diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go new file mode 100644 index 00000000000..87749139a2a --- /dev/null +++ b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbasemarketplacedetailsupdate.go @@ -0,0 +1,10 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseMarketplaceDetailsUpdate struct { + OfferDetails *LiftrBaseOfferDetailsUpdate `json:"offerDetails,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionStatus *MarketplaceSubscriptionStatus `json:"subscriptionStatus,omitempty"` +} diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go new file mode 100644 index 00000000000..4b2d9aed2b4 --- /dev/null +++ b/resource-manager/astronomer/2023-08-01/organizations/model_liftrbaseofferdetailsupdate.go @@ -0,0 +1,13 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseOfferDetailsUpdate struct { + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PlanName *string `json:"planName,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + TermId *string `json:"termId,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` +} diff --git a/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go b/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go index 6d313e73494..e9a3795a650 100644 --- a/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go +++ b/resource-manager/astronomer/2023-08-01/organizations/model_organizationresourceupdateproperties.go @@ -4,6 +4,7 @@ package organizations // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type OrganizationResourceUpdateProperties struct { + Marketplace *LiftrBaseMarketplaceDetailsUpdate `json:"marketplace,omitempty"` PartnerOrganizationProperties *LiftrBaseDataPartnerOrganizationPropertiesUpdate `json:"partnerOrganizationProperties,omitempty"` User *LiftrBaseUserDetailsUpdate `json:"user,omitempty"` } diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go new file mode 100644 index 00000000000..87749139a2a --- /dev/null +++ b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbasemarketplacedetailsupdate.go @@ -0,0 +1,10 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseMarketplaceDetailsUpdate struct { + OfferDetails *LiftrBaseOfferDetailsUpdate `json:"offerDetails,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionStatus *MarketplaceSubscriptionStatus `json:"subscriptionStatus,omitempty"` +} diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go new file mode 100644 index 00000000000..07234d33576 --- /dev/null +++ b/resource-manager/astronomer/2024-08-27/organizations/model_liftrbaseofferdetailsupdate.go @@ -0,0 +1,14 @@ +package organizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LiftrBaseOfferDetailsUpdate struct { + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PlanName *string `json:"planName,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + RenewalMode *RenewalMode `json:"renewalMode,omitempty"` + TermId *string `json:"termId,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` +} diff --git a/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go b/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go index 6d313e73494..e9a3795a650 100644 --- a/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go +++ b/resource-manager/astronomer/2024-08-27/organizations/model_organizationresourceupdateproperties.go @@ -4,6 +4,7 @@ package organizations // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type OrganizationResourceUpdateProperties struct { + Marketplace *LiftrBaseMarketplaceDetailsUpdate `json:"marketplace,omitempty"` PartnerOrganizationProperties *LiftrBaseDataPartnerOrganizationPropertiesUpdate `json:"partnerOrganizationProperties,omitempty"` User *LiftrBaseUserDetailsUpdate `json:"user,omitempty"` } diff --git a/resource-manager/azurefleet/2024-11-01/client.go b/resource-manager/azurefleet/2024-11-01/client.go new file mode 100644 index 00000000000..1f429f1c406 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/client.go @@ -0,0 +1,28 @@ +package v2024_11_01 + +// 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/azurefleet/2024-11-01/fleets" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Fleets *fleets.FleetsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + fleetsClient, err := fleets.NewFleetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Fleets client: %+v", err) + } + configureFunc(fleetsClient.Client) + + return &Client{ + Fleets: fleetsClient, + }, nil +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/README.md b/resource-manager/azurefleet/2024-11-01/fleets/README.md new file mode 100644 index 00000000000..9d7aeb86e4a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/README.md @@ -0,0 +1,134 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurefleet/2024-11-01/fleets` Documentation + +The `fleets` SDK allows for interaction with Azure Resource Manager `azurefleet` (API Version `2024-11-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurefleet/2024-11-01/fleets" +``` + + +### Client Initialization + +```go +client := fleets.NewFleetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FleetsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := fleets.NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + +payload := fleets.Fleet{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FleetsClient.Delete` + +```go +ctx := context.TODO() +id := fleets.NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FleetsClient.Get` + +```go +ctx := context.TODO() +id := fleets.NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + +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: `FleetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FleetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FleetsClient.ListVirtualMachineScaleSets` + +```go +ctx := context.TODO() +id := fleets.NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + +// alternatively `client.ListVirtualMachineScaleSets(ctx, id)` can be used to do batched pagination +items, err := client.ListVirtualMachineScaleSetsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FleetsClient.Update` + +```go +ctx := context.TODO() +id := fleets.NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + +payload := fleets.FleetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurefleet/2024-11-01/fleets/client.go b/resource-manager/azurefleet/2024-11-01/fleets/client.go new file mode 100644 index 00000000000..212151c2570 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/client.go @@ -0,0 +1,26 @@ +package fleets + +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 FleetsClient struct { + Client *resourcemanager.Client +} + +func NewFleetsClientWithBaseURI(sdkApi sdkEnv.Api) (*FleetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "fleets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FleetsClient: %+v", err) + } + + return &FleetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/constants.go b/resource-manager/azurefleet/2024-11-01/fleets/constants.go new file mode 100644 index 00000000000..6cfa0c3758d --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/constants.go @@ -0,0 +1,1796 @@ +package fleets + +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 AcceleratorManufacturer string + +const ( + AcceleratorManufacturerAMD AcceleratorManufacturer = "AMD" + AcceleratorManufacturerNvidia AcceleratorManufacturer = "Nvidia" + AcceleratorManufacturerXilinx AcceleratorManufacturer = "Xilinx" +) + +func PossibleValuesForAcceleratorManufacturer() []string { + return []string{ + string(AcceleratorManufacturerAMD), + string(AcceleratorManufacturerNvidia), + string(AcceleratorManufacturerXilinx), + } +} + +func (s *AcceleratorManufacturer) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAcceleratorManufacturer(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAcceleratorManufacturer(input string) (*AcceleratorManufacturer, error) { + vals := map[string]AcceleratorManufacturer{ + "amd": AcceleratorManufacturerAMD, + "nvidia": AcceleratorManufacturerNvidia, + "xilinx": AcceleratorManufacturerXilinx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcceleratorManufacturer(input) + return &out, nil +} + +type AcceleratorType string + +const ( + AcceleratorTypeFPGA AcceleratorType = "FPGA" + AcceleratorTypeGPU AcceleratorType = "GPU" +) + +func PossibleValuesForAcceleratorType() []string { + return []string{ + string(AcceleratorTypeFPGA), + string(AcceleratorTypeGPU), + } +} + +func (s *AcceleratorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAcceleratorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAcceleratorType(input string) (*AcceleratorType, error) { + vals := map[string]AcceleratorType{ + "fpga": AcceleratorTypeFPGA, + "gpu": AcceleratorTypeGPU, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcceleratorType(input) + return &out, nil +} + +type ArchitectureType string + +const ( + ArchitectureTypeARMSixFour ArchitectureType = "ARM64" + ArchitectureTypeXSixFour ArchitectureType = "X64" +) + +func PossibleValuesForArchitectureType() []string { + return []string{ + string(ArchitectureTypeARMSixFour), + string(ArchitectureTypeXSixFour), + } +} + +func (s *ArchitectureType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseArchitectureType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseArchitectureType(input string) (*ArchitectureType, error) { + vals := map[string]ArchitectureType{ + "arm64": ArchitectureTypeARMSixFour, + "x64": ArchitectureTypeXSixFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ArchitectureType(input) + return &out, nil +} + +type CPUManufacturer string + +const ( + CPUManufacturerAMD CPUManufacturer = "AMD" + CPUManufacturerAmpere CPUManufacturer = "Ampere" + CPUManufacturerIntel CPUManufacturer = "Intel" + CPUManufacturerMicrosoft CPUManufacturer = "Microsoft" +) + +func PossibleValuesForCPUManufacturer() []string { + return []string{ + string(CPUManufacturerAMD), + string(CPUManufacturerAmpere), + string(CPUManufacturerIntel), + string(CPUManufacturerMicrosoft), + } +} + +func (s *CPUManufacturer) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCPUManufacturer(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCPUManufacturer(input string) (*CPUManufacturer, error) { + vals := map[string]CPUManufacturer{ + "amd": CPUManufacturerAMD, + "ampere": CPUManufacturerAmpere, + "intel": CPUManufacturerIntel, + "microsoft": CPUManufacturerMicrosoft, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CPUManufacturer(input) + return &out, nil +} + +type CachingTypes string + +const ( + CachingTypesNone CachingTypes = "None" + CachingTypesReadOnly CachingTypes = "ReadOnly" + CachingTypesReadWrite CachingTypes = "ReadWrite" +) + +func PossibleValuesForCachingTypes() []string { + return []string{ + string(CachingTypesNone), + string(CachingTypesReadOnly), + string(CachingTypesReadWrite), + } +} + +func (s *CachingTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCachingTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCachingTypes(input string) (*CachingTypes, error) { + vals := map[string]CachingTypes{ + "none": CachingTypesNone, + "readonly": CachingTypesReadOnly, + "readwrite": CachingTypesReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CachingTypes(input) + return &out, nil +} + +type ComponentName string + +const ( + ComponentNameMicrosoftNegativeWindowsNegativeShellNegativeSetup ComponentName = "Microsoft-Windows-Shell-Setup" +) + +func PossibleValuesForComponentName() []string { + return []string{ + string(ComponentNameMicrosoftNegativeWindowsNegativeShellNegativeSetup), + } +} + +func (s *ComponentName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComponentName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComponentName(input string) (*ComponentName, error) { + vals := map[string]ComponentName{ + "microsoft-windows-shell-setup": ComponentNameMicrosoftNegativeWindowsNegativeShellNegativeSetup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComponentName(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type DiffDiskOptions string + +const ( + DiffDiskOptionsLocal DiffDiskOptions = "Local" +) + +func PossibleValuesForDiffDiskOptions() []string { + return []string{ + string(DiffDiskOptionsLocal), + } +} + +func (s *DiffDiskOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiffDiskOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiffDiskOptions(input string) (*DiffDiskOptions, error) { + vals := map[string]DiffDiskOptions{ + "local": DiffDiskOptionsLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiffDiskOptions(input) + return &out, nil +} + +type DiffDiskPlacement string + +const ( + DiffDiskPlacementCacheDisk DiffDiskPlacement = "CacheDisk" + DiffDiskPlacementNVMeDisk DiffDiskPlacement = "NvmeDisk" + DiffDiskPlacementResourceDisk DiffDiskPlacement = "ResourceDisk" +) + +func PossibleValuesForDiffDiskPlacement() []string { + return []string{ + string(DiffDiskPlacementCacheDisk), + string(DiffDiskPlacementNVMeDisk), + string(DiffDiskPlacementResourceDisk), + } +} + +func (s *DiffDiskPlacement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiffDiskPlacement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiffDiskPlacement(input string) (*DiffDiskPlacement, error) { + vals := map[string]DiffDiskPlacement{ + "cachedisk": DiffDiskPlacementCacheDisk, + "nvmedisk": DiffDiskPlacementNVMeDisk, + "resourcedisk": DiffDiskPlacementResourceDisk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiffDiskPlacement(input) + return &out, nil +} + +type DiskControllerTypes string + +const ( + DiskControllerTypesNVMe DiskControllerTypes = "NVMe" + DiskControllerTypesSCSI DiskControllerTypes = "SCSI" +) + +func PossibleValuesForDiskControllerTypes() []string { + return []string{ + string(DiskControllerTypesNVMe), + string(DiskControllerTypesSCSI), + } +} + +func (s *DiskControllerTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskControllerTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskControllerTypes(input string) (*DiskControllerTypes, error) { + vals := map[string]DiskControllerTypes{ + "nvme": DiskControllerTypesNVMe, + "scsi": DiskControllerTypesSCSI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskControllerTypes(input) + return &out, nil +} + +type DiskCreateOptionTypes string + +const ( + DiskCreateOptionTypesAttach DiskCreateOptionTypes = "Attach" + DiskCreateOptionTypesCopy DiskCreateOptionTypes = "Copy" + DiskCreateOptionTypesEmpty DiskCreateOptionTypes = "Empty" + DiskCreateOptionTypesFromImage DiskCreateOptionTypes = "FromImage" + DiskCreateOptionTypesRestore DiskCreateOptionTypes = "Restore" +) + +func PossibleValuesForDiskCreateOptionTypes() []string { + return []string{ + string(DiskCreateOptionTypesAttach), + string(DiskCreateOptionTypesCopy), + string(DiskCreateOptionTypesEmpty), + string(DiskCreateOptionTypesFromImage), + string(DiskCreateOptionTypesRestore), + } +} + +func (s *DiskCreateOptionTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskCreateOptionTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskCreateOptionTypes(input string) (*DiskCreateOptionTypes, error) { + vals := map[string]DiskCreateOptionTypes{ + "attach": DiskCreateOptionTypesAttach, + "copy": DiskCreateOptionTypesCopy, + "empty": DiskCreateOptionTypesEmpty, + "fromimage": DiskCreateOptionTypesFromImage, + "restore": DiskCreateOptionTypesRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskCreateOptionTypes(input) + return &out, nil +} + +type DiskDeleteOptionTypes string + +const ( + DiskDeleteOptionTypesDelete DiskDeleteOptionTypes = "Delete" + DiskDeleteOptionTypesDetach DiskDeleteOptionTypes = "Detach" +) + +func PossibleValuesForDiskDeleteOptionTypes() []string { + return []string{ + string(DiskDeleteOptionTypesDelete), + string(DiskDeleteOptionTypesDetach), + } +} + +func (s *DiskDeleteOptionTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskDeleteOptionTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskDeleteOptionTypes(input string) (*DiskDeleteOptionTypes, error) { + vals := map[string]DiskDeleteOptionTypes{ + "delete": DiskDeleteOptionTypesDelete, + "detach": DiskDeleteOptionTypesDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskDeleteOptionTypes(input) + return &out, nil +} + +type DomainNameLabelScopeTypes string + +const ( + DomainNameLabelScopeTypesNoReuse DomainNameLabelScopeTypes = "NoReuse" + DomainNameLabelScopeTypesResourceGroupReuse DomainNameLabelScopeTypes = "ResourceGroupReuse" + DomainNameLabelScopeTypesSubscriptionReuse DomainNameLabelScopeTypes = "SubscriptionReuse" + DomainNameLabelScopeTypesTenantReuse DomainNameLabelScopeTypes = "TenantReuse" +) + +func PossibleValuesForDomainNameLabelScopeTypes() []string { + return []string{ + string(DomainNameLabelScopeTypesNoReuse), + string(DomainNameLabelScopeTypesResourceGroupReuse), + string(DomainNameLabelScopeTypesSubscriptionReuse), + string(DomainNameLabelScopeTypesTenantReuse), + } +} + +func (s *DomainNameLabelScopeTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainNameLabelScopeTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainNameLabelScopeTypes(input string) (*DomainNameLabelScopeTypes, error) { + vals := map[string]DomainNameLabelScopeTypes{ + "noreuse": DomainNameLabelScopeTypesNoReuse, + "resourcegroupreuse": DomainNameLabelScopeTypesResourceGroupReuse, + "subscriptionreuse": DomainNameLabelScopeTypesSubscriptionReuse, + "tenantreuse": DomainNameLabelScopeTypesTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainNameLabelScopeTypes(input) + return &out, nil +} + +type EvictionPolicy string + +const ( + EvictionPolicyDeallocate EvictionPolicy = "Deallocate" + EvictionPolicyDelete EvictionPolicy = "Delete" +) + +func PossibleValuesForEvictionPolicy() []string { + return []string{ + string(EvictionPolicyDeallocate), + string(EvictionPolicyDelete), + } +} + +func (s *EvictionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEvictionPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEvictionPolicy(input string) (*EvictionPolicy, error) { + vals := map[string]EvictionPolicy{ + "deallocate": EvictionPolicyDeallocate, + "delete": EvictionPolicyDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EvictionPolicy(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LinuxPatchAssessmentMode string + +const ( + LinuxPatchAssessmentModeAutomaticByPlatform LinuxPatchAssessmentMode = "AutomaticByPlatform" + LinuxPatchAssessmentModeImageDefault LinuxPatchAssessmentMode = "ImageDefault" +) + +func PossibleValuesForLinuxPatchAssessmentMode() []string { + return []string{ + string(LinuxPatchAssessmentModeAutomaticByPlatform), + string(LinuxPatchAssessmentModeImageDefault), + } +} + +func (s *LinuxPatchAssessmentMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxPatchAssessmentMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxPatchAssessmentMode(input string) (*LinuxPatchAssessmentMode, error) { + vals := map[string]LinuxPatchAssessmentMode{ + "automaticbyplatform": LinuxPatchAssessmentModeAutomaticByPlatform, + "imagedefault": LinuxPatchAssessmentModeImageDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxPatchAssessmentMode(input) + return &out, nil +} + +type LinuxVMGuestPatchAutomaticByPlatformRebootSetting string + +const ( + LinuxVMGuestPatchAutomaticByPlatformRebootSettingAlways LinuxVMGuestPatchAutomaticByPlatformRebootSetting = "Always" + LinuxVMGuestPatchAutomaticByPlatformRebootSettingIfRequired LinuxVMGuestPatchAutomaticByPlatformRebootSetting = "IfRequired" + LinuxVMGuestPatchAutomaticByPlatformRebootSettingNever LinuxVMGuestPatchAutomaticByPlatformRebootSetting = "Never" + LinuxVMGuestPatchAutomaticByPlatformRebootSettingUnknown LinuxVMGuestPatchAutomaticByPlatformRebootSetting = "Unknown" +) + +func PossibleValuesForLinuxVMGuestPatchAutomaticByPlatformRebootSetting() []string { + return []string{ + string(LinuxVMGuestPatchAutomaticByPlatformRebootSettingAlways), + string(LinuxVMGuestPatchAutomaticByPlatformRebootSettingIfRequired), + string(LinuxVMGuestPatchAutomaticByPlatformRebootSettingNever), + string(LinuxVMGuestPatchAutomaticByPlatformRebootSettingUnknown), + } +} + +func (s *LinuxVMGuestPatchAutomaticByPlatformRebootSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxVMGuestPatchAutomaticByPlatformRebootSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxVMGuestPatchAutomaticByPlatformRebootSetting(input string) (*LinuxVMGuestPatchAutomaticByPlatformRebootSetting, error) { + vals := map[string]LinuxVMGuestPatchAutomaticByPlatformRebootSetting{ + "always": LinuxVMGuestPatchAutomaticByPlatformRebootSettingAlways, + "ifrequired": LinuxVMGuestPatchAutomaticByPlatformRebootSettingIfRequired, + "never": LinuxVMGuestPatchAutomaticByPlatformRebootSettingNever, + "unknown": LinuxVMGuestPatchAutomaticByPlatformRebootSettingUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxVMGuestPatchAutomaticByPlatformRebootSetting(input) + return &out, nil +} + +type LinuxVMGuestPatchMode string + +const ( + LinuxVMGuestPatchModeAutomaticByPlatform LinuxVMGuestPatchMode = "AutomaticByPlatform" + LinuxVMGuestPatchModeImageDefault LinuxVMGuestPatchMode = "ImageDefault" +) + +func PossibleValuesForLinuxVMGuestPatchMode() []string { + return []string{ + string(LinuxVMGuestPatchModeAutomaticByPlatform), + string(LinuxVMGuestPatchModeImageDefault), + } +} + +func (s *LinuxVMGuestPatchMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxVMGuestPatchMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxVMGuestPatchMode(input string) (*LinuxVMGuestPatchMode, error) { + vals := map[string]LinuxVMGuestPatchMode{ + "automaticbyplatform": LinuxVMGuestPatchModeAutomaticByPlatform, + "imagedefault": LinuxVMGuestPatchModeImageDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxVMGuestPatchMode(input) + return &out, nil +} + +type LocalStorageDiskType string + +const ( + LocalStorageDiskTypeHDD LocalStorageDiskType = "HDD" + LocalStorageDiskTypeSSD LocalStorageDiskType = "SSD" +) + +func PossibleValuesForLocalStorageDiskType() []string { + return []string{ + string(LocalStorageDiskTypeHDD), + string(LocalStorageDiskTypeSSD), + } +} + +func (s *LocalStorageDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLocalStorageDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLocalStorageDiskType(input string) (*LocalStorageDiskType, error) { + vals := map[string]LocalStorageDiskType{ + "hdd": LocalStorageDiskTypeHDD, + "ssd": LocalStorageDiskTypeSSD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LocalStorageDiskType(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + string(ManagedServiceIdentityTypeSystemAssignedUserAssigned), + string(ManagedServiceIdentityTypeUserAssigned), + } +} + +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + "systemassigned,userassigned": ManagedServiceIdentityTypeSystemAssignedUserAssigned, + "userassigned": ManagedServiceIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type Mode string + +const ( + ModeAudit Mode = "Audit" + ModeEnforce Mode = "Enforce" +) + +func PossibleValuesForMode() []string { + return []string{ + string(ModeAudit), + string(ModeEnforce), + } +} + +func (s *Mode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMode(input string) (*Mode, error) { + vals := map[string]Mode{ + "audit": ModeAudit, + "enforce": ModeEnforce, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Mode(input) + return &out, nil +} + +type NetworkApiVersion string + +const ( + NetworkApiVersionTwoZeroTwoZeroNegativeOneOneNegativeZeroOne NetworkApiVersion = "2020-11-01" +) + +func PossibleValuesForNetworkApiVersion() []string { + return []string{ + string(NetworkApiVersionTwoZeroTwoZeroNegativeOneOneNegativeZeroOne), + } +} + +func (s *NetworkApiVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkApiVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkApiVersion(input string) (*NetworkApiVersion, error) { + vals := map[string]NetworkApiVersion{ + "2020-11-01": NetworkApiVersionTwoZeroTwoZeroNegativeOneOneNegativeZeroOne, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkApiVersion(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(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 PassName string + +const ( + PassNameOobeSystem PassName = "OobeSystem" +) + +func PossibleValuesForPassName() []string { + return []string{ + string(PassNameOobeSystem), + } +} + +func (s *PassName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePassName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePassName(input string) (*PassName, error) { + vals := map[string]PassName{ + "oobesystem": PassNameOobeSystem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PassName(input) + return &out, nil +} + +type ProtocolTypes string + +const ( + ProtocolTypesHTTP ProtocolTypes = "Http" + ProtocolTypesHTTPS ProtocolTypes = "Https" +) + +func PossibleValuesForProtocolTypes() []string { + return []string{ + string(ProtocolTypesHTTP), + string(ProtocolTypesHTTPS), + } +} + +func (s *ProtocolTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocolTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocolTypes(input string) (*ProtocolTypes, error) { + vals := map[string]ProtocolTypes{ + "http": ProtocolTypesHTTP, + "https": ProtocolTypesHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtocolTypes(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMigrating ProvisioningState = "Migrating" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMigrating), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "migrating": ProvisioningStateMigrating, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RegularPriorityAllocationStrategy string + +const ( + RegularPriorityAllocationStrategyLowestPrice RegularPriorityAllocationStrategy = "LowestPrice" + RegularPriorityAllocationStrategyPrioritized RegularPriorityAllocationStrategy = "Prioritized" +) + +func PossibleValuesForRegularPriorityAllocationStrategy() []string { + return []string{ + string(RegularPriorityAllocationStrategyLowestPrice), + string(RegularPriorityAllocationStrategyPrioritized), + } +} + +func (s *RegularPriorityAllocationStrategy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegularPriorityAllocationStrategy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegularPriorityAllocationStrategy(input string) (*RegularPriorityAllocationStrategy, error) { + vals := map[string]RegularPriorityAllocationStrategy{ + "lowestprice": RegularPriorityAllocationStrategyLowestPrice, + "prioritized": RegularPriorityAllocationStrategyPrioritized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegularPriorityAllocationStrategy(input) + return &out, nil +} + +type SecurityEncryptionTypes string + +const ( + SecurityEncryptionTypesDiskWithVMGuestState SecurityEncryptionTypes = "DiskWithVMGuestState" + SecurityEncryptionTypesNonPersistedTPM SecurityEncryptionTypes = "NonPersistedTPM" + SecurityEncryptionTypesVMGuestStateOnly SecurityEncryptionTypes = "VMGuestStateOnly" +) + +func PossibleValuesForSecurityEncryptionTypes() []string { + return []string{ + string(SecurityEncryptionTypesDiskWithVMGuestState), + string(SecurityEncryptionTypesNonPersistedTPM), + string(SecurityEncryptionTypesVMGuestStateOnly), + } +} + +func (s *SecurityEncryptionTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityEncryptionTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityEncryptionTypes(input string) (*SecurityEncryptionTypes, error) { + vals := map[string]SecurityEncryptionTypes{ + "diskwithvmgueststate": SecurityEncryptionTypesDiskWithVMGuestState, + "nonpersistedtpm": SecurityEncryptionTypesNonPersistedTPM, + "vmgueststateonly": SecurityEncryptionTypesVMGuestStateOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityEncryptionTypes(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 SettingNames string + +const ( + SettingNamesAutoLogon SettingNames = "AutoLogon" + SettingNamesFirstLogonCommands SettingNames = "FirstLogonCommands" +) + +func PossibleValuesForSettingNames() []string { + return []string{ + string(SettingNamesAutoLogon), + string(SettingNamesFirstLogonCommands), + } +} + +func (s *SettingNames) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSettingNames(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSettingNames(input string) (*SettingNames, error) { + vals := map[string]SettingNames{ + "autologon": SettingNamesAutoLogon, + "firstlogoncommands": SettingNamesFirstLogonCommands, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SettingNames(input) + return &out, nil +} + +type SpotAllocationStrategy string + +const ( + SpotAllocationStrategyCapacityOptimized SpotAllocationStrategy = "CapacityOptimized" + SpotAllocationStrategyLowestPrice SpotAllocationStrategy = "LowestPrice" + SpotAllocationStrategyPriceCapacityOptimized SpotAllocationStrategy = "PriceCapacityOptimized" +) + +func PossibleValuesForSpotAllocationStrategy() []string { + return []string{ + string(SpotAllocationStrategyCapacityOptimized), + string(SpotAllocationStrategyLowestPrice), + string(SpotAllocationStrategyPriceCapacityOptimized), + } +} + +func (s *SpotAllocationStrategy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSpotAllocationStrategy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSpotAllocationStrategy(input string) (*SpotAllocationStrategy, error) { + vals := map[string]SpotAllocationStrategy{ + "capacityoptimized": SpotAllocationStrategyCapacityOptimized, + "lowestprice": SpotAllocationStrategyLowestPrice, + "pricecapacityoptimized": SpotAllocationStrategyPriceCapacityOptimized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SpotAllocationStrategy(input) + return &out, nil +} + +type StorageAccountTypes string + +const ( + StorageAccountTypesPremiumLRS StorageAccountTypes = "Premium_LRS" + StorageAccountTypesPremiumVTwoLRS StorageAccountTypes = "PremiumV2_LRS" + StorageAccountTypesPremiumZRS StorageAccountTypes = "Premium_ZRS" + StorageAccountTypesStandardLRS StorageAccountTypes = "Standard_LRS" + StorageAccountTypesStandardSSDLRS StorageAccountTypes = "StandardSSD_LRS" + StorageAccountTypesStandardSSDZRS StorageAccountTypes = "StandardSSD_ZRS" + StorageAccountTypesUltraSSDLRS StorageAccountTypes = "UltraSSD_LRS" +) + +func PossibleValuesForStorageAccountTypes() []string { + return []string{ + string(StorageAccountTypesPremiumLRS), + string(StorageAccountTypesPremiumVTwoLRS), + string(StorageAccountTypesPremiumZRS), + string(StorageAccountTypesStandardLRS), + string(StorageAccountTypesStandardSSDLRS), + string(StorageAccountTypesStandardSSDZRS), + string(StorageAccountTypesUltraSSDLRS), + } +} + +func (s *StorageAccountTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAccountTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAccountTypes(input string) (*StorageAccountTypes, error) { + vals := map[string]StorageAccountTypes{ + "premium_lrs": StorageAccountTypesPremiumLRS, + "premiumv2_lrs": StorageAccountTypesPremiumVTwoLRS, + "premium_zrs": StorageAccountTypesPremiumZRS, + "standard_lrs": StorageAccountTypesStandardLRS, + "standardssd_lrs": StorageAccountTypesStandardSSDLRS, + "standardssd_zrs": StorageAccountTypesStandardSSDZRS, + "ultrassd_lrs": StorageAccountTypesUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAccountTypes(input) + return &out, nil +} + +type VMAttributeSupport string + +const ( + VMAttributeSupportExcluded VMAttributeSupport = "Excluded" + VMAttributeSupportIncluded VMAttributeSupport = "Included" + VMAttributeSupportRequired VMAttributeSupport = "Required" +) + +func PossibleValuesForVMAttributeSupport() []string { + return []string{ + string(VMAttributeSupportExcluded), + string(VMAttributeSupportIncluded), + string(VMAttributeSupportRequired), + } +} + +func (s *VMAttributeSupport) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMAttributeSupport(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMAttributeSupport(input string) (*VMAttributeSupport, error) { + vals := map[string]VMAttributeSupport{ + "excluded": VMAttributeSupportExcluded, + "included": VMAttributeSupportIncluded, + "required": VMAttributeSupportRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMAttributeSupport(input) + return &out, nil +} + +type VMCategory string + +const ( + VMCategoryComputeOptimized VMCategory = "ComputeOptimized" + VMCategoryFpgaAccelerated VMCategory = "FpgaAccelerated" + VMCategoryGeneralPurpose VMCategory = "GeneralPurpose" + VMCategoryGpuAccelerated VMCategory = "GpuAccelerated" + VMCategoryHighPerformanceCompute VMCategory = "HighPerformanceCompute" + VMCategoryMemoryOptimized VMCategory = "MemoryOptimized" + VMCategoryStorageOptimized VMCategory = "StorageOptimized" +) + +func PossibleValuesForVMCategory() []string { + return []string{ + string(VMCategoryComputeOptimized), + string(VMCategoryFpgaAccelerated), + string(VMCategoryGeneralPurpose), + string(VMCategoryGpuAccelerated), + string(VMCategoryHighPerformanceCompute), + string(VMCategoryMemoryOptimized), + string(VMCategoryStorageOptimized), + } +} + +func (s *VMCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMCategory(input string) (*VMCategory, error) { + vals := map[string]VMCategory{ + "computeoptimized": VMCategoryComputeOptimized, + "fpgaaccelerated": VMCategoryFpgaAccelerated, + "generalpurpose": VMCategoryGeneralPurpose, + "gpuaccelerated": VMCategoryGpuAccelerated, + "highperformancecompute": VMCategoryHighPerformanceCompute, + "memoryoptimized": VMCategoryMemoryOptimized, + "storageoptimized": VMCategoryStorageOptimized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMCategory(input) + return &out, nil +} + +type WindowsPatchAssessmentMode string + +const ( + WindowsPatchAssessmentModeAutomaticByPlatform WindowsPatchAssessmentMode = "AutomaticByPlatform" + WindowsPatchAssessmentModeImageDefault WindowsPatchAssessmentMode = "ImageDefault" +) + +func PossibleValuesForWindowsPatchAssessmentMode() []string { + return []string{ + string(WindowsPatchAssessmentModeAutomaticByPlatform), + string(WindowsPatchAssessmentModeImageDefault), + } +} + +func (s *WindowsPatchAssessmentMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWindowsPatchAssessmentMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWindowsPatchAssessmentMode(input string) (*WindowsPatchAssessmentMode, error) { + vals := map[string]WindowsPatchAssessmentMode{ + "automaticbyplatform": WindowsPatchAssessmentModeAutomaticByPlatform, + "imagedefault": WindowsPatchAssessmentModeImageDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WindowsPatchAssessmentMode(input) + return &out, nil +} + +type WindowsVMGuestPatchAutomaticByPlatformRebootSetting string + +const ( + WindowsVMGuestPatchAutomaticByPlatformRebootSettingAlways WindowsVMGuestPatchAutomaticByPlatformRebootSetting = "Always" + WindowsVMGuestPatchAutomaticByPlatformRebootSettingIfRequired WindowsVMGuestPatchAutomaticByPlatformRebootSetting = "IfRequired" + WindowsVMGuestPatchAutomaticByPlatformRebootSettingNever WindowsVMGuestPatchAutomaticByPlatformRebootSetting = "Never" + WindowsVMGuestPatchAutomaticByPlatformRebootSettingUnknown WindowsVMGuestPatchAutomaticByPlatformRebootSetting = "Unknown" +) + +func PossibleValuesForWindowsVMGuestPatchAutomaticByPlatformRebootSetting() []string { + return []string{ + string(WindowsVMGuestPatchAutomaticByPlatformRebootSettingAlways), + string(WindowsVMGuestPatchAutomaticByPlatformRebootSettingIfRequired), + string(WindowsVMGuestPatchAutomaticByPlatformRebootSettingNever), + string(WindowsVMGuestPatchAutomaticByPlatformRebootSettingUnknown), + } +} + +func (s *WindowsVMGuestPatchAutomaticByPlatformRebootSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWindowsVMGuestPatchAutomaticByPlatformRebootSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWindowsVMGuestPatchAutomaticByPlatformRebootSetting(input string) (*WindowsVMGuestPatchAutomaticByPlatformRebootSetting, error) { + vals := map[string]WindowsVMGuestPatchAutomaticByPlatformRebootSetting{ + "always": WindowsVMGuestPatchAutomaticByPlatformRebootSettingAlways, + "ifrequired": WindowsVMGuestPatchAutomaticByPlatformRebootSettingIfRequired, + "never": WindowsVMGuestPatchAutomaticByPlatformRebootSettingNever, + "unknown": WindowsVMGuestPatchAutomaticByPlatformRebootSettingUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WindowsVMGuestPatchAutomaticByPlatformRebootSetting(input) + return &out, nil +} + +type WindowsVMGuestPatchMode string + +const ( + WindowsVMGuestPatchModeAutomaticByOS WindowsVMGuestPatchMode = "AutomaticByOS" + WindowsVMGuestPatchModeAutomaticByPlatform WindowsVMGuestPatchMode = "AutomaticByPlatform" + WindowsVMGuestPatchModeManual WindowsVMGuestPatchMode = "Manual" +) + +func PossibleValuesForWindowsVMGuestPatchMode() []string { + return []string{ + string(WindowsVMGuestPatchModeAutomaticByOS), + string(WindowsVMGuestPatchModeAutomaticByPlatform), + string(WindowsVMGuestPatchModeManual), + } +} + +func (s *WindowsVMGuestPatchMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWindowsVMGuestPatchMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWindowsVMGuestPatchMode(input string) (*WindowsVMGuestPatchMode, error) { + vals := map[string]WindowsVMGuestPatchMode{ + "automaticbyos": WindowsVMGuestPatchModeAutomaticByOS, + "automaticbyplatform": WindowsVMGuestPatchModeAutomaticByPlatform, + "manual": WindowsVMGuestPatchModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WindowsVMGuestPatchMode(input) + return &out, nil +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/id_fleet.go b/resource-manager/azurefleet/2024-11-01/fleets/id_fleet.go new file mode 100644 index 00000000000..1983424335c --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/id_fleet.go @@ -0,0 +1,130 @@ +package fleets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FleetId{}) +} + +var _ resourceids.ResourceId = &FleetId{} + +// FleetId is a struct representing the Resource ID for a Fleet +type FleetId struct { + SubscriptionId string + ResourceGroupName string + FleetName string +} + +// NewFleetID returns a new FleetId struct +func NewFleetID(subscriptionId string, resourceGroupName string, fleetName string) FleetId { + return FleetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FleetName: fleetName, + } +} + +// ParseFleetID parses 'input' into a FleetId +func ParseFleetID(input string) (*FleetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FleetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FleetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFleetIDInsensitively parses 'input' case-insensitively into a FleetId +// note: this method should only be used for API response data and not user input +func ParseFleetIDInsensitively(input string) (*FleetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FleetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FleetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FleetId) 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.FleetName, ok = input.Parsed["fleetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "fleetName", input) + } + + return nil +} + +// ValidateFleetID checks that 'input' can be parsed as a Fleet ID +func ValidateFleetID(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 := ParseFleetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fleet ID +func (id FleetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureFleet/fleets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FleetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fleet ID +func (id FleetId) 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("staticMicrosoftAzureFleet", "Microsoft.AzureFleet", "Microsoft.AzureFleet"), + resourceids.StaticSegment("staticFleets", "fleets", "fleets"), + resourceids.UserSpecifiedSegment("fleetName", "fleetName"), + } +} + +// String returns a human-readable description of this Fleet ID +func (id FleetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Fleet Name: %q", id.FleetName), + } + return fmt.Sprintf("Fleet (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/id_fleet_test.go b/resource-manager/azurefleet/2024-11-01/fleets/id_fleet_test.go new file mode 100644 index 00000000000..fa496a7a607 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/id_fleet_test.go @@ -0,0 +1,282 @@ +package fleets + +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 = &FleetId{} + +func TestNewFleetID(t *testing.T) { + id := NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName") + + 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.FleetName != "fleetName" { + t.Fatalf("Expected %q but got %q for Segment 'FleetName'", id.FleetName, "fleetName") + } +} + +func TestFormatFleetID(t *testing.T) { + actual := NewFleetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fleetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets/fleetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFleetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FleetId + }{ + { + // 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.AzureFleet", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets/fleetName", + Expected: &FleetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FleetName: "fleetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets/fleetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFleetID(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.FleetName != v.Expected.FleetName { + t.Fatalf("Expected %q but got %q for FleetName", v.Expected.FleetName, actual.FleetName) + } + + } +} + +func TestParseFleetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FleetId + }{ + { + // 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.AzureFleet", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReFlEeT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReFlEeT/fLeEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets/fleetName", + Expected: &FleetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FleetName: "fleetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureFleet/fleets/fleetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReFlEeT/fLeEtS/fLeEtNaMe", + Expected: &FleetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FleetName: "fLeEtNaMe", + }, + }, + { + // 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.aZuReFlEeT/fLeEtS/fLeEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFleetIDInsensitively(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.FleetName != v.Expected.FleetName { + t.Fatalf("Expected %q but got %q for FleetName", v.Expected.FleetName, actual.FleetName) + } + + } +} + +func TestSegmentsForFleetId(t *testing.T) { + segments := FleetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FleetId 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/azurefleet/2024-11-01/fleets/method_createorupdate.go b/resource-manager/azurefleet/2024-11-01/fleets/method_createorupdate.go new file mode 100644 index 00000000000..059481c5752 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_createorupdate.go @@ -0,0 +1,75 @@ +package fleets + +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 + Model *Fleet +} + +// CreateOrUpdate ... +func (c FleetsClient) CreateOrUpdate(ctx context.Context, id FleetId, input Fleet) (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 FleetsClient) CreateOrUpdateThenPoll(ctx context.Context, id FleetId, input Fleet) 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/azurefleet/2024-11-01/fleets/method_delete.go b/resource-manager/azurefleet/2024-11-01/fleets/method_delete.go new file mode 100644 index 00000000000..2af3eb57f17 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_delete.go @@ -0,0 +1,70 @@ +package fleets + +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 FleetsClient) Delete(ctx context.Context, id FleetId) (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 FleetsClient) DeleteThenPoll(ctx context.Context, id FleetId) 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/azurefleet/2024-11-01/fleets/method_get.go b/resource-manager/azurefleet/2024-11-01/fleets/method_get.go new file mode 100644 index 00000000000..c45bbd36e11 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_get.go @@ -0,0 +1,53 @@ +package fleets + +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 *Fleet +} + +// Get ... +func (c FleetsClient) Get(ctx context.Context, id FleetId) (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 + } + + var model Fleet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/method_listbyresourcegroup.go b/resource-manager/azurefleet/2024-11-01/fleets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..6dde708b85a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package fleets + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Fleet +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Fleet +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c FleetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureFleet/fleets", 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 *[]Fleet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c FleetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, FleetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FleetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FleetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Fleet, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/method_listbysubscription.go b/resource-manager/azurefleet/2024-11-01/fleets/method_listbysubscription.go new file mode 100644 index 00000000000..ccfc60b2ec7 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package fleets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Fleet +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Fleet +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c FleetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureFleet/fleets", 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 *[]Fleet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c FleetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, FleetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FleetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FleetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Fleet, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/method_listvirtualmachinescalesets.go b/resource-manager/azurefleet/2024-11-01/fleets/method_listvirtualmachinescalesets.go new file mode 100644 index 00000000000..5e043843b9a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_listvirtualmachinescalesets.go @@ -0,0 +1,105 @@ +package fleets + +import ( + "context" + "fmt" + "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 ListVirtualMachineScaleSetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualMachineScaleSet +} + +type ListVirtualMachineScaleSetsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualMachineScaleSet +} + +type ListVirtualMachineScaleSetsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListVirtualMachineScaleSetsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListVirtualMachineScaleSets ... +func (c FleetsClient) ListVirtualMachineScaleSets(ctx context.Context, id FleetId) (result ListVirtualMachineScaleSetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListVirtualMachineScaleSetsCustomPager{}, + Path: fmt.Sprintf("%s/virtualMachineScaleSets", 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 *[]VirtualMachineScaleSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVirtualMachineScaleSetsComplete retrieves all the results into a single object +func (c FleetsClient) ListVirtualMachineScaleSetsComplete(ctx context.Context, id FleetId) (ListVirtualMachineScaleSetsCompleteResult, error) { + return c.ListVirtualMachineScaleSetsCompleteMatchingPredicate(ctx, id, VirtualMachineScaleSetOperationPredicate{}) +} + +// ListVirtualMachineScaleSetsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FleetsClient) ListVirtualMachineScaleSetsCompleteMatchingPredicate(ctx context.Context, id FleetId, predicate VirtualMachineScaleSetOperationPredicate) (result ListVirtualMachineScaleSetsCompleteResult, err error) { + items := make([]VirtualMachineScaleSet, 0) + + resp, err := c.ListVirtualMachineScaleSets(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListVirtualMachineScaleSetsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/method_update.go b/resource-manager/azurefleet/2024-11-01/fleets/method_update.go new file mode 100644 index 00000000000..718214ccc69 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/method_update.go @@ -0,0 +1,75 @@ +package fleets + +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 + Model *Fleet +} + +// Update ... +func (c FleetsClient) Update(ctx context.Context, id FleetId, input FleetUpdate) (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 FleetsClient) UpdateThenPoll(ctx context.Context, id FleetId, input FleetUpdate) 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/azurefleet/2024-11-01/fleets/model_additionalcapabilities.go b/resource-manager/azurefleet/2024-11-01/fleets/model_additionalcapabilities.go new file mode 100644 index 00000000000..aee1361afcf --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_additionalcapabilities.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdditionalCapabilities struct { + HibernationEnabled *bool `json:"hibernationEnabled,omitempty"` + UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_additionallocationsprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_additionallocationsprofile.go new file mode 100644 index 00000000000..73ee0ef7998 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_additionallocationsprofile.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdditionalLocationsProfile struct { + LocationProfiles []LocationProfile `json:"locationProfiles"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_additionalunattendcontent.go b/resource-manager/azurefleet/2024-11-01/fleets/model_additionalunattendcontent.go new file mode 100644 index 00000000000..4dbf70b589c --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_additionalunattendcontent.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdditionalUnattendContent struct { + ComponentName *ComponentName `json:"componentName,omitempty"` + Content *string `json:"content,omitempty"` + PassName *PassName `json:"passName,omitempty"` + SettingName *SettingNames `json:"settingName,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_apientityreference.go b/resource-manager/azurefleet/2024-11-01/fleets/model_apientityreference.go new file mode 100644 index 00000000000..ab0a1d78b2e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_apientityreference.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiEntityReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_apierror.go b/resource-manager/azurefleet/2024-11-01/fleets/model_apierror.go new file mode 100644 index 00000000000..a93a11873c9 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_apierror.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiError struct { + Code *string `json:"code,omitempty"` + Details *[]ApiErrorBase `json:"details,omitempty"` + Innererror *InnerError `json:"innererror,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_apierrorbase.go b/resource-manager/azurefleet/2024-11-01/fleets/model_apierrorbase.go new file mode 100644 index 00000000000..2eb7277fcf8 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_apierrorbase.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiErrorBase struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_applicationprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_applicationprofile.go new file mode 100644 index 00000000000..7fb5f0a76d5 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_applicationprofile.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationProfile struct { + GalleryApplications *[]VMGalleryApplication `json:"galleryApplications,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_basevirtualmachineprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_basevirtualmachineprofile.go new file mode 100644 index 00000000000..9af5805638e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_basevirtualmachineprofile.go @@ -0,0 +1,40 @@ +package fleets + +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 BaseVirtualMachineProfile struct { + ApplicationProfile *ApplicationProfile `json:"applicationProfile,omitempty"` + CapacityReservation *CapacityReservationProfile `json:"capacityReservation,omitempty"` + DiagnosticsProfile *DiagnosticsProfile `json:"diagnosticsProfile,omitempty"` + ExtensionProfile *VirtualMachineScaleSetExtensionProfile `json:"extensionProfile,omitempty"` + HardwareProfile *VirtualMachineScaleSetHardwareProfile `json:"hardwareProfile,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + NetworkProfile *VirtualMachineScaleSetNetworkProfile `json:"networkProfile,omitempty"` + OsProfile *VirtualMachineScaleSetOSProfile `json:"osProfile,omitempty"` + ScheduledEventsProfile *ScheduledEventsProfile `json:"scheduledEventsProfile,omitempty"` + SecurityPostureReference *SecurityPostureReference `json:"securityPostureReference,omitempty"` + SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` + ServiceArtifactReference *ServiceArtifactReference `json:"serviceArtifactReference,omitempty"` + StorageProfile *VirtualMachineScaleSetStorageProfile `json:"storageProfile,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + UserData *string `json:"userData,omitempty"` +} + +func (o *BaseVirtualMachineProfile) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *BaseVirtualMachineProfile) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_bootdiagnostics.go b/resource-manager/azurefleet/2024-11-01/fleets/model_bootdiagnostics.go new file mode 100644 index 00000000000..996a16ade1e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_bootdiagnostics.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BootDiagnostics struct { + Enabled *bool `json:"enabled,omitempty"` + StorageUri *string `json:"storageUri,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_capacityreservationprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_capacityreservationprofile.go new file mode 100644 index 00000000000..f450e66f0e4 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_capacityreservationprofile.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityReservationProfile struct { + CapacityReservationGroup *SubResource `json:"capacityReservationGroup,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_computeprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_computeprofile.go new file mode 100644 index 00000000000..196e09e448f --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_computeprofile.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeProfile struct { + AdditionalVirtualMachineCapabilities *AdditionalCapabilities `json:"additionalVirtualMachineCapabilities,omitempty"` + BaseVirtualMachineProfile BaseVirtualMachineProfile `json:"baseVirtualMachineProfile"` + ComputeApiVersion *string `json:"computeApiVersion,omitempty"` + PlatformFaultDomainCount *int64 `json:"platformFaultDomainCount,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_diagnosticsprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_diagnosticsprofile.go new file mode 100644 index 00000000000..65cf8501bc1 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_diagnosticsprofile.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsProfile struct { + BootDiagnostics *BootDiagnostics `json:"bootDiagnostics,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_diffdisksettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_diffdisksettings.go new file mode 100644 index 00000000000..9219602e956 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_diffdisksettings.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiffDiskSettings struct { + Option *DiffDiskOptions `json:"option,omitempty"` + Placement *DiffDiskPlacement `json:"placement,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_diskencryptionsetparameters.go b/resource-manager/azurefleet/2024-11-01/fleets/model_diskencryptionsetparameters.go new file mode 100644 index 00000000000..2dc1fa4492b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_diskencryptionsetparameters.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionSetParameters struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_encryptionidentity.go b/resource-manager/azurefleet/2024-11-01/fleets/model_encryptionidentity.go new file mode 100644 index 00000000000..a15e8cf4184 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_encryptionidentity.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionIdentity struct { + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_fleet.go b/resource-manager/azurefleet/2024-11-01/fleets/model_fleet.go new file mode 100644 index 00000000000..d61cc421b50 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_fleet.go @@ -0,0 +1,23 @@ +package fleets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Fleet struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties *FleetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_fleetproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_fleetproperties.go new file mode 100644 index 00000000000..8c473f5936c --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_fleetproperties.go @@ -0,0 +1,34 @@ +package fleets + +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 FleetProperties struct { + AdditionalLocationsProfile *AdditionalLocationsProfile `json:"additionalLocationsProfile,omitempty"` + ComputeProfile ComputeProfile `json:"computeProfile"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RegularPriorityProfile *RegularPriorityProfile `json:"regularPriorityProfile,omitempty"` + SpotPriorityProfile *SpotPriorityProfile `json:"spotPriorityProfile,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + UniqueId *string `json:"uniqueId,omitempty"` + VMAttributes *VMAttributes `json:"vmAttributes,omitempty"` + VMSizesProfile []VMSizeProfile `json:"vmSizesProfile"` +} + +func (o *FleetProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *FleetProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_fleetupdate.go b/resource-manager/azurefleet/2024-11-01/fleets/model_fleetupdate.go new file mode 100644 index 00000000000..1da51b98167 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_fleetupdate.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FleetUpdate struct { + Identity *ManagedServiceIdentityUpdate `json:"identity,omitempty"` + Plan *ResourcePlanUpdate `json:"plan,omitempty"` + Properties *FleetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_imagereference.go b/resource-manager/azurefleet/2024-11-01/fleets/model_imagereference.go new file mode 100644 index 00000000000..c67656bf0ce --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_imagereference.go @@ -0,0 +1,15 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageReference struct { + CommunityGalleryImageId *string `json:"communityGalleryImageId,omitempty"` + ExactVersion *string `json:"exactVersion,omitempty"` + Id *string `json:"id,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + SharedGalleryImageId *string `json:"sharedGalleryImageId,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_innererror.go b/resource-manager/azurefleet/2024-11-01/fleets/model_innererror.go new file mode 100644 index 00000000000..9a0ac49f18d --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_innererror.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + ErrorDetail *string `json:"errorDetail,omitempty"` + ExceptionType *string `json:"exceptionType,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_keyvaultsecretreference.go b/resource-manager/azurefleet/2024-11-01/fleets/model_keyvaultsecretreference.go new file mode 100644 index 00000000000..684b0486642 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_keyvaultsecretreference.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultSecretReference struct { + SecretURL string `json:"secretUrl"` + SourceVault SubResource `json:"sourceVault"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_linuxconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxconfiguration.go new file mode 100644 index 00000000000..56deaf78e9d --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxconfiguration.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxConfiguration struct { + DisablePasswordAuthentication *bool `json:"disablePasswordAuthentication,omitempty"` + EnableVMAgentPlatformUpdates *bool `json:"enableVMAgentPlatformUpdates,omitempty"` + PatchSettings *LinuxPatchSettings `json:"patchSettings,omitempty"` + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + Ssh *SshConfiguration `json:"ssh,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_linuxpatchsettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxpatchsettings.go new file mode 100644 index 00000000000..718c23e2a8b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxpatchsettings.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxPatchSettings struct { + AssessmentMode *LinuxPatchAssessmentMode `json:"assessmentMode,omitempty"` + AutomaticByPlatformSettings *LinuxVMGuestPatchAutomaticByPlatformSettings `json:"automaticByPlatformSettings,omitempty"` + PatchMode *LinuxVMGuestPatchMode `json:"patchMode,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_linuxvmguestpatchautomaticbyplatformsettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxvmguestpatchautomaticbyplatformsettings.go new file mode 100644 index 00000000000..10b840d5bfa --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_linuxvmguestpatchautomaticbyplatformsettings.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxVMGuestPatchAutomaticByPlatformSettings struct { + BypassPlatformSafetyChecksOnUserSchedule *bool `json:"bypassPlatformSafetyChecksOnUserSchedule,omitempty"` + RebootSetting *LinuxVMGuestPatchAutomaticByPlatformRebootSetting `json:"rebootSetting,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_locationprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_locationprofile.go new file mode 100644 index 00000000000..d3eefbe05b3 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_locationprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationProfile struct { + Location string `json:"location"` + VirtualMachineProfileOverride *BaseVirtualMachineProfile `json:"virtualMachineProfileOverride,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_managedserviceidentityupdate.go b/resource-manager/azurefleet/2024-11-01/fleets/model_managedserviceidentityupdate.go new file mode 100644 index 00000000000..719bba30d96 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_managedserviceidentityupdate.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedServiceIdentityUpdate struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` + UserAssignedIdentities *map[string]UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_osimagenotificationprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_osimagenotificationprofile.go new file mode 100644 index 00000000000..5e8cb60dee3 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_osimagenotificationprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSImageNotificationProfile struct { + Enable *bool `json:"enable,omitempty"` + NotBeforeTimeout *string `json:"notBeforeTimeout,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_patchsettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_patchsettings.go new file mode 100644 index 00000000000..14c8c88e1d0 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_patchsettings.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchSettings struct { + AssessmentMode *WindowsPatchAssessmentMode `json:"assessmentMode,omitempty"` + AutomaticByPlatformSettings *WindowsVMGuestPatchAutomaticByPlatformSettings `json:"automaticByPlatformSettings,omitempty"` + EnableHotpatching *bool `json:"enableHotpatching,omitempty"` + PatchMode *WindowsVMGuestPatchMode `json:"patchMode,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_plan.go b/resource-manager/azurefleet/2024-11-01/fleets/model_plan.go new file mode 100644 index 00000000000..5f7e1d4e743 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_plan.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_proxyagentsettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_proxyagentsettings.go new file mode 100644 index 00000000000..95f7078adfc --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_proxyagentsettings.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProxyAgentSettings struct { + Enabled *bool `json:"enabled,omitempty"` + KeyIncarnationId *int64 `json:"keyIncarnationId,omitempty"` + Mode *Mode `json:"mode,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_publicipaddresssku.go b/resource-manager/azurefleet/2024-11-01/fleets/model_publicipaddresssku.go new file mode 100644 index 00000000000..dd4a6eb1ea5 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_regularpriorityprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_regularpriorityprofile.go new file mode 100644 index 00000000000..b7e60460b86 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_regularpriorityprofile.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegularPriorityProfile struct { + AllocationStrategy *RegularPriorityAllocationStrategy `json:"allocationStrategy,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_resourceplanupdate.go b/resource-manager/azurefleet/2024-11-01/fleets/model_resourceplanupdate.go new file mode 100644 index 00000000000..ba98f103d4a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_resourceplanupdate.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcePlanUpdate struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_scheduledeventsprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_scheduledeventsprofile.go new file mode 100644 index 00000000000..962b353efd2 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_scheduledeventsprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledEventsProfile struct { + OsImageNotificationProfile *OSImageNotificationProfile `json:"osImageNotificationProfile,omitempty"` + TerminateNotificationProfile *TerminateNotificationProfile `json:"terminateNotificationProfile,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_securityposturereference.go b/resource-manager/azurefleet/2024-11-01/fleets/model_securityposturereference.go new file mode 100644 index 00000000000..baa61cd1807 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_securityposturereference.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPostureReference struct { + ExcludeExtensions *[]string `json:"excludeExtensions,omitempty"` + Id *string `json:"id,omitempty"` + IsOverridable *bool `json:"isOverridable,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_securityprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_securityprofile.go new file mode 100644 index 00000000000..91e44a21e29 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_securityprofile.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityProfile struct { + EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"` + EncryptionIdentity *EncryptionIdentity `json:"encryptionIdentity,omitempty"` + ProxyAgentSettings *ProxyAgentSettings `json:"proxyAgentSettings,omitempty"` + SecurityType *SecurityTypes `json:"securityType,omitempty"` + UefiSettings *UefiSettings `json:"uefiSettings,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_serviceartifactreference.go b/resource-manager/azurefleet/2024-11-01/fleets/model_serviceartifactreference.go new file mode 100644 index 00000000000..b49e9629b4b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_serviceartifactreference.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceArtifactReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_spotpriorityprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_spotpriorityprofile.go new file mode 100644 index 00000000000..f85f4dde4d1 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_spotpriorityprofile.go @@ -0,0 +1,13 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SpotPriorityProfile struct { + AllocationStrategy *SpotAllocationStrategy `json:"allocationStrategy,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + EvictionPolicy *EvictionPolicy `json:"evictionPolicy,omitempty"` + Maintain *bool `json:"maintain,omitempty"` + MaxPricePerVM *float64 `json:"maxPricePerVM,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_sshconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_sshconfiguration.go new file mode 100644 index 00000000000..2a22e28e3a2 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_sshconfiguration.go @@ -0,0 +1,8 @@ +package fleets + +// 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/azurefleet/2024-11-01/fleets/model_sshpublickey.go b/resource-manager/azurefleet/2024-11-01/fleets/model_sshpublickey.go new file mode 100644 index 00000000000..44a2fb49cab --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_sshpublickey.go @@ -0,0 +1,9 @@ +package fleets + +// 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/azurefleet/2024-11-01/fleets/model_subresource.go b/resource-manager/azurefleet/2024-11-01/fleets/model_subresource.go new file mode 100644 index 00000000000..56bd148f427 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_subresource.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_terminatenotificationprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_terminatenotificationprofile.go new file mode 100644 index 00000000000..135150fc173 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_terminatenotificationprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TerminateNotificationProfile struct { + Enable *bool `json:"enable,omitempty"` + NotBeforeTimeout *string `json:"notBeforeTimeout,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_uefisettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_uefisettings.go new file mode 100644 index 00000000000..c2a7cf858c3 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_uefisettings.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UefiSettings struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + VTpmEnabled *bool `json:"vTpmEnabled,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_userassignedidentity.go b/resource-manager/azurefleet/2024-11-01/fleets/model_userassignedidentity.go new file mode 100644 index 00000000000..a9ceb2d827e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_userassignedidentity.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vaultcertificate.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vaultcertificate.go new file mode 100644 index 00000000000..0cfabd0a8cc --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vaultcertificate.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultCertificate struct { + CertificateStore *string `json:"certificateStore,omitempty"` + CertificateURL *string `json:"certificateUrl,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vaultsecretgroup.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vaultsecretgroup.go new file mode 100644 index 00000000000..0c77cbe3366 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vaultsecretgroup.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSecretGroup struct { + SourceVault *SubResource `json:"sourceVault,omitempty"` + VaultCertificates *[]VaultCertificate `json:"vaultCertificates,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualharddisk.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualharddisk.go new file mode 100644 index 00000000000..377f8c771da --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualharddisk.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDisk struct { + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescaleset.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescaleset.go new file mode 100644 index 00000000000..a2cd9025d1a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescaleset.go @@ -0,0 +1,12 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSet struct { + Error *ApiError `json:"error,omitempty"` + Id string `json:"id"` + Name string `json:"name"` + OperationStatus ProvisioningState `json:"operationStatus"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetdatadisk.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetdatadisk.go new file mode 100644 index 00000000000..57a2c2be1dd --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetdatadisk.go @@ -0,0 +1,17 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetDataDisk struct { + Caching *CachingTypes `json:"caching,omitempty"` + CreateOption DiskCreateOptionTypes `json:"createOption"` + DeleteOption *DiskDeleteOptionTypes `json:"deleteOption,omitempty"` + DiskIOPSReadWrite *int64 `json:"diskIOPSReadWrite,omitempty"` + DiskMBpsReadWrite *int64 `json:"diskMBpsReadWrite,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Lun int64 `json:"lun"` + ManagedDisk *VirtualMachineScaleSetManagedDiskParameters `json:"managedDisk,omitempty"` + Name *string `json:"name,omitempty"` + WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextension.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextension.go new file mode 100644 index 00000000000..1da320c3231 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextension.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetExtension struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualMachineScaleSetExtensionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionprofile.go new file mode 100644 index 00000000000..2f7a0f4306b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetExtensionProfile struct { + Extensions *[]VirtualMachineScaleSetExtension `json:"extensions,omitempty"` + ExtensionsTimeBudget *string `json:"extensionsTimeBudget,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionproperties.go new file mode 100644 index 00000000000..5261f1d1b5a --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetextensionproperties.go @@ -0,0 +1,19 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetExtensionProperties struct { + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"` + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + ProtectedSettings *map[string]interface{} `json:"protectedSettings,omitempty"` + ProtectedSettingsFromKeyVault *KeyVaultSecretReference `json:"protectedSettingsFromKeyVault,omitempty"` + ProvisionAfterExtensions *[]string `json:"provisionAfterExtensions,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + SuppressFailures *bool `json:"suppressFailures,omitempty"` + Type *string `json:"type,omitempty"` + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesethardwareprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesethardwareprofile.go new file mode 100644 index 00000000000..43769c31c4e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesethardwareprofile.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetHardwareProfile struct { + VMSizeProperties *VMSizeProperties `json:"vmSizeProperties,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfiguration.go new file mode 100644 index 00000000000..890a2f8150b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfiguration.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetIPConfiguration struct { + Name string `json:"name"` + Properties *VirtualMachineScaleSetIPConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfigurationproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfigurationproperties.go new file mode 100644 index 00000000000..eb0dd864621 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetipconfigurationproperties.go @@ -0,0 +1,15 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetIPConfigurationProperties struct { + ApplicationGatewayBackendAddressPools *[]SubResource `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]SubResource `json:"applicationSecurityGroups,omitempty"` + LoadBalancerBackendAddressPools *[]SubResource `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatPools *[]SubResource `json:"loadBalancerInboundNatPools,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PublicIPAddressConfiguration *VirtualMachineScaleSetPublicIPAddressConfiguration `json:"publicIPAddressConfiguration,omitempty"` + Subnet *ApiEntityReference `json:"subnet,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetiptag.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetiptag.go new file mode 100644 index 00000000000..d33842afe8e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetiptag.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetIPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetmanageddiskparameters.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetmanageddiskparameters.go new file mode 100644 index 00000000000..3c3b31b0152 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetmanageddiskparameters.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetManagedDiskParameters struct { + DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"` + SecurityProfile *VMDiskSecurityProfile `json:"securityProfile,omitempty"` + StorageAccountType *StorageAccountTypes `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfiguration.go new file mode 100644 index 00000000000..bb94e01cc6d --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfiguration.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetNetworkConfiguration struct { + Name string `json:"name"` + Properties *VirtualMachineScaleSetNetworkConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationdnssettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationdnssettings.go new file mode 100644 index 00000000000..6fd867af2be --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationdnssettings.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetNetworkConfigurationDnsSettings struct { + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationproperties.go new file mode 100644 index 00000000000..e73eca06b6b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkconfigurationproperties.go @@ -0,0 +1,18 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetNetworkConfigurationProperties struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *VirtualMachineScaleSetNetworkConfigurationDnsSettings `json:"dnsSettings,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableFpga *bool `json:"enableFpga,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + IPConfigurations []VirtualMachineScaleSetIPConfiguration `json:"ipConfigurations"` + NetworkSecurityGroup *SubResource `json:"networkSecurityGroup,omitempty"` + Primary *bool `json:"primary,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkprofile.go new file mode 100644 index 00000000000..e0a0045cf80 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetnetworkprofile.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetNetworkProfile struct { + HealthProbe *ApiEntityReference `json:"healthProbe,omitempty"` + NetworkApiVersion *NetworkApiVersion `json:"networkApiVersion,omitempty"` + NetworkInterfaceConfigurations *[]VirtualMachineScaleSetNetworkConfiguration `json:"networkInterfaceConfigurations,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosdisk.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosdisk.go new file mode 100644 index 00000000000..8c08084f004 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosdisk.go @@ -0,0 +1,18 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetOSDisk struct { + Caching *CachingTypes `json:"caching,omitempty"` + CreateOption DiskCreateOptionTypes `json:"createOption"` + DeleteOption *DiskDeleteOptionTypes `json:"deleteOption,omitempty"` + DiffDiskSettings *DiffDiskSettings `json:"diffDiskSettings,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Image *VirtualHardDisk `json:"image,omitempty"` + ManagedDisk *VirtualMachineScaleSetManagedDiskParameters `json:"managedDisk,omitempty"` + Name *string `json:"name,omitempty"` + OsType *OperatingSystemTypes `json:"osType,omitempty"` + VhdContainers *[]string `json:"vhdContainers,omitempty"` + WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosprofile.go new file mode 100644 index 00000000000..7f4e67b43ec --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetosprofile.go @@ -0,0 +1,16 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetOSProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + AllowExtensionOperations *bool `json:"allowExtensionOperations,omitempty"` + ComputerNamePrefix *string `json:"computerNamePrefix,omitempty"` + CustomData *string `json:"customData,omitempty"` + LinuxConfiguration *LinuxConfiguration `json:"linuxConfiguration,omitempty"` + RequireGuestProvisionSignal *bool `json:"requireGuestProvisionSignal,omitempty"` + Secrets *[]VaultSecretGroup `json:"secrets,omitempty"` + WindowsConfiguration *WindowsConfiguration `json:"windowsConfiguration,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfiguration.go new file mode 100644 index 00000000000..cc74bad9d0e --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfiguration.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetPublicIPAddressConfiguration struct { + Name string `json:"name"` + Properties *VirtualMachineScaleSetPublicIPAddressConfigurationProperties `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationdnssettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationdnssettings.go new file mode 100644 index 00000000000..a8c18f2c5b4 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationdnssettings.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings struct { + DomainNameLabel string `json:"domainNameLabel"` + DomainNameLabelScope *DomainNameLabelScopeTypes `json:"domainNameLabelScope,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationproperties.go new file mode 100644 index 00000000000..11faa5ab093 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetpublicipaddressconfigurationproperties.go @@ -0,0 +1,13 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetPublicIPAddressConfigurationProperties struct { + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings `json:"dnsSettings,omitempty"` + IPTags *[]VirtualMachineScaleSetIPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetstorageprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetstorageprofile.go new file mode 100644 index 00000000000..4a8d9f184ca --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_virtualmachinescalesetstorageprofile.go @@ -0,0 +1,11 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineScaleSetStorageProfile struct { + DataDisks *[]VirtualMachineScaleSetDataDisk `json:"dataDisks,omitempty"` + DiskControllerType *DiskControllerTypes `json:"diskControllerType,omitempty"` + ImageReference *ImageReference `json:"imageReference,omitempty"` + OsDisk *VirtualMachineScaleSetOSDisk `json:"osDisk,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxdouble.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxdouble.go new file mode 100644 index 00000000000..978aa4a3b9c --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxdouble.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMAttributeMinMaxDouble struct { + Max *float64 `json:"max,omitempty"` + Min *float64 `json:"min,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxinteger.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxinteger.go new file mode 100644 index 00000000000..7ce95208fb3 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributeminmaxinteger.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMAttributeMinMaxInteger struct { + Max *int64 `json:"max,omitempty"` + Min *int64 `json:"min,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributes.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributes.go new file mode 100644 index 00000000000..734e5277880 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmattributes.go @@ -0,0 +1,27 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMAttributes struct { + AcceleratorCount *VMAttributeMinMaxInteger `json:"acceleratorCount,omitempty"` + AcceleratorManufacturers *[]AcceleratorManufacturer `json:"acceleratorManufacturers,omitempty"` + AcceleratorSupport *VMAttributeSupport `json:"acceleratorSupport,omitempty"` + AcceleratorTypes *[]AcceleratorType `json:"acceleratorTypes,omitempty"` + ArchitectureTypes *[]ArchitectureType `json:"architectureTypes,omitempty"` + BurstableSupport *VMAttributeSupport `json:"burstableSupport,omitempty"` + CpuManufacturers *[]CPUManufacturer `json:"cpuManufacturers,omitempty"` + DataDiskCount *VMAttributeMinMaxInteger `json:"dataDiskCount,omitempty"` + ExcludedVMSizes *[]string `json:"excludedVMSizes,omitempty"` + LocalStorageDiskTypes *[]LocalStorageDiskType `json:"localStorageDiskTypes,omitempty"` + LocalStorageInGiB *VMAttributeMinMaxDouble `json:"localStorageInGiB,omitempty"` + LocalStorageSupport *VMAttributeSupport `json:"localStorageSupport,omitempty"` + MemoryInGiB VMAttributeMinMaxDouble `json:"memoryInGiB"` + MemoryInGiBPerVCPU *VMAttributeMinMaxDouble `json:"memoryInGiBPerVCpu,omitempty"` + NetworkBandwidthInMbps *VMAttributeMinMaxDouble `json:"networkBandwidthInMbps,omitempty"` + NetworkInterfaceCount *VMAttributeMinMaxInteger `json:"networkInterfaceCount,omitempty"` + RdmaNetworkInterfaceCount *VMAttributeMinMaxInteger `json:"rdmaNetworkInterfaceCount,omitempty"` + RdmaSupport *VMAttributeSupport `json:"rdmaSupport,omitempty"` + VCPUCount VMAttributeMinMaxInteger `json:"vCpuCount"` + VMCategories *[]VMCategory `json:"vmCategories,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmdisksecurityprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmdisksecurityprofile.go new file mode 100644 index 00000000000..8ad4bea61be --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmdisksecurityprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMDiskSecurityProfile struct { + DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"` + SecurityEncryptionType *SecurityEncryptionTypes `json:"securityEncryptionType,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmgalleryapplication.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmgalleryapplication.go new file mode 100644 index 00000000000..14410c448f8 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmgalleryapplication.go @@ -0,0 +1,13 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMGalleryApplication struct { + ConfigurationReference *string `json:"configurationReference,omitempty"` + EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"` + Order *int64 `json:"order,omitempty"` + PackageReferenceId string `json:"packageReferenceId"` + Tags *string `json:"tags,omitempty"` + TreatFailureAsDeploymentFailure *bool `json:"treatFailureAsDeploymentFailure,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeprofile.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeprofile.go new file mode 100644 index 00000000000..ff86647b686 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeprofile.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSizeProfile struct { + Name string `json:"name"` + Rank *int64 `json:"rank,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeproperties.go b/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeproperties.go new file mode 100644 index 00000000000..59621f57f75 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_vmsizeproperties.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSizeProperties struct { + VCPUsAvailable *int64 `json:"vCPUsAvailable,omitempty"` + VCPUsPerCore *int64 `json:"vCPUsPerCore,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_windowsconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_windowsconfiguration.go new file mode 100644 index 00000000000..74d866389bf --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_windowsconfiguration.go @@ -0,0 +1,14 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsConfiguration struct { + AdditionalUnattendContent *[]AdditionalUnattendContent `json:"additionalUnattendContent,omitempty"` + EnableAutomaticUpdates *bool `json:"enableAutomaticUpdates,omitempty"` + EnableVMAgentPlatformUpdates *bool `json:"enableVMAgentPlatformUpdates,omitempty"` + PatchSettings *PatchSettings `json:"patchSettings,omitempty"` + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + WinRM *WinRMConfiguration `json:"winRM,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_windowsvmguestpatchautomaticbyplatformsettings.go b/resource-manager/azurefleet/2024-11-01/fleets/model_windowsvmguestpatchautomaticbyplatformsettings.go new file mode 100644 index 00000000000..60f79c4e492 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_windowsvmguestpatchautomaticbyplatformsettings.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsVMGuestPatchAutomaticByPlatformSettings struct { + BypassPlatformSafetyChecksOnUserSchedule *bool `json:"bypassPlatformSafetyChecksOnUserSchedule,omitempty"` + RebootSetting *WindowsVMGuestPatchAutomaticByPlatformRebootSetting `json:"rebootSetting,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_winrmconfiguration.go b/resource-manager/azurefleet/2024-11-01/fleets/model_winrmconfiguration.go new file mode 100644 index 00000000000..3e0154b4b3b --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_winrmconfiguration.go @@ -0,0 +1,8 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WinRMConfiguration struct { + Listeners *[]WinRMListener `json:"listeners,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/model_winrmlistener.go b/resource-manager/azurefleet/2024-11-01/fleets/model_winrmlistener.go new file mode 100644 index 00000000000..67a7c3aa0da --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/model_winrmlistener.go @@ -0,0 +1,9 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WinRMListener struct { + CertificateURL *string `json:"certificateUrl,omitempty"` + Protocol *ProtocolTypes `json:"protocol,omitempty"` +} diff --git a/resource-manager/azurefleet/2024-11-01/fleets/predicates.go b/resource-manager/azurefleet/2024-11-01/fleets/predicates.go new file mode 100644 index 00000000000..2cf769e96ae --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/predicates.go @@ -0,0 +1,55 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FleetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FleetOperationPredicate) Matches(input Fleet) 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 +} + +type VirtualMachineScaleSetOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p VirtualMachineScaleSetOperationPredicate) Matches(input VirtualMachineScaleSet) bool { + + if p.Id != nil && *p.Id != input.Id { + return false + } + + if p.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/azurefleet/2024-11-01/fleets/version.go b/resource-manager/azurefleet/2024-11-01/fleets/version.go new file mode 100644 index 00000000000..554a3ac9b69 --- /dev/null +++ b/resource-manager/azurefleet/2024-11-01/fleets/version.go @@ -0,0 +1,10 @@ +package fleets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/fleets/2024-11-01" +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/README.md b/resource-manager/cdn/2024-09-01/afdcustomdomains/README.md new file mode 100644 index 00000000000..61d9b5b2371 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdcustomdomains` Documentation + +The `afdcustomdomains` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/afdcustomdomains" +``` + + +### Client Initialization + +```go +client := afdcustomdomains.NewAFDCustomDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AFDCustomDomainsClient.Create` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + +payload := afdcustomdomains.AFDDomain{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDCustomDomainsClient.Delete` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDCustomDomainsClient.Get` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + +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: `AFDCustomDomainsClient.ListByProfile` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDCustomDomainsClient.RefreshValidationToken` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + +if err := client.RefreshValidationTokenThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDCustomDomainsClient.Update` + +```go +ctx := context.TODO() +id := afdcustomdomains.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + +payload := afdcustomdomains.AFDDomainUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/client.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/client.go new file mode 100644 index 00000000000..c5d7647815e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/client.go @@ -0,0 +1,26 @@ +package afdcustomdomains + +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 AFDCustomDomainsClient struct { + Client *resourcemanager.Client +} + +func NewAFDCustomDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*AFDCustomDomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "afdcustomdomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AFDCustomDomainsClient: %+v", err) + } + + return &AFDCustomDomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/constants.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/constants.go new file mode 100644 index 00000000000..c0d8c92ef84 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/constants.go @@ -0,0 +1,254 @@ +package afdcustomdomains + +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 AfdCertificateType string + +const ( + AfdCertificateTypeAzureFirstPartyManagedCertificate AfdCertificateType = "AzureFirstPartyManagedCertificate" + AfdCertificateTypeCustomerCertificate AfdCertificateType = "CustomerCertificate" + AfdCertificateTypeManagedCertificate AfdCertificateType = "ManagedCertificate" +) + +func PossibleValuesForAfdCertificateType() []string { + return []string{ + string(AfdCertificateTypeAzureFirstPartyManagedCertificate), + string(AfdCertificateTypeCustomerCertificate), + string(AfdCertificateTypeManagedCertificate), + } +} + +func (s *AfdCertificateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdCertificateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdCertificateType(input string) (*AfdCertificateType, error) { + vals := map[string]AfdCertificateType{ + "azurefirstpartymanagedcertificate": AfdCertificateTypeAzureFirstPartyManagedCertificate, + "customercertificate": AfdCertificateTypeCustomerCertificate, + "managedcertificate": AfdCertificateTypeManagedCertificate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdCertificateType(input) + return &out, nil +} + +type AfdMinimumTlsVersion string + +const ( + AfdMinimumTlsVersionTLSOneTwo AfdMinimumTlsVersion = "TLS12" + AfdMinimumTlsVersionTLSOneZero AfdMinimumTlsVersion = "TLS10" +) + +func PossibleValuesForAfdMinimumTlsVersion() []string { + return []string{ + string(AfdMinimumTlsVersionTLSOneTwo), + string(AfdMinimumTlsVersionTLSOneZero), + } +} + +func (s *AfdMinimumTlsVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdMinimumTlsVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdMinimumTlsVersion(input string) (*AfdMinimumTlsVersion, error) { + vals := map[string]AfdMinimumTlsVersion{ + "tls12": AfdMinimumTlsVersionTLSOneTwo, + "tls10": AfdMinimumTlsVersionTLSOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdMinimumTlsVersion(input) + return &out, nil +} + +type AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type DomainValidationState string + +const ( + DomainValidationStateApproved DomainValidationState = "Approved" + DomainValidationStateInternalError DomainValidationState = "InternalError" + DomainValidationStatePending DomainValidationState = "Pending" + DomainValidationStatePendingRevalidation DomainValidationState = "PendingRevalidation" + DomainValidationStateRefreshingValidationToken DomainValidationState = "RefreshingValidationToken" + DomainValidationStateRejected DomainValidationState = "Rejected" + DomainValidationStateSubmitting DomainValidationState = "Submitting" + DomainValidationStateTimedOut DomainValidationState = "TimedOut" + DomainValidationStateUnknown DomainValidationState = "Unknown" +) + +func PossibleValuesForDomainValidationState() []string { + return []string{ + string(DomainValidationStateApproved), + string(DomainValidationStateInternalError), + string(DomainValidationStatePending), + string(DomainValidationStatePendingRevalidation), + string(DomainValidationStateRefreshingValidationToken), + string(DomainValidationStateRejected), + string(DomainValidationStateSubmitting), + string(DomainValidationStateTimedOut), + string(DomainValidationStateUnknown), + } +} + +func (s *DomainValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainValidationState(input string) (*DomainValidationState, error) { + vals := map[string]DomainValidationState{ + "approved": DomainValidationStateApproved, + "internalerror": DomainValidationStateInternalError, + "pending": DomainValidationStatePending, + "pendingrevalidation": DomainValidationStatePendingRevalidation, + "refreshingvalidationtoken": DomainValidationStateRefreshingValidationToken, + "rejected": DomainValidationStateRejected, + "submitting": DomainValidationStateSubmitting, + "timedout": DomainValidationStateTimedOut, + "unknown": DomainValidationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainValidationState(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain.go new file mode 100644 index 00000000000..657d3ea7184 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain.go @@ -0,0 +1,139 @@ +package afdcustomdomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, profileName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(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 := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainName"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain_test.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain_test.go new file mode 100644 index 00000000000..c87c7f48dbd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_customdomain_test.go @@ -0,0 +1,327 @@ +package afdcustomdomains + +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 = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.CustomDomainName != "customDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainName") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "customDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains/customDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains/customDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/customDomains/customDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/cUsToMdOmAiNs/cUsToMdOmAiNnAmE", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + CustomDomainName: "cUsToMdOmAiNnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/cUsToMdOmAiNs/cUsToMdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId 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/cdn/2024-09-01/afdcustomdomains/id_profile.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_profile.go new file mode 100644 index 00000000000..80949c3a24a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_profile.go @@ -0,0 +1,130 @@ +package afdcustomdomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/id_profile_test.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_profile_test.go new file mode 100644 index 00000000000..f17b9c71a3a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/id_profile_test.go @@ -0,0 +1,282 @@ +package afdcustomdomains + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/afdcustomdomains/method_create.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_create.go new file mode 100644 index 00000000000..ae549ab66f3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_create.go @@ -0,0 +1,76 @@ +package afdcustomdomains + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AFDDomain +} + +// Create ... +func (c AFDCustomDomainsClient) Create(ctx context.Context, id CustomDomainId, input AFDDomain) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c AFDCustomDomainsClient) CreateThenPoll(ctx context.Context, id CustomDomainId, input AFDDomain) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/method_delete.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_delete.go new file mode 100644 index 00000000000..0bc3be82915 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_delete.go @@ -0,0 +1,71 @@ +package afdcustomdomains + +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 AFDCustomDomainsClient) Delete(ctx context.Context, id CustomDomainId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AFDCustomDomainsClient) DeleteThenPoll(ctx context.Context, id CustomDomainId) 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/cdn/2024-09-01/afdcustomdomains/method_get.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_get.go new file mode 100644 index 00000000000..d3a04f74127 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_get.go @@ -0,0 +1,53 @@ +package afdcustomdomains + +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 *AFDDomain +} + +// Get ... +func (c AFDCustomDomainsClient) Get(ctx context.Context, id CustomDomainId) (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 + } + + var model AFDDomain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_listbyprofile.go new file mode 100644 index 00000000000..3519a246ca5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_listbyprofile.go @@ -0,0 +1,105 @@ +package afdcustomdomains + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AFDDomain +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []AFDDomain +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c AFDCustomDomainsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/customDomains", 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 *[]AFDDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c AFDCustomDomainsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, AFDDomainOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDCustomDomainsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate AFDDomainOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]AFDDomain, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/method_refreshvalidationtoken.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_refreshvalidationtoken.go new file mode 100644 index 00000000000..e6247385e47 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_refreshvalidationtoken.go @@ -0,0 +1,70 @@ +package afdcustomdomains + +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 RefreshValidationTokenOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RefreshValidationToken ... +func (c AFDCustomDomainsClient) RefreshValidationToken(ctx context.Context, id CustomDomainId) (result RefreshValidationTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshValidationToken", 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 +} + +// RefreshValidationTokenThenPoll performs RefreshValidationToken then polls until it's completed +func (c AFDCustomDomainsClient) RefreshValidationTokenThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.RefreshValidationToken(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshValidationToken: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshValidationToken: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/method_update.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_update.go new file mode 100644 index 00000000000..b2841d6e1c0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/method_update.go @@ -0,0 +1,75 @@ +package afdcustomdomains + +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 + Model *AFDDomain +} + +// Update ... +func (c AFDCustomDomainsClient) Update(ctx context.Context, id CustomDomainId, input AFDDomainUpdateParameters) (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 AFDCustomDomainsClient) UpdateThenPoll(ctx context.Context, id CustomDomainId, input AFDDomainUpdateParameters) 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/cdn/2024-09-01/afdcustomdomains/model_afddomain.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomain.go new file mode 100644 index 00000000000..05cb918cf11 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomain.go @@ -0,0 +1,16 @@ +package afdcustomdomains + +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 AFDDomain struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AFDDomainProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainhttpsparameters.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainhttpsparameters.go new file mode 100644 index 00000000000..e05940ce72e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainhttpsparameters.go @@ -0,0 +1,10 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDDomainHTTPSParameters struct { + CertificateType AfdCertificateType `json:"certificateType"` + MinimumTlsVersion *AfdMinimumTlsVersion `json:"minimumTlsVersion,omitempty"` + Secret *ResourceReference `json:"secret,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainproperties.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainproperties.go new file mode 100644 index 00000000000..b6cd1d3ab9f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainproperties.go @@ -0,0 +1,17 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDDomainProperties struct { + AzureDnsZone *ResourceReference `json:"azureDnsZone,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + DomainValidationState *DomainValidationState `json:"domainValidationState,omitempty"` + ExtendedProperties *map[string]string `json:"extendedProperties,omitempty"` + HostName string `json:"hostName"` + PreValidatedCustomDomainResourceId *ResourceReference `json:"preValidatedCustomDomainResourceId,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + TlsSettings *AFDDomainHTTPSParameters `json:"tlsSettings,omitempty"` + ValidationProperties *DomainValidationProperties `json:"validationProperties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdateparameters.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdateparameters.go new file mode 100644 index 00000000000..47b41476862 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdateparameters.go @@ -0,0 +1,8 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDDomainUpdateParameters struct { + Properties *AFDDomainUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdatepropertiesparameters.go new file mode 100644 index 00000000000..031b13ae2f7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_afddomainupdatepropertiesparameters.go @@ -0,0 +1,11 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDDomainUpdatePropertiesParameters struct { + AzureDnsZone *ResourceReference `json:"azureDnsZone,omitempty"` + PreValidatedCustomDomainResourceId *ResourceReference `json:"preValidatedCustomDomainResourceId,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + TlsSettings *AFDDomainHTTPSParameters `json:"tlsSettings,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_domainvalidationproperties.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_domainvalidationproperties.go new file mode 100644 index 00000000000..7a0f09cd6af --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_domainvalidationproperties.go @@ -0,0 +1,9 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainValidationProperties struct { + ExpirationDate *string `json:"expirationDate,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/model_resourcereference.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_resourcereference.go new file mode 100644 index 00000000000..be573730686 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/model_resourcereference.go @@ -0,0 +1,8 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdcustomdomains/predicates.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/predicates.go new file mode 100644 index 00000000000..91e0235faea --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/predicates.go @@ -0,0 +1,27 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDDomainOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AFDDomainOperationPredicate) Matches(input AFDDomain) 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/cdn/2024-09-01/afdcustomdomains/version.go b/resource-manager/cdn/2024-09-01/afdcustomdomains/version.go new file mode 100644 index 00000000000..8a140aa8882 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdcustomdomains/version.go @@ -0,0 +1,10 @@ +package afdcustomdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/afdcustomdomains/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/README.md b/resource-manager/cdn/2024-09-01/afdendpoints/README.md new file mode 100644 index 00000000000..3a646e7befa --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/README.md @@ -0,0 +1,154 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdendpoints` Documentation + +The `afdendpoints` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/afdendpoints" +``` + + +### Client Initialization + +```go +client := afdendpoints.NewAFDEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AFDEndpointsClient.Create` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +payload := afdendpoints.AFDEndpoint{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDEndpointsClient.Delete` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDEndpointsClient.Get` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +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: `AFDEndpointsClient.ListByProfile` + +```go +ctx := context.TODO() +id := afdendpoints.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDEndpointsClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDEndpointsClient.PurgeContent` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +payload := afdendpoints.AfdPurgeParameters{ + // ... +} + + +if err := client.PurgeContentThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDEndpointsClient.Update` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +payload := afdendpoints.AFDEndpointUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDEndpointsClient.ValidateCustomDomain` + +```go +ctx := context.TODO() +id := afdendpoints.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +payload := afdendpoints.ValidateCustomDomainInput{ + // ... +} + + +read, err := client.ValidateCustomDomain(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/client.go b/resource-manager/cdn/2024-09-01/afdendpoints/client.go new file mode 100644 index 00000000000..bf3791c198d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/client.go @@ -0,0 +1,26 @@ +package afdendpoints + +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 AFDEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewAFDEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*AFDEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "afdendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AFDEndpointsClient: %+v", err) + } + + return &AFDEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/constants.go b/resource-manager/cdn/2024-09-01/afdendpoints/constants.go new file mode 100644 index 00000000000..870818f8770 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/constants.go @@ -0,0 +1,233 @@ +package afdendpoints + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type EnabledState string + +const ( + EnabledStateDisabled EnabledState = "Disabled" + EnabledStateEnabled EnabledState = "Enabled" +) + +func PossibleValuesForEnabledState() []string { + return []string{ + string(EnabledStateDisabled), + string(EnabledStateEnabled), + } +} + +func (s *EnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnabledState(input string) (*EnabledState, error) { + vals := map[string]EnabledState{ + "disabled": EnabledStateDisabled, + "enabled": EnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnabledState(input) + return &out, nil +} + +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint.go b/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint.go new file mode 100644 index 00000000000..7548872fa4a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint.go @@ -0,0 +1,139 @@ +package afdendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AfdEndpointId{}) +} + +var _ resourceids.ResourceId = &AfdEndpointId{} + +// AfdEndpointId is a struct representing the Resource ID for a Afd Endpoint +type AfdEndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + AfdEndpointName string +} + +// NewAfdEndpointID returns a new AfdEndpointId struct +func NewAfdEndpointID(subscriptionId string, resourceGroupName string, profileName string, afdEndpointName string) AfdEndpointId { + return AfdEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + AfdEndpointName: afdEndpointName, + } +} + +// ParseAfdEndpointID parses 'input' into a AfdEndpointId +func ParseAfdEndpointID(input string) (*AfdEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&AfdEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AfdEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAfdEndpointIDInsensitively parses 'input' case-insensitively into a AfdEndpointId +// note: this method should only be used for API response data and not user input +func ParseAfdEndpointIDInsensitively(input string) (*AfdEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&AfdEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AfdEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AfdEndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.AfdEndpointName, ok = input.Parsed["afdEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "afdEndpointName", input) + } + + return nil +} + +// ValidateAfdEndpointID checks that 'input' can be parsed as a Afd Endpoint ID +func ValidateAfdEndpointID(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 := ParseAfdEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Afd Endpoint ID +func (id AfdEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/afdEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.AfdEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Afd Endpoint ID +func (id AfdEndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticAfdEndpoints", "afdEndpoints", "afdEndpoints"), + resourceids.UserSpecifiedSegment("afdEndpointName", "afdEndpointName"), + } +} + +// String returns a human-readable description of this Afd Endpoint ID +func (id AfdEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Afd Endpoint Name: %q", id.AfdEndpointName), + } + return fmt.Sprintf("Afd Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint_test.go b/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint_test.go new file mode 100644 index 00000000000..17925820c6d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/id_afdendpoint_test.go @@ -0,0 +1,327 @@ +package afdendpoints + +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 = &AfdEndpointId{} + +func TestNewAfdEndpointID(t *testing.T) { + id := NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.AfdEndpointName != "afdEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'AfdEndpointName'", id.AfdEndpointName, "afdEndpointName") + } +} + +func TestFormatAfdEndpointID(t *testing.T) { + actual := NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAfdEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AfdEndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAfdEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + } +} + +func TestParseAfdEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AfdEndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + AfdEndpointName: "aFdEnDpOiNtNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAfdEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + } +} + +func TestSegmentsForAfdEndpointId(t *testing.T) { + segments := AfdEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AfdEndpointId 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/cdn/2024-09-01/afdendpoints/id_profile.go b/resource-manager/cdn/2024-09-01/afdendpoints/id_profile.go new file mode 100644 index 00000000000..4930a1866de --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/id_profile.go @@ -0,0 +1,130 @@ +package afdendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/id_profile_test.go b/resource-manager/cdn/2024-09-01/afdendpoints/id_profile_test.go new file mode 100644 index 00000000000..2f4a4c60def --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/id_profile_test.go @@ -0,0 +1,282 @@ +package afdendpoints + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/afdendpoints/method_create.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_create.go new file mode 100644 index 00000000000..ed1dd57cf10 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_create.go @@ -0,0 +1,76 @@ +package afdendpoints + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AFDEndpoint +} + +// Create ... +func (c AFDEndpointsClient) Create(ctx context.Context, id AfdEndpointId, input AFDEndpoint) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c AFDEndpointsClient) CreateThenPoll(ctx context.Context, id AfdEndpointId, input AFDEndpoint) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/method_delete.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_delete.go new file mode 100644 index 00000000000..008d9ba504a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_delete.go @@ -0,0 +1,71 @@ +package afdendpoints + +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 AFDEndpointsClient) Delete(ctx context.Context, id AfdEndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AFDEndpointsClient) DeleteThenPoll(ctx context.Context, id AfdEndpointId) 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/cdn/2024-09-01/afdendpoints/method_get.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_get.go new file mode 100644 index 00000000000..3f75c564bbd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_get.go @@ -0,0 +1,53 @@ +package afdendpoints + +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 *AFDEndpoint +} + +// Get ... +func (c AFDEndpointsClient) Get(ctx context.Context, id AfdEndpointId) (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 + } + + var model AFDEndpoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_listbyprofile.go new file mode 100644 index 00000000000..328db4641b9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_listbyprofile.go @@ -0,0 +1,105 @@ +package afdendpoints + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AFDEndpoint +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []AFDEndpoint +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c AFDEndpointsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/afdEndpoints", 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 *[]AFDEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c AFDEndpointsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, AFDEndpointOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDEndpointsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate AFDEndpointOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]AFDEndpoint, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_listresourceusage.go new file mode 100644 index 00000000000..9d0e7501447 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_listresourceusage.go @@ -0,0 +1,105 @@ +package afdendpoints + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c AFDEndpointsClient) ListResourceUsage(ctx context.Context, id AfdEndpointId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c AFDEndpointsClient) ListResourceUsageComplete(ctx context.Context, id AfdEndpointId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDEndpointsClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id AfdEndpointId, predicate UsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/method_purgecontent.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_purgecontent.go new file mode 100644 index 00000000000..266d22c7ea2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_purgecontent.go @@ -0,0 +1,74 @@ +package afdendpoints + +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 PurgeContentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PurgeContent ... +func (c AFDEndpointsClient) PurgeContent(ctx context.Context, id AfdEndpointId, input AfdPurgeParameters) (result PurgeContentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", 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 +} + +// PurgeContentThenPoll performs PurgeContent then polls until it's completed +func (c AFDEndpointsClient) PurgeContentThenPoll(ctx context.Context, id AfdEndpointId, input AfdPurgeParameters) error { + result, err := c.PurgeContent(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PurgeContent: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PurgeContent: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/method_update.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_update.go new file mode 100644 index 00000000000..911a2a70823 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_update.go @@ -0,0 +1,75 @@ +package afdendpoints + +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 + Model *AFDEndpoint +} + +// Update ... +func (c AFDEndpointsClient) Update(ctx context.Context, id AfdEndpointId, input AFDEndpointUpdateParameters) (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 AFDEndpointsClient) UpdateThenPoll(ctx context.Context, id AfdEndpointId, input AFDEndpointUpdateParameters) 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/cdn/2024-09-01/afdendpoints/method_validatecustomdomain.go b/resource-manager/cdn/2024-09-01/afdendpoints/method_validatecustomdomain.go new file mode 100644 index 00000000000..0ec89caf8c8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/method_validatecustomdomain.go @@ -0,0 +1,58 @@ +package afdendpoints + +import ( + "context" + "fmt" + "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 ValidateCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateCustomDomainOutput +} + +// ValidateCustomDomain ... +func (c AFDEndpointsClient) ValidateCustomDomain(ctx context.Context, id AfdEndpointId, input ValidateCustomDomainInput) (result ValidateCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateCustomDomain", 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 + } + + var model ValidateCustomDomainOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpoint.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpoint.go new file mode 100644 index 00000000000..fe851cca60c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpoint.go @@ -0,0 +1,18 @@ +package afdendpoints + +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 AFDEndpoint struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AFDEndpointProperties `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/cdn/2024-09-01/afdendpoints/model_afdendpointproperties.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointproperties.go new file mode 100644 index 00000000000..9a02413671c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointproperties.go @@ -0,0 +1,13 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDEndpointProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + EnabledState *EnabledState `json:"enabledState,omitempty"` + HostName *string `json:"hostName,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointpropertiesupdateparameters.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointpropertiesupdateparameters.go new file mode 100644 index 00000000000..8611ce0d850 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointpropertiesupdateparameters.go @@ -0,0 +1,9 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDEndpointPropertiesUpdateParameters struct { + EnabledState *EnabledState `json:"enabledState,omitempty"` + ProfileName *string `json:"profileName,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointupdateparameters.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointupdateparameters.go new file mode 100644 index 00000000000..5d6b6ab8d5b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdendpointupdateparameters.go @@ -0,0 +1,9 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDEndpointUpdateParameters struct { + Properties *AFDEndpointPropertiesUpdateParameters `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_afdpurgeparameters.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdpurgeparameters.go new file mode 100644 index 00000000000..7fa33e59b86 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_afdpurgeparameters.go @@ -0,0 +1,9 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AfdPurgeParameters struct { + ContentPaths []string `json:"contentPaths"` + Domains *[]string `json:"domains,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_usage.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_usage.go new file mode 100644 index 00000000000..e1410730af5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_usage.go @@ -0,0 +1,12 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue int64 `json:"currentValue"` + Id *string `json:"id,omitempty"` + Limit int64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_usagename.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_usagename.go new file mode 100644 index 00000000000..e00d7fba315 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_usagename.go @@ -0,0 +1,9 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomaininput.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomaininput.go new file mode 100644 index 00000000000..cdd8ec4488e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomaininput.go @@ -0,0 +1,8 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCustomDomainInput struct { + HostName string `json:"hostName"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomainoutput.go b/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomainoutput.go new file mode 100644 index 00000000000..2aedfdc5b18 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/model_validatecustomdomainoutput.go @@ -0,0 +1,10 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCustomDomainOutput struct { + CustomDomainValidated *bool `json:"customDomainValidated,omitempty"` + Message *string `json:"message,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/predicates.go b/resource-manager/cdn/2024-09-01/afdendpoints/predicates.go new file mode 100644 index 00000000000..f8a26db0ed7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/predicates.go @@ -0,0 +1,55 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDEndpointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AFDEndpointOperationPredicate) Matches(input AFDEndpoint) 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 +} + +type UsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/afdendpoints/version.go b/resource-manager/cdn/2024-09-01/afdendpoints/version.go new file mode 100644 index 00000000000..740fb26bbfd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdendpoints/version.go @@ -0,0 +1,10 @@ +package afdendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/afdendpoints/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/README.md b/resource-manager/cdn/2024-09-01/afdorigingroups/README.md new file mode 100644 index 00000000000..7139be7abe8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdorigingroups` Documentation + +The `afdorigingroups` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/afdorigingroups" +``` + + +### Client Initialization + +```go +client := afdorigingroups.NewAFDOriginGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AFDOriginGroupsClient.Create` + +```go +ctx := context.TODO() +id := afdorigingroups.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +payload := afdorigingroups.AFDOriginGroup{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDOriginGroupsClient.Delete` + +```go +ctx := context.TODO() +id := afdorigingroups.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDOriginGroupsClient.Get` + +```go +ctx := context.TODO() +id := afdorigingroups.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +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: `AFDOriginGroupsClient.ListByProfile` + +```go +ctx := context.TODO() +id := afdorigingroups.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDOriginGroupsClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := afdorigingroups.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDOriginGroupsClient.Update` + +```go +ctx := context.TODO() +id := afdorigingroups.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +payload := afdorigingroups.AFDOriginGroupUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/client.go b/resource-manager/cdn/2024-09-01/afdorigingroups/client.go new file mode 100644 index 00000000000..76e2701d5ab --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/client.go @@ -0,0 +1,26 @@ +package afdorigingroups + +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 AFDOriginGroupsClient struct { + Client *resourcemanager.Client +} + +func NewAFDOriginGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*AFDOriginGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "afdorigingroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AFDOriginGroupsClient: %+v", err) + } + + return &AFDOriginGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/constants.go b/resource-manager/cdn/2024-09-01/afdorigingroups/constants.go new file mode 100644 index 00000000000..88b86252913 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/constants.go @@ -0,0 +1,274 @@ +package afdorigingroups + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type EnabledState string + +const ( + EnabledStateDisabled EnabledState = "Disabled" + EnabledStateEnabled EnabledState = "Enabled" +) + +func PossibleValuesForEnabledState() []string { + return []string{ + string(EnabledStateDisabled), + string(EnabledStateEnabled), + } +} + +func (s *EnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnabledState(input string) (*EnabledState, error) { + vals := map[string]EnabledState{ + "disabled": EnabledStateDisabled, + "enabled": EnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnabledState(input) + return &out, nil +} + +type HealthProbeRequestType string + +const ( + HealthProbeRequestTypeGET HealthProbeRequestType = "GET" + HealthProbeRequestTypeHEAD HealthProbeRequestType = "HEAD" + HealthProbeRequestTypeNotSet HealthProbeRequestType = "NotSet" +) + +func PossibleValuesForHealthProbeRequestType() []string { + return []string{ + string(HealthProbeRequestTypeGET), + string(HealthProbeRequestTypeHEAD), + string(HealthProbeRequestTypeNotSet), + } +} + +func (s *HealthProbeRequestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthProbeRequestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthProbeRequestType(input string) (*HealthProbeRequestType, error) { + vals := map[string]HealthProbeRequestType{ + "get": HealthProbeRequestTypeGET, + "head": HealthProbeRequestTypeHEAD, + "notset": HealthProbeRequestTypeNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthProbeRequestType(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "Http" + ProbeProtocolHTTPS ProbeProtocol = "Https" + ProbeProtocolNotSet ProbeProtocol = "NotSet" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolNotSet), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "notset": ProbeProtocolNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup.go b/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup.go new file mode 100644 index 00000000000..ed40b9ec3f8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup.go @@ -0,0 +1,139 @@ +package afdorigingroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&OriginGroupId{}) +} + +var _ resourceids.ResourceId = &OriginGroupId{} + +// OriginGroupId is a struct representing the Resource ID for a Origin Group +type OriginGroupId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + OriginGroupName string +} + +// NewOriginGroupID returns a new OriginGroupId struct +func NewOriginGroupID(subscriptionId string, resourceGroupName string, profileName string, originGroupName string) OriginGroupId { + return OriginGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + OriginGroupName: originGroupName, + } +} + +// ParseOriginGroupID parses 'input' into a OriginGroupId +func ParseOriginGroupID(input string) (*OriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOriginGroupIDInsensitively parses 'input' case-insensitively into a OriginGroupId +// note: this method should only be used for API response data and not user input +func ParseOriginGroupIDInsensitively(input string) (*OriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OriginGroupId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.OriginGroupName, ok = input.Parsed["originGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originGroupName", input) + } + + return nil +} + +// ValidateOriginGroupID checks that 'input' can be parsed as a Origin Group ID +func ValidateOriginGroupID(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 := ParseOriginGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Origin Group ID +func (id OriginGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/originGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.OriginGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Origin Group ID +func (id OriginGroupId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticOriginGroups", "originGroups", "originGroups"), + resourceids.UserSpecifiedSegment("originGroupName", "originGroupName"), + } +} + +// String returns a human-readable description of this Origin Group ID +func (id OriginGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Origin Group Name: %q", id.OriginGroupName), + } + return fmt.Sprintf("Origin Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup_test.go b/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup_test.go new file mode 100644 index 00000000000..c975ee5291c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/id_origingroup_test.go @@ -0,0 +1,327 @@ +package afdorigingroups + +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 = &OriginGroupId{} + +func TestNewOriginGroupID(t *testing.T) { + id := NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.OriginGroupName != "originGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginGroupName'", id.OriginGroupName, "originGroupName") + } +} + +func TestFormatOriginGroupID(t *testing.T) { + actual := NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOriginGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestParseOriginGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + OriginGroupName: "oRiGiNgRoUpNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestSegmentsForOriginGroupId(t *testing.T) { + segments := OriginGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OriginGroupId 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/cdn/2024-09-01/afdorigingroups/id_profile.go b/resource-manager/cdn/2024-09-01/afdorigingroups/id_profile.go new file mode 100644 index 00000000000..77076a1e480 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/id_profile.go @@ -0,0 +1,130 @@ +package afdorigingroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/id_profile_test.go b/resource-manager/cdn/2024-09-01/afdorigingroups/id_profile_test.go new file mode 100644 index 00000000000..7c717d6653c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/id_profile_test.go @@ -0,0 +1,282 @@ +package afdorigingroups + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/afdorigingroups/method_create.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_create.go new file mode 100644 index 00000000000..5538fb9d110 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_create.go @@ -0,0 +1,76 @@ +package afdorigingroups + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AFDOriginGroup +} + +// Create ... +func (c AFDOriginGroupsClient) Create(ctx context.Context, id OriginGroupId, input AFDOriginGroup) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c AFDOriginGroupsClient) CreateThenPoll(ctx context.Context, id OriginGroupId, input AFDOriginGroup) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/method_delete.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_delete.go new file mode 100644 index 00000000000..c95a6000a7e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_delete.go @@ -0,0 +1,71 @@ +package afdorigingroups + +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 AFDOriginGroupsClient) Delete(ctx context.Context, id OriginGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AFDOriginGroupsClient) DeleteThenPoll(ctx context.Context, id OriginGroupId) 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/cdn/2024-09-01/afdorigingroups/method_get.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_get.go new file mode 100644 index 00000000000..7d6139ef937 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_get.go @@ -0,0 +1,53 @@ +package afdorigingroups + +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 *AFDOriginGroup +} + +// Get ... +func (c AFDOriginGroupsClient) Get(ctx context.Context, id OriginGroupId) (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 + } + + var model AFDOriginGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_listbyprofile.go new file mode 100644 index 00000000000..41c9b62d2bf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_listbyprofile.go @@ -0,0 +1,105 @@ +package afdorigingroups + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AFDOriginGroup +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []AFDOriginGroup +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c AFDOriginGroupsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/originGroups", 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 *[]AFDOriginGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c AFDOriginGroupsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, AFDOriginGroupOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDOriginGroupsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate AFDOriginGroupOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]AFDOriginGroup, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_listresourceusage.go new file mode 100644 index 00000000000..bd98ba2d547 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_listresourceusage.go @@ -0,0 +1,105 @@ +package afdorigingroups + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c AFDOriginGroupsClient) ListResourceUsage(ctx context.Context, id OriginGroupId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c AFDOriginGroupsClient) ListResourceUsageComplete(ctx context.Context, id OriginGroupId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDOriginGroupsClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id OriginGroupId, predicate UsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/method_update.go b/resource-manager/cdn/2024-09-01/afdorigingroups/method_update.go new file mode 100644 index 00000000000..caad347178d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/method_update.go @@ -0,0 +1,75 @@ +package afdorigingroups + +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 + Model *AFDOriginGroup +} + +// Update ... +func (c AFDOriginGroupsClient) Update(ctx context.Context, id OriginGroupId, input AFDOriginGroupUpdateParameters) (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 AFDOriginGroupsClient) UpdateThenPoll(ctx context.Context, id OriginGroupId, input AFDOriginGroupUpdateParameters) 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/cdn/2024-09-01/afdorigingroups/model_afdorigingroup.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroup.go new file mode 100644 index 00000000000..4ca3aa687ba --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroup.go @@ -0,0 +1,16 @@ +package afdorigingroups + +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 AFDOriginGroup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AFDOriginGroupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupproperties.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupproperties.go new file mode 100644 index 00000000000..c4ffcea699b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupproperties.go @@ -0,0 +1,14 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginGroupProperties struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + HealthProbeSettings *HealthProbeParameters `json:"healthProbeSettings,omitempty"` + LoadBalancingSettings *LoadBalancingSettingsParameters `json:"loadBalancingSettings,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + SessionAffinityState *EnabledState `json:"sessionAffinityState,omitempty"` + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes *int64 `json:"trafficRestorationTimeToHealedOrNewEndpointsInMinutes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdateparameters.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdateparameters.go new file mode 100644 index 00000000000..907c42b1e77 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdateparameters.go @@ -0,0 +1,8 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginGroupUpdateParameters struct { + Properties *AFDOriginGroupUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdatepropertiesparameters.go new file mode 100644 index 00000000000..0cbb49b9466 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_afdorigingroupupdatepropertiesparameters.go @@ -0,0 +1,12 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginGroupUpdatePropertiesParameters struct { + HealthProbeSettings *HealthProbeParameters `json:"healthProbeSettings,omitempty"` + LoadBalancingSettings *LoadBalancingSettingsParameters `json:"loadBalancingSettings,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + SessionAffinityState *EnabledState `json:"sessionAffinityState,omitempty"` + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes *int64 `json:"trafficRestorationTimeToHealedOrNewEndpointsInMinutes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_healthprobeparameters.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_healthprobeparameters.go new file mode 100644 index 00000000000..987e8ba933d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_healthprobeparameters.go @@ -0,0 +1,11 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthProbeParameters struct { + ProbeIntervalInSeconds *int64 `json:"probeIntervalInSeconds,omitempty"` + ProbePath *string `json:"probePath,omitempty"` + ProbeProtocol *ProbeProtocol `json:"probeProtocol,omitempty"` + ProbeRequestType *HealthProbeRequestType `json:"probeRequestType,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_loadbalancingsettingsparameters.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_loadbalancingsettingsparameters.go new file mode 100644 index 00000000000..989f3fe3dd8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_loadbalancingsettingsparameters.go @@ -0,0 +1,10 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingSettingsParameters struct { + AdditionalLatencyInMilliseconds *int64 `json:"additionalLatencyInMilliseconds,omitempty"` + SampleSize *int64 `json:"sampleSize,omitempty"` + SuccessfulSamplesRequired *int64 `json:"successfulSamplesRequired,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_usage.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_usage.go new file mode 100644 index 00000000000..eaf251c8972 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_usage.go @@ -0,0 +1,12 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue int64 `json:"currentValue"` + Id *string `json:"id,omitempty"` + Limit int64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/model_usagename.go b/resource-manager/cdn/2024-09-01/afdorigingroups/model_usagename.go new file mode 100644 index 00000000000..28c2628adc3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/model_usagename.go @@ -0,0 +1,9 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/predicates.go b/resource-manager/cdn/2024-09-01/afdorigingroups/predicates.go new file mode 100644 index 00000000000..24de95a48e3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/predicates.go @@ -0,0 +1,50 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginGroupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AFDOriginGroupOperationPredicate) Matches(input AFDOriginGroup) 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 +} + +type UsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/afdorigingroups/version.go b/resource-manager/cdn/2024-09-01/afdorigingroups/version.go new file mode 100644 index 00000000000..5afc7d6878d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigingroups/version.go @@ -0,0 +1,10 @@ +package afdorigingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/afdorigingroups/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/README.md b/resource-manager/cdn/2024-09-01/afdorigins/README.md new file mode 100644 index 00000000000..090596d28fc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdorigins` Documentation + +The `afdorigins` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/afdorigins" +``` + + +### Client Initialization + +```go +client := afdorigins.NewAFDOriginsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AFDOriginsClient.Create` + +```go +ctx := context.TODO() +id := afdorigins.NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName") + +payload := afdorigins.AFDOrigin{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDOriginsClient.Delete` + +```go +ctx := context.TODO() +id := afdorigins.NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDOriginsClient.Get` + +```go +ctx := context.TODO() +id := afdorigins.NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName") + +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: `AFDOriginsClient.ListByOriginGroup` + +```go +ctx := context.TODO() +id := afdorigins.NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + +// alternatively `client.ListByOriginGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByOriginGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDOriginsClient.Update` + +```go +ctx := context.TODO() +id := afdorigins.NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName") + +payload := afdorigins.AFDOriginUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/afdorigins/client.go b/resource-manager/cdn/2024-09-01/afdorigins/client.go new file mode 100644 index 00000000000..44159420ff1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/client.go @@ -0,0 +1,26 @@ +package afdorigins + +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 AFDOriginsClient struct { + Client *resourcemanager.Client +} + +func NewAFDOriginsClientWithBaseURI(sdkApi sdkEnv.Api) (*AFDOriginsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "afdorigins", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AFDOriginsClient: %+v", err) + } + + return &AFDOriginsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/constants.go b/resource-manager/cdn/2024-09-01/afdorigins/constants.go new file mode 100644 index 00000000000..78f584111ad --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/constants.go @@ -0,0 +1,198 @@ +package afdorigins + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type EnabledState string + +const ( + EnabledStateDisabled EnabledState = "Disabled" + EnabledStateEnabled EnabledState = "Enabled" +) + +func PossibleValuesForEnabledState() []string { + return []string{ + string(EnabledStateDisabled), + string(EnabledStateEnabled), + } +} + +func (s *EnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnabledState(input string) (*EnabledState, error) { + vals := map[string]EnabledState{ + "disabled": EnabledStateDisabled, + "enabled": EnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnabledState(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" + SharedPrivateLinkResourceStatusTimeout SharedPrivateLinkResourceStatus = "Timeout" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + string(SharedPrivateLinkResourceStatusTimeout), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + "timeout": SharedPrivateLinkResourceStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup.go b/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup.go new file mode 100644 index 00000000000..167f2a544c3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup.go @@ -0,0 +1,139 @@ +package afdorigins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&OriginGroupId{}) +} + +var _ resourceids.ResourceId = &OriginGroupId{} + +// OriginGroupId is a struct representing the Resource ID for a Origin Group +type OriginGroupId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + OriginGroupName string +} + +// NewOriginGroupID returns a new OriginGroupId struct +func NewOriginGroupID(subscriptionId string, resourceGroupName string, profileName string, originGroupName string) OriginGroupId { + return OriginGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + OriginGroupName: originGroupName, + } +} + +// ParseOriginGroupID parses 'input' into a OriginGroupId +func ParseOriginGroupID(input string) (*OriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOriginGroupIDInsensitively parses 'input' case-insensitively into a OriginGroupId +// note: this method should only be used for API response data and not user input +func ParseOriginGroupIDInsensitively(input string) (*OriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OriginGroupId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.OriginGroupName, ok = input.Parsed["originGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originGroupName", input) + } + + return nil +} + +// ValidateOriginGroupID checks that 'input' can be parsed as a Origin Group ID +func ValidateOriginGroupID(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 := ParseOriginGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Origin Group ID +func (id OriginGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/originGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.OriginGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Origin Group ID +func (id OriginGroupId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticOriginGroups", "originGroups", "originGroups"), + resourceids.UserSpecifiedSegment("originGroupName", "originGroupName"), + } +} + +// String returns a human-readable description of this Origin Group ID +func (id OriginGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Origin Group Name: %q", id.OriginGroupName), + } + return fmt.Sprintf("Origin Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup_test.go b/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup_test.go new file mode 100644 index 00000000000..450fbdf576f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/id_origingroup_test.go @@ -0,0 +1,327 @@ +package afdorigins + +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 = &OriginGroupId{} + +func TestNewOriginGroupID(t *testing.T) { + id := NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.OriginGroupName != "originGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginGroupName'", id.OriginGroupName, "originGroupName") + } +} + +func TestFormatOriginGroupID(t *testing.T) { + actual := NewOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOriginGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestParseOriginGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe", + Expected: &OriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + OriginGroupName: "oRiGiNgRoUpNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestSegmentsForOriginGroupId(t *testing.T) { + segments := OriginGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OriginGroupId 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/cdn/2024-09-01/afdorigins/id_origingrouporigin.go b/resource-manager/cdn/2024-09-01/afdorigins/id_origingrouporigin.go new file mode 100644 index 00000000000..650256d4cd0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/id_origingrouporigin.go @@ -0,0 +1,148 @@ +package afdorigins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&OriginGroupOriginId{}) +} + +var _ resourceids.ResourceId = &OriginGroupOriginId{} + +// OriginGroupOriginId is a struct representing the Resource ID for a Origin Group Origin +type OriginGroupOriginId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + OriginGroupName string + OriginName string +} + +// NewOriginGroupOriginID returns a new OriginGroupOriginId struct +func NewOriginGroupOriginID(subscriptionId string, resourceGroupName string, profileName string, originGroupName string, originName string) OriginGroupOriginId { + return OriginGroupOriginId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + OriginGroupName: originGroupName, + OriginName: originName, + } +} + +// ParseOriginGroupOriginID parses 'input' into a OriginGroupOriginId +func ParseOriginGroupOriginID(input string) (*OriginGroupOriginId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupOriginId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupOriginId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOriginGroupOriginIDInsensitively parses 'input' case-insensitively into a OriginGroupOriginId +// note: this method should only be used for API response data and not user input +func ParseOriginGroupOriginIDInsensitively(input string) (*OriginGroupOriginId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginGroupOriginId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginGroupOriginId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OriginGroupOriginId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.OriginGroupName, ok = input.Parsed["originGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originGroupName", input) + } + + if id.OriginName, ok = input.Parsed["originName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originName", input) + } + + return nil +} + +// ValidateOriginGroupOriginID checks that 'input' can be parsed as a Origin Group Origin ID +func ValidateOriginGroupOriginID(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 := ParseOriginGroupOriginID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Origin Group Origin ID +func (id OriginGroupOriginId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/originGroups/%s/origins/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.OriginGroupName, id.OriginName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Origin Group Origin ID +func (id OriginGroupOriginId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticOriginGroups", "originGroups", "originGroups"), + resourceids.UserSpecifiedSegment("originGroupName", "originGroupName"), + resourceids.StaticSegment("staticOrigins", "origins", "origins"), + resourceids.UserSpecifiedSegment("originName", "originName"), + } +} + +// String returns a human-readable description of this Origin Group Origin ID +func (id OriginGroupOriginId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Origin Group Name: %q", id.OriginGroupName), + fmt.Sprintf("Origin Name: %q", id.OriginName), + } + return fmt.Sprintf("Origin Group Origin (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/id_origingrouporigin_test.go b/resource-manager/cdn/2024-09-01/afdorigins/id_origingrouporigin_test.go new file mode 100644 index 00000000000..93db7a9b7a4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/id_origingrouporigin_test.go @@ -0,0 +1,372 @@ +package afdorigins + +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 = &OriginGroupOriginId{} + +func TestNewOriginGroupOriginID(t *testing.T) { + id := NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.OriginGroupName != "originGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginGroupName'", id.OriginGroupName, "originGroupName") + } + + if id.OriginName != "originName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginName'", id.OriginName, "originName") + } +} + +func TestFormatOriginGroupOriginID(t *testing.T) { + actual := NewOriginGroupOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "originGroupName", "originName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins/originName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOriginGroupOriginID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupOriginId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins/originName", + Expected: &OriginGroupOriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + OriginName: "originName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins/originName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupOriginID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + if actual.OriginName != v.Expected.OriginName { + t.Fatalf("Expected %q but got %q for OriginName", v.Expected.OriginName, actual.OriginName) + } + + } +} + +func TestParseOriginGroupOriginIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginGroupOriginId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/oRiGiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins/originName", + Expected: &OriginGroupOriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + OriginGroupName: "originGroupName", + OriginName: "originName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/originGroups/originGroupName/origins/originName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/oRiGiNs/oRiGiNnAmE", + Expected: &OriginGroupOriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + OriginGroupName: "oRiGiNgRoUpNaMe", + OriginName: "oRiGiNnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/oRiGiNs/oRiGiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginGroupOriginIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + if actual.OriginName != v.Expected.OriginName { + t.Fatalf("Expected %q but got %q for OriginName", v.Expected.OriginName, actual.OriginName) + } + + } +} + +func TestSegmentsForOriginGroupOriginId(t *testing.T) { + segments := OriginGroupOriginId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OriginGroupOriginId 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/cdn/2024-09-01/afdorigins/method_create.go b/resource-manager/cdn/2024-09-01/afdorigins/method_create.go new file mode 100644 index 00000000000..77dd05478d0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/method_create.go @@ -0,0 +1,76 @@ +package afdorigins + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AFDOrigin +} + +// Create ... +func (c AFDOriginsClient) Create(ctx context.Context, id OriginGroupOriginId, input AFDOrigin) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c AFDOriginsClient) CreateThenPoll(ctx context.Context, id OriginGroupOriginId, input AFDOrigin) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/method_delete.go b/resource-manager/cdn/2024-09-01/afdorigins/method_delete.go new file mode 100644 index 00000000000..b8373b1a8ae --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/method_delete.go @@ -0,0 +1,71 @@ +package afdorigins + +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 AFDOriginsClient) Delete(ctx context.Context, id OriginGroupOriginId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AFDOriginsClient) DeleteThenPoll(ctx context.Context, id OriginGroupOriginId) 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/cdn/2024-09-01/afdorigins/method_get.go b/resource-manager/cdn/2024-09-01/afdorigins/method_get.go new file mode 100644 index 00000000000..07d5d79dc8a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/method_get.go @@ -0,0 +1,53 @@ +package afdorigins + +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 *AFDOrigin +} + +// Get ... +func (c AFDOriginsClient) Get(ctx context.Context, id OriginGroupOriginId) (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 + } + + var model AFDOrigin + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/method_listbyorigingroup.go b/resource-manager/cdn/2024-09-01/afdorigins/method_listbyorigingroup.go new file mode 100644 index 00000000000..d1791399e80 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/method_listbyorigingroup.go @@ -0,0 +1,105 @@ +package afdorigins + +import ( + "context" + "fmt" + "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 ListByOriginGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AFDOrigin +} + +type ListByOriginGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AFDOrigin +} + +type ListByOriginGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByOriginGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByOriginGroup ... +func (c AFDOriginsClient) ListByOriginGroup(ctx context.Context, id OriginGroupId) (result ListByOriginGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByOriginGroupCustomPager{}, + Path: fmt.Sprintf("%s/origins", 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 *[]AFDOrigin `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByOriginGroupComplete retrieves all the results into a single object +func (c AFDOriginsClient) ListByOriginGroupComplete(ctx context.Context, id OriginGroupId) (ListByOriginGroupCompleteResult, error) { + return c.ListByOriginGroupCompleteMatchingPredicate(ctx, id, AFDOriginOperationPredicate{}) +} + +// ListByOriginGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDOriginsClient) ListByOriginGroupCompleteMatchingPredicate(ctx context.Context, id OriginGroupId, predicate AFDOriginOperationPredicate) (result ListByOriginGroupCompleteResult, err error) { + items := make([]AFDOrigin, 0) + + resp, err := c.ListByOriginGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByOriginGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/method_update.go b/resource-manager/cdn/2024-09-01/afdorigins/method_update.go new file mode 100644 index 00000000000..ea31f9b396a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/method_update.go @@ -0,0 +1,75 @@ +package afdorigins + +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 + Model *AFDOrigin +} + +// Update ... +func (c AFDOriginsClient) Update(ctx context.Context, id OriginGroupOriginId, input AFDOriginUpdateParameters) (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 AFDOriginsClient) UpdateThenPoll(ctx context.Context, id OriginGroupOriginId, input AFDOriginUpdateParameters) 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/cdn/2024-09-01/afdorigins/model_afdorigin.go b/resource-manager/cdn/2024-09-01/afdorigins/model_afdorigin.go new file mode 100644 index 00000000000..4ebe2c0ac9d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_afdorigin.go @@ -0,0 +1,16 @@ +package afdorigins + +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 AFDOrigin struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AFDOriginProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginproperties.go b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginproperties.go new file mode 100644 index 00000000000..1fa0dcacb4c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginproperties.go @@ -0,0 +1,20 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginProperties struct { + AzureOrigin *ResourceReference `json:"azureOrigin,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + EnabledState *EnabledState `json:"enabledState,omitempty"` + EnforceCertificateNameCheck *bool `json:"enforceCertificateNameCheck,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + OriginGroupName *string `json:"originGroupName,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + SharedPrivateLinkResource *SharedPrivateLinkResourceProperties `json:"sharedPrivateLinkResource,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdateparameters.go b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdateparameters.go new file mode 100644 index 00000000000..679950c6d4f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdateparameters.go @@ -0,0 +1,8 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginUpdateParameters struct { + Properties *AFDOriginUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdatepropertiesparameters.go new file mode 100644 index 00000000000..e1f958eac8b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_afdoriginupdatepropertiesparameters.go @@ -0,0 +1,18 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginUpdatePropertiesParameters struct { + AzureOrigin *ResourceReference `json:"azureOrigin,omitempty"` + EnabledState *EnabledState `json:"enabledState,omitempty"` + EnforceCertificateNameCheck *bool `json:"enforceCertificateNameCheck,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + OriginGroupName *string `json:"originGroupName,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SharedPrivateLinkResource *SharedPrivateLinkResourceProperties `json:"sharedPrivateLinkResource,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/model_resourcereference.go b/resource-manager/cdn/2024-09-01/afdorigins/model_resourcereference.go new file mode 100644 index 00000000000..5314652c752 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_resourcereference.go @@ -0,0 +1,8 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/model_sharedprivatelinkresourceproperties.go b/resource-manager/cdn/2024-09-01/afdorigins/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..e8a77e5c8c7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,12 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLink *ResourceReference `json:"privateLink,omitempty"` + PrivateLinkLocation *string `json:"privateLinkLocation,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdorigins/predicates.go b/resource-manager/cdn/2024-09-01/afdorigins/predicates.go new file mode 100644 index 00000000000..44ceab3f730 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/predicates.go @@ -0,0 +1,27 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AFDOriginOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AFDOriginOperationPredicate) Matches(input AFDOrigin) 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/cdn/2024-09-01/afdorigins/version.go b/resource-manager/cdn/2024-09-01/afdorigins/version.go new file mode 100644 index 00000000000..58b4f258e7f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdorigins/version.go @@ -0,0 +1,10 @@ +package afdorigins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/afdorigins/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/README.md b/resource-manager/cdn/2024-09-01/afdprofiles/README.md new file mode 100644 index 00000000000..e62849c1a0f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdprofiles` Documentation + +The `afdprofiles` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/afdprofiles" +``` + + +### Client Initialization + +```go +client := afdprofiles.NewAFDProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AFDProfilesClient.CheckEndpointNameAvailability` + +```go +ctx := context.TODO() +id := afdprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := afdprofiles.CheckEndpointNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckEndpointNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AFDProfilesClient.CheckHostNameAvailability` + +```go +ctx := context.TODO() +id := afdprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := afdprofiles.CheckHostNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckHostNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AFDProfilesClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := afdprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AFDProfilesClient.Upgrade` + +```go +ctx := context.TODO() +id := afdprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := afdprofiles.ProfileUpgradeParameters{ + // ... +} + + +if err := client.UpgradeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AFDProfilesClient.ValidateSecret` + +```go +ctx := context.TODO() +id := afdprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := afdprofiles.ValidateSecretInput{ + // ... +} + + +read, err := client.ValidateSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/client.go b/resource-manager/cdn/2024-09-01/afdprofiles/client.go new file mode 100644 index 00000000000..1b225a4c76a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/client.go @@ -0,0 +1,26 @@ +package afdprofiles + +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 AFDProfilesClient struct { + Client *resourcemanager.Client +} + +func NewAFDProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*AFDProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "afdprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AFDProfilesClient: %+v", err) + } + + return &AFDProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/constants.go b/resource-manager/cdn/2024-09-01/afdprofiles/constants.go new file mode 100644 index 00000000000..da6f76c8fea --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/constants.go @@ -0,0 +1,580 @@ +package afdprofiles + +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 AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type ProfileProvisioningState string + +const ( + ProfileProvisioningStateCreating ProfileProvisioningState = "Creating" + ProfileProvisioningStateDeleting ProfileProvisioningState = "Deleting" + ProfileProvisioningStateFailed ProfileProvisioningState = "Failed" + ProfileProvisioningStateSucceeded ProfileProvisioningState = "Succeeded" + ProfileProvisioningStateUpdating ProfileProvisioningState = "Updating" +) + +func PossibleValuesForProfileProvisioningState() []string { + return []string{ + string(ProfileProvisioningStateCreating), + string(ProfileProvisioningStateDeleting), + string(ProfileProvisioningStateFailed), + string(ProfileProvisioningStateSucceeded), + string(ProfileProvisioningStateUpdating), + } +} + +func (s *ProfileProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileProvisioningState(input string) (*ProfileProvisioningState, error) { + vals := map[string]ProfileProvisioningState{ + "creating": ProfileProvisioningStateCreating, + "deleting": ProfileProvisioningStateDeleting, + "failed": ProfileProvisioningStateFailed, + "succeeded": ProfileProvisioningStateSucceeded, + "updating": ProfileProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileProvisioningState(input) + return &out, nil +} + +type ProfileResourceState string + +const ( + ProfileResourceStateAbortingMigration ProfileResourceState = "AbortingMigration" + ProfileResourceStateActive ProfileResourceState = "Active" + ProfileResourceStateCommittingMigration ProfileResourceState = "CommittingMigration" + ProfileResourceStateCreating ProfileResourceState = "Creating" + ProfileResourceStateDeleting ProfileResourceState = "Deleting" + ProfileResourceStateDisabled ProfileResourceState = "Disabled" + ProfileResourceStateMigrated ProfileResourceState = "Migrated" + ProfileResourceStateMigrating ProfileResourceState = "Migrating" + ProfileResourceStatePendingMigrationCommit ProfileResourceState = "PendingMigrationCommit" +) + +func PossibleValuesForProfileResourceState() []string { + return []string{ + string(ProfileResourceStateAbortingMigration), + string(ProfileResourceStateActive), + string(ProfileResourceStateCommittingMigration), + string(ProfileResourceStateCreating), + string(ProfileResourceStateDeleting), + string(ProfileResourceStateDisabled), + string(ProfileResourceStateMigrated), + string(ProfileResourceStateMigrating), + string(ProfileResourceStatePendingMigrationCommit), + } +} + +func (s *ProfileResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileResourceState(input string) (*ProfileResourceState, error) { + vals := map[string]ProfileResourceState{ + "abortingmigration": ProfileResourceStateAbortingMigration, + "active": ProfileResourceStateActive, + "committingmigration": ProfileResourceStateCommittingMigration, + "creating": ProfileResourceStateCreating, + "deleting": ProfileResourceStateDeleting, + "disabled": ProfileResourceStateDisabled, + "migrated": ProfileResourceStateMigrated, + "migrating": ProfileResourceStateMigrating, + "pendingmigrationcommit": ProfileResourceStatePendingMigrationCommit, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileResourceState(input) + return &out, nil +} + +type ProfileScrubbingState string + +const ( + ProfileScrubbingStateDisabled ProfileScrubbingState = "Disabled" + ProfileScrubbingStateEnabled ProfileScrubbingState = "Enabled" +) + +func PossibleValuesForProfileScrubbingState() []string { + return []string{ + string(ProfileScrubbingStateDisabled), + string(ProfileScrubbingStateEnabled), + } +} + +func (s *ProfileScrubbingState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileScrubbingState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileScrubbingState(input string) (*ProfileScrubbingState, error) { + vals := map[string]ProfileScrubbingState{ + "disabled": ProfileScrubbingStateDisabled, + "enabled": ProfileScrubbingStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileScrubbingState(input) + return &out, nil +} + +type ResourceType string + +const ( + ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints ResourceType = "Microsoft.Cdn/Profiles/AfdEndpoints" + ResourceTypeMicrosoftPointCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints), + string(ResourceTypeMicrosoftPointCdnProfilesEndpoints), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "microsoft.cdn/profiles/afdendpoints": ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints, + "microsoft.cdn/profiles/endpoints": ResourceTypeMicrosoftPointCdnProfilesEndpoints, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchOperator string + +const ( + ScrubbingRuleEntryMatchOperatorEqualsAny ScrubbingRuleEntryMatchOperator = "EqualsAny" +) + +func PossibleValuesForScrubbingRuleEntryMatchOperator() []string { + return []string{ + string(ScrubbingRuleEntryMatchOperatorEqualsAny), + } +} + +func (s *ScrubbingRuleEntryMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchOperator(input string) (*ScrubbingRuleEntryMatchOperator, error) { + vals := map[string]ScrubbingRuleEntryMatchOperator{ + "equalsany": ScrubbingRuleEntryMatchOperatorEqualsAny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchOperator(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchVariable string + +const ( + ScrubbingRuleEntryMatchVariableQueryStringArgNames ScrubbingRuleEntryMatchVariable = "QueryStringArgNames" + ScrubbingRuleEntryMatchVariableRequestIPAddress ScrubbingRuleEntryMatchVariable = "RequestIPAddress" + ScrubbingRuleEntryMatchVariableRequestUri ScrubbingRuleEntryMatchVariable = "RequestUri" +) + +func PossibleValuesForScrubbingRuleEntryMatchVariable() []string { + return []string{ + string(ScrubbingRuleEntryMatchVariableQueryStringArgNames), + string(ScrubbingRuleEntryMatchVariableRequestIPAddress), + string(ScrubbingRuleEntryMatchVariableRequestUri), + } +} + +func (s *ScrubbingRuleEntryMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchVariable(input string) (*ScrubbingRuleEntryMatchVariable, error) { + vals := map[string]ScrubbingRuleEntryMatchVariable{ + "querystringargnames": ScrubbingRuleEntryMatchVariableQueryStringArgNames, + "requestipaddress": ScrubbingRuleEntryMatchVariableRequestIPAddress, + "requesturi": ScrubbingRuleEntryMatchVariableRequestUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchVariable(input) + return &out, nil +} + +type ScrubbingRuleEntryState string + +const ( + ScrubbingRuleEntryStateDisabled ScrubbingRuleEntryState = "Disabled" + ScrubbingRuleEntryStateEnabled ScrubbingRuleEntryState = "Enabled" +) + +func PossibleValuesForScrubbingRuleEntryState() []string { + return []string{ + string(ScrubbingRuleEntryStateDisabled), + string(ScrubbingRuleEntryStateEnabled), + } +} + +func (s *ScrubbingRuleEntryState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryState(input string) (*ScrubbingRuleEntryState, error) { + vals := map[string]ScrubbingRuleEntryState{ + "disabled": ScrubbingRuleEntryStateDisabled, + "enabled": ScrubbingRuleEntryStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryState(input) + return &out, nil +} + +type SecretType string + +const ( + SecretTypeAzureFirstPartyManagedCertificate SecretType = "AzureFirstPartyManagedCertificate" + SecretTypeCustomerCertificate SecretType = "CustomerCertificate" + SecretTypeManagedCertificate SecretType = "ManagedCertificate" + SecretTypeURLSigningKey SecretType = "UrlSigningKey" +) + +func PossibleValuesForSecretType() []string { + return []string{ + string(SecretTypeAzureFirstPartyManagedCertificate), + string(SecretTypeCustomerCertificate), + string(SecretTypeManagedCertificate), + string(SecretTypeURLSigningKey), + } +} + +func (s *SecretType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretType(input string) (*SecretType, error) { + vals := map[string]SecretType{ + "azurefirstpartymanagedcertificate": SecretTypeAzureFirstPartyManagedCertificate, + "customercertificate": SecretTypeCustomerCertificate, + "managedcertificate": SecretTypeManagedCertificate, + "urlsigningkey": SecretTypeURLSigningKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretType(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameCustomVerizon SkuName = "Custom_Verizon" + SkuNamePremiumAzureFrontDoor SkuName = "Premium_AzureFrontDoor" + SkuNamePremiumVerizon SkuName = "Premium_Verizon" + SkuNameStandardAkamai SkuName = "Standard_Akamai" + SkuNameStandardAvgBandWidthChinaCdn SkuName = "Standard_AvgBandWidth_ChinaCdn" + SkuNameStandardAzureFrontDoor SkuName = "Standard_AzureFrontDoor" + SkuNameStandardChinaCdn SkuName = "Standard_ChinaCdn" + SkuNameStandardMicrosoft SkuName = "Standard_Microsoft" + SkuNameStandardNineFiveFiveBandWidthChinaCdn SkuName = "Standard_955BandWidth_ChinaCdn" + SkuNameStandardPlusAvgBandWidthChinaCdn SkuName = "StandardPlus_AvgBandWidth_ChinaCdn" + SkuNameStandardPlusChinaCdn SkuName = "StandardPlus_ChinaCdn" + SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn SkuName = "StandardPlus_955BandWidth_ChinaCdn" + SkuNameStandardVerizon SkuName = "Standard_Verizon" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameCustomVerizon), + string(SkuNamePremiumAzureFrontDoor), + string(SkuNamePremiumVerizon), + string(SkuNameStandardAkamai), + string(SkuNameStandardAvgBandWidthChinaCdn), + string(SkuNameStandardAzureFrontDoor), + string(SkuNameStandardChinaCdn), + string(SkuNameStandardMicrosoft), + string(SkuNameStandardNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardPlusAvgBandWidthChinaCdn), + string(SkuNameStandardPlusChinaCdn), + string(SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardVerizon), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "custom_verizon": SkuNameCustomVerizon, + "premium_azurefrontdoor": SkuNamePremiumAzureFrontDoor, + "premium_verizon": SkuNamePremiumVerizon, + "standard_akamai": SkuNameStandardAkamai, + "standard_avgbandwidth_chinacdn": SkuNameStandardAvgBandWidthChinaCdn, + "standard_azurefrontdoor": SkuNameStandardAzureFrontDoor, + "standard_chinacdn": SkuNameStandardChinaCdn, + "standard_microsoft": SkuNameStandardMicrosoft, + "standard_955bandwidth_chinacdn": SkuNameStandardNineFiveFiveBandWidthChinaCdn, + "standardplus_avgbandwidth_chinacdn": SkuNameStandardPlusAvgBandWidthChinaCdn, + "standardplus_chinacdn": SkuNameStandardPlusChinaCdn, + "standardplus_955bandwidth_chinacdn": SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn, + "standard_verizon": SkuNameStandardVerizon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type Status string + +const ( + StatusAccessDenied Status = "AccessDenied" + StatusCertificateExpired Status = "CertificateExpired" + StatusInvalid Status = "Invalid" + StatusValid Status = "Valid" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusAccessDenied), + string(StatusCertificateExpired), + string(StatusInvalid), + string(StatusValid), + } +} + +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{ + "accessdenied": StatusAccessDenied, + "certificateexpired": StatusCertificateExpired, + "invalid": StatusInvalid, + "valid": StatusValid, + } + 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 UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/id_profile.go b/resource-manager/cdn/2024-09-01/afdprofiles/id_profile.go new file mode 100644 index 00000000000..04602dcc25c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/id_profile.go @@ -0,0 +1,130 @@ +package afdprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/id_profile_test.go b/resource-manager/cdn/2024-09-01/afdprofiles/id_profile_test.go new file mode 100644 index 00000000000..fc3424d5992 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/id_profile_test.go @@ -0,0 +1,282 @@ +package afdprofiles + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/afdprofiles/method_checkendpointnameavailability.go b/resource-manager/cdn/2024-09-01/afdprofiles/method_checkendpointnameavailability.go new file mode 100644 index 00000000000..e63995d03fd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/method_checkendpointnameavailability.go @@ -0,0 +1,58 @@ +package afdprofiles + +import ( + "context" + "fmt" + "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 CheckEndpointNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckEndpointNameAvailabilityOutput +} + +// CheckEndpointNameAvailability ... +func (c AFDProfilesClient) CheckEndpointNameAvailability(ctx context.Context, id ProfileId, input CheckEndpointNameAvailabilityInput) (result CheckEndpointNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkEndpointNameAvailability", 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 + } + + var model CheckEndpointNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/method_checkhostnameavailability.go b/resource-manager/cdn/2024-09-01/afdprofiles/method_checkhostnameavailability.go new file mode 100644 index 00000000000..7a0a2ca9451 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/method_checkhostnameavailability.go @@ -0,0 +1,58 @@ +package afdprofiles + +import ( + "context" + "fmt" + "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 CheckHostNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityOutput +} + +// CheckHostNameAvailability ... +func (c AFDProfilesClient) CheckHostNameAvailability(ctx context.Context, id ProfileId, input CheckHostNameAvailabilityInput) (result CheckHostNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkHostNameAvailability", 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 + } + + var model CheckNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/afdprofiles/method_listresourceusage.go new file mode 100644 index 00000000000..e0cb859dc7e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/method_listresourceusage.go @@ -0,0 +1,105 @@ +package afdprofiles + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c AFDProfilesClient) ListResourceUsage(ctx context.Context, id ProfileId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c AFDProfilesClient) ListResourceUsageComplete(ctx context.Context, id ProfileId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AFDProfilesClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate UsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/method_upgrade.go b/resource-manager/cdn/2024-09-01/afdprofiles/method_upgrade.go new file mode 100644 index 00000000000..42c2540b228 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/method_upgrade.go @@ -0,0 +1,75 @@ +package afdprofiles + +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 UpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Profile +} + +// Upgrade ... +func (c AFDProfilesClient) Upgrade(ctx context.Context, id ProfileId, input ProfileUpgradeParameters) (result UpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", 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 +} + +// UpgradeThenPoll performs Upgrade then polls until it's completed +func (c AFDProfilesClient) UpgradeThenPoll(ctx context.Context, id ProfileId, input ProfileUpgradeParameters) error { + result, err := c.Upgrade(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Upgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Upgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/method_validatesecret.go b/resource-manager/cdn/2024-09-01/afdprofiles/method_validatesecret.go new file mode 100644 index 00000000000..9fddaecaf92 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/method_validatesecret.go @@ -0,0 +1,58 @@ +package afdprofiles + +import ( + "context" + "fmt" + "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 ValidateSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateSecretOutput +} + +// ValidateSecret ... +func (c AFDProfilesClient) ValidateSecret(ctx context.Context, id ProfileId, input ValidateSecretInput) (result ValidateSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateSecret", 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 + } + + var model ValidateSecretOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityinput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityinput.go new file mode 100644 index 00000000000..96f0f41765e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityinput.go @@ -0,0 +1,10 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckEndpointNameAvailabilityInput struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityoutput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityoutput.go new file mode 100644 index 00000000000..0be9e951f73 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkendpointnameavailabilityoutput.go @@ -0,0 +1,11 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckEndpointNameAvailabilityOutput struct { + AvailableHostname *string `json:"availableHostname,omitempty"` + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_checkhostnameavailabilityinput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkhostnameavailabilityinput.go new file mode 100644 index 00000000000..b8248d20fbb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_checkhostnameavailabilityinput.go @@ -0,0 +1,8 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckHostNameAvailabilityInput struct { + HostName string `json:"hostName"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_checknameavailabilityoutput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_checknameavailabilityoutput.go new file mode 100644 index 00000000000..18e961a7842 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_checknameavailabilityoutput.go @@ -0,0 +1,10 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOutput struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profile.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profile.go new file mode 100644 index 00000000000..f2093113bb4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profile.go @@ -0,0 +1,22 @@ +package afdprofiles + +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 Profile struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ProfileProperties `json:"properties,omitempty"` + Sku Sku `json:"sku"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profilechangeskuwafmapping.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilechangeskuwafmapping.go new file mode 100644 index 00000000000..1e289e8c1fb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilechangeskuwafmapping.go @@ -0,0 +1,9 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileChangeSkuWafMapping struct { + ChangeToWafPolicy ResourceReference `json:"changeToWafPolicy"` + SecurityPolicyName string `json:"securityPolicyName"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profilelogscrubbing.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilelogscrubbing.go new file mode 100644 index 00000000000..6f89bfd997b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilelogscrubbing.go @@ -0,0 +1,9 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileLogScrubbing struct { + ScrubbingRules *[]ProfileScrubbingRules `json:"scrubbingRules,omitempty"` + State *ProfileScrubbingState `json:"state,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profileproperties.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profileproperties.go new file mode 100644 index 00000000000..72356670dfc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profileproperties.go @@ -0,0 +1,13 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileProperties struct { + ExtendedProperties *map[string]string `json:"extendedProperties,omitempty"` + FrontDoorId *string `json:"frontDoorId,omitempty"` + LogScrubbing *ProfileLogScrubbing `json:"logScrubbing,omitempty"` + OriginResponseTimeoutSeconds *int64 `json:"originResponseTimeoutSeconds,omitempty"` + ProvisioningState *ProfileProvisioningState `json:"provisioningState,omitempty"` + ResourceState *ProfileResourceState `json:"resourceState,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profilescrubbingrules.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilescrubbingrules.go new file mode 100644 index 00000000000..332a2f30281 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profilescrubbingrules.go @@ -0,0 +1,11 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileScrubbingRules struct { + MatchVariable ScrubbingRuleEntryMatchVariable `json:"matchVariable"` + Selector *string `json:"selector,omitempty"` + SelectorMatchOperator ScrubbingRuleEntryMatchOperator `json:"selectorMatchOperator"` + State *ScrubbingRuleEntryState `json:"state,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_profileupgradeparameters.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_profileupgradeparameters.go new file mode 100644 index 00000000000..2fe3ac4982d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_profileupgradeparameters.go @@ -0,0 +1,8 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileUpgradeParameters struct { + WafMappingList []ProfileChangeSkuWafMapping `json:"wafMappingList"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_resourcereference.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_resourcereference.go new file mode 100644 index 00000000000..6444e52fde2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_resourcereference.go @@ -0,0 +1,8 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_sku.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_sku.go new file mode 100644 index 00000000000..cb55c9a874a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_sku.go @@ -0,0 +1,8 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_usage.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_usage.go new file mode 100644 index 00000000000..7cc8e126873 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_usage.go @@ -0,0 +1,12 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue int64 `json:"currentValue"` + Id *string `json:"id,omitempty"` + Limit int64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_usagename.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_usagename.go new file mode 100644 index 00000000000..5540d53cdd5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_usagename.go @@ -0,0 +1,9 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretinput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretinput.go new file mode 100644 index 00000000000..d4e3198b21a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretinput.go @@ -0,0 +1,10 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateSecretInput struct { + SecretSource ResourceReference `json:"secretSource"` + SecretType SecretType `json:"secretType"` + SecretVersion *string `json:"secretVersion,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretoutput.go b/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretoutput.go new file mode 100644 index 00000000000..6a68c34cdd4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/model_validatesecretoutput.go @@ -0,0 +1,9 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateSecretOutput struct { + Message *string `json:"message,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/predicates.go b/resource-manager/cdn/2024-09-01/afdprofiles/predicates.go new file mode 100644 index 00000000000..0642e103835 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/predicates.go @@ -0,0 +1,27 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/afdprofiles/version.go b/resource-manager/cdn/2024-09-01/afdprofiles/version.go new file mode 100644 index 00000000000..a7f47086d3c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/afdprofiles/version.go @@ -0,0 +1,10 @@ +package afdprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/afdprofiles/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/README.md b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/README.md new file mode 100644 index 00000000000..6e5457461dd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checkendpointnameavailability` Documentation + +The `checkendpointnameavailability` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checkendpointnameavailability" +``` + + +### Client Initialization + +```go +client := checkendpointnameavailability.NewCheckEndpointNameAvailabilityClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckEndpointNameAvailabilityClient.CheckEndpointNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := checkendpointnameavailability.CheckEndpointNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckEndpointNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/client.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/client.go new file mode 100644 index 00000000000..853d16cb4cf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/client.go @@ -0,0 +1,26 @@ +package checkendpointnameavailability + +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 CheckEndpointNameAvailabilityClient struct { + Client *resourcemanager.Client +} + +func NewCheckEndpointNameAvailabilityClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckEndpointNameAvailabilityClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checkendpointnameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckEndpointNameAvailabilityClient: %+v", err) + } + + return &CheckEndpointNameAvailabilityClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/constants.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/constants.go new file mode 100644 index 00000000000..0197e78fa00 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/constants.go @@ -0,0 +1,98 @@ +package checkendpointnameavailability + +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 AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type ResourceType string + +const ( + ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints ResourceType = "Microsoft.Cdn/Profiles/AfdEndpoints" + ResourceTypeMicrosoftPointCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints), + string(ResourceTypeMicrosoftPointCdnProfilesEndpoints), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "microsoft.cdn/profiles/afdendpoints": ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints, + "microsoft.cdn/profiles/endpoints": ResourceTypeMicrosoftPointCdnProfilesEndpoints, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/method_checkendpointnameavailability.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/method_checkendpointnameavailability.go new file mode 100644 index 00000000000..ee77402ff6d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/method_checkendpointnameavailability.go @@ -0,0 +1,59 @@ +package checkendpointnameavailability + +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 CheckEndpointNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckEndpointNameAvailabilityOutput +} + +// CheckEndpointNameAvailability ... +func (c CheckEndpointNameAvailabilityClient) CheckEndpointNameAvailability(ctx context.Context, id commonids.ResourceGroupId, input CheckEndpointNameAvailabilityInput) (result CheckEndpointNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/checkEndpointNameAvailability", 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 + } + + var model CheckEndpointNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityinput.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityinput.go new file mode 100644 index 00000000000..381cce48b2f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityinput.go @@ -0,0 +1,10 @@ +package checkendpointnameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckEndpointNameAvailabilityInput struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityoutput.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityoutput.go new file mode 100644 index 00000000000..b78fec5b55e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/model_checkendpointnameavailabilityoutput.go @@ -0,0 +1,11 @@ +package checkendpointnameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckEndpointNameAvailabilityOutput struct { + AvailableHostname *string `json:"availableHostname,omitempty"` + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/checkendpointnameavailability/version.go b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/version.go new file mode 100644 index 00000000000..1758cf883a2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checkendpointnameavailability/version.go @@ -0,0 +1,10 @@ +package checkendpointnameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checkendpointnameavailability/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/README.md b/resource-manager/cdn/2024-09-01/checknameavailability/README.md new file mode 100644 index 00000000000..d084224c327 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/README.md @@ -0,0 +1,40 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checknameavailability` Documentation + +The `checknameavailability` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/checknameavailability" +``` + + +### Client Initialization + +```go +client := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckNameAvailabilityClient.CheckNameAvailability` + +```go +ctx := context.TODO() + +payload := checknameavailability.CheckNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/client.go b/resource-manager/cdn/2024-09-01/checknameavailability/client.go new file mode 100644 index 00000000000..777c8ea9e9f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/client.go @@ -0,0 +1,26 @@ +package checknameavailability + +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 CheckNameAvailabilityClient struct { + Client *resourcemanager.Client +} + +func NewCheckNameAvailabilityClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckNameAvailabilityClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checknameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityClient: %+v", err) + } + + return &CheckNameAvailabilityClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/constants.go b/resource-manager/cdn/2024-09-01/checknameavailability/constants.go new file mode 100644 index 00000000000..bf58e64a60c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/constants.go @@ -0,0 +1,51 @@ +package checknameavailability + +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 ResourceType string + +const ( + ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints ResourceType = "Microsoft.Cdn/Profiles/AfdEndpoints" + ResourceTypeMicrosoftPointCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints), + string(ResourceTypeMicrosoftPointCdnProfilesEndpoints), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "microsoft.cdn/profiles/afdendpoints": ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints, + "microsoft.cdn/profiles/endpoints": ResourceTypeMicrosoftPointCdnProfilesEndpoints, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/method_checknameavailability.go b/resource-manager/cdn/2024-09-01/checknameavailability/method_checknameavailability.go new file mode 100644 index 00000000000..fbeb3627ddb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/method_checknameavailability.go @@ -0,0 +1,57 @@ +package checknameavailability + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityOutput +} + +// CheckNameAvailability ... +func (c CheckNameAvailabilityClient) CheckNameAvailability(ctx context.Context, input CheckNameAvailabilityInput) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.CDN/checkNameAvailability", + } + + 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 + } + + var model CheckNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityinput.go b/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityinput.go new file mode 100644 index 00000000000..36311e975a8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityinput.go @@ -0,0 +1,9 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityInput struct { + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityoutput.go b/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityoutput.go new file mode 100644 index 00000000000..8b591ca1f86 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/model_checknameavailabilityoutput.go @@ -0,0 +1,10 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOutput struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailability/version.go b/resource-manager/cdn/2024-09-01/checknameavailability/version.go new file mode 100644 index 00000000000..915fc2b2ffc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailability/version.go @@ -0,0 +1,10 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checknameavailability/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/README.md b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/README.md new file mode 100644 index 00000000000..49250c522f5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription` Documentation + +The `checknameavailabilitywithsubscription` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription" +``` + + +### Client Initialization + +```go +client := checknameavailabilitywithsubscription.NewCheckNameAvailabilityWithSubscriptionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckNameAvailabilityWithSubscriptionClient.CheckNameAvailabilityWithSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := checknameavailabilitywithsubscription.CheckNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckNameAvailabilityWithSubscription(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/client.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/client.go new file mode 100644 index 00000000000..2a9854f6b75 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/client.go @@ -0,0 +1,26 @@ +package checknameavailabilitywithsubscription + +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 CheckNameAvailabilityWithSubscriptionClient struct { + Client *resourcemanager.Client +} + +func NewCheckNameAvailabilityWithSubscriptionClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckNameAvailabilityWithSubscriptionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checknameavailabilitywithsubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityWithSubscriptionClient: %+v", err) + } + + return &CheckNameAvailabilityWithSubscriptionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/constants.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/constants.go new file mode 100644 index 00000000000..8dc9ec77e49 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/constants.go @@ -0,0 +1,51 @@ +package checknameavailabilitywithsubscription + +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 ResourceType string + +const ( + ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints ResourceType = "Microsoft.Cdn/Profiles/AfdEndpoints" + ResourceTypeMicrosoftPointCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints), + string(ResourceTypeMicrosoftPointCdnProfilesEndpoints), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "microsoft.cdn/profiles/afdendpoints": ResourceTypeMicrosoftPointCdnProfilesAfdEndpoints, + "microsoft.cdn/profiles/endpoints": ResourceTypeMicrosoftPointCdnProfilesEndpoints, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/method_checknameavailabilitywithsubscription.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/method_checknameavailabilitywithsubscription.go new file mode 100644 index 00000000000..4f84ee148e8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/method_checknameavailabilitywithsubscription.go @@ -0,0 +1,59 @@ +package checknameavailabilitywithsubscription + +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 CheckNameAvailabilityWithSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityOutput +} + +// CheckNameAvailabilityWithSubscription ... +func (c CheckNameAvailabilityWithSubscriptionClient) CheckNameAvailabilityWithSubscription(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityInput) (result CheckNameAvailabilityWithSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/checkNameAvailability", 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 + } + + var model CheckNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityinput.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityinput.go new file mode 100644 index 00000000000..5025305279a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityinput.go @@ -0,0 +1,9 @@ +package checknameavailabilitywithsubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityInput struct { + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityoutput.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityoutput.go new file mode 100644 index 00000000000..9c0781a0b16 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/model_checknameavailabilityoutput.go @@ -0,0 +1,10 @@ +package checknameavailabilitywithsubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOutput struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/version.go b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/version.go new file mode 100644 index 00000000000..3907253a93c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription/version.go @@ -0,0 +1,10 @@ +package checknameavailabilitywithsubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checknameavailabilitywithsubscription/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/client.go b/resource-manager/cdn/2024-09-01/client.go new file mode 100644 index 00000000000..65a578928fe --- /dev/null +++ b/resource-manager/cdn/2024-09-01/client.go @@ -0,0 +1,235 @@ +package v2024_09_01 + +// 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/cdn/2024-09-01/afdcustomdomains" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdorigingroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdorigins" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/afdprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checkendpointnameavailability" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checknameavailability" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/checknameavailabilitywithsubscription" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/customdomains" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/edgenodes" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/endpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/loganalytics" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/origingroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/origins" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/profiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/routes" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/rules" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/rulesets" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/secrets" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/securitypolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/validateprobe" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/wafloganalytics" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets" + "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AFDCustomDomains *afdcustomdomains.AFDCustomDomainsClient + AFDEndpoints *afdendpoints.AFDEndpointsClient + AFDOriginGroups *afdorigingroups.AFDOriginGroupsClient + AFDOrigins *afdorigins.AFDOriginsClient + AFDProfiles *afdprofiles.AFDProfilesClient + CheckEndpointNameAvailability *checkendpointnameavailability.CheckEndpointNameAvailabilityClient + CheckNameAvailability *checknameavailability.CheckNameAvailabilityClient + CheckNameAvailabilityWithSubscription *checknameavailabilitywithsubscription.CheckNameAvailabilityWithSubscriptionClient + CustomDomains *customdomains.CustomDomainsClient + Edgenodes *edgenodes.EdgenodesClient + Endpoints *endpoints.EndpointsClient + LogAnalytics *loganalytics.LogAnalyticsClient + OriginGroups *origingroups.OriginGroupsClient + Origins *origins.OriginsClient + Profiles *profiles.ProfilesClient + Routes *routes.RoutesClient + RuleSets *rulesets.RuleSetsClient + Rules *rules.RulesClient + Secrets *secrets.SecretsClient + SecurityPolicies *securitypolicies.SecurityPoliciesClient + ValidateProbe *validateprobe.ValidateProbeClient + WafLogAnalytics *wafloganalytics.WafLogAnalyticsClient + WebApplicationFirewallManagedRuleSets *webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient + WebApplicationFirewallPolicies *webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + aFDCustomDomainsClient, err := afdcustomdomains.NewAFDCustomDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AFDCustomDomains client: %+v", err) + } + configureFunc(aFDCustomDomainsClient.Client) + + aFDEndpointsClient, err := afdendpoints.NewAFDEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AFDEndpoints client: %+v", err) + } + configureFunc(aFDEndpointsClient.Client) + + aFDOriginGroupsClient, err := afdorigingroups.NewAFDOriginGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AFDOriginGroups client: %+v", err) + } + configureFunc(aFDOriginGroupsClient.Client) + + aFDOriginsClient, err := afdorigins.NewAFDOriginsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AFDOrigins client: %+v", err) + } + configureFunc(aFDOriginsClient.Client) + + aFDProfilesClient, err := afdprofiles.NewAFDProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AFDProfiles client: %+v", err) + } + configureFunc(aFDProfilesClient.Client) + + checkEndpointNameAvailabilityClient, err := checkendpointnameavailability.NewCheckEndpointNameAvailabilityClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckEndpointNameAvailability client: %+v", err) + } + configureFunc(checkEndpointNameAvailabilityClient.Client) + + checkNameAvailabilityClient, err := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailability client: %+v", err) + } + configureFunc(checkNameAvailabilityClient.Client) + + checkNameAvailabilityWithSubscriptionClient, err := checknameavailabilitywithsubscription.NewCheckNameAvailabilityWithSubscriptionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailabilityWithSubscription client: %+v", err) + } + configureFunc(checkNameAvailabilityWithSubscriptionClient.Client) + + customDomainsClient, err := customdomains.NewCustomDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CustomDomains client: %+v", err) + } + configureFunc(customDomainsClient.Client) + + edgenodesClient, err := edgenodes.NewEdgenodesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Edgenodes client: %+v", err) + } + configureFunc(edgenodesClient.Client) + + endpointsClient, err := endpoints.NewEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Endpoints client: %+v", err) + } + configureFunc(endpointsClient.Client) + + logAnalyticsClient, err := loganalytics.NewLogAnalyticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LogAnalytics client: %+v", err) + } + configureFunc(logAnalyticsClient.Client) + + originGroupsClient, err := origingroups.NewOriginGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OriginGroups client: %+v", err) + } + configureFunc(originGroupsClient.Client) + + originsClient, err := origins.NewOriginsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Origins client: %+v", err) + } + configureFunc(originsClient.Client) + + profilesClient, err := profiles.NewProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Profiles client: %+v", err) + } + configureFunc(profilesClient.Client) + + routesClient, err := routes.NewRoutesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Routes client: %+v", err) + } + configureFunc(routesClient.Client) + + ruleSetsClient, err := rulesets.NewRuleSetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RuleSets client: %+v", err) + } + configureFunc(ruleSetsClient.Client) + + rulesClient, err := rules.NewRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Rules client: %+v", err) + } + configureFunc(rulesClient.Client) + + secretsClient, err := secrets.NewSecretsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Secrets client: %+v", err) + } + configureFunc(secretsClient.Client) + + securityPoliciesClient, err := securitypolicies.NewSecurityPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityPolicies client: %+v", err) + } + configureFunc(securityPoliciesClient.Client) + + validateProbeClient, err := validateprobe.NewValidateProbeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ValidateProbe client: %+v", err) + } + configureFunc(validateProbeClient.Client) + + wafLogAnalyticsClient, err := wafloganalytics.NewWafLogAnalyticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WafLogAnalytics client: %+v", err) + } + configureFunc(wafLogAnalyticsClient.Client) + + webApplicationFirewallManagedRuleSetsClient, err := webapplicationfirewallmanagedrulesets.NewWebApplicationFirewallManagedRuleSetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApplicationFirewallManagedRuleSets client: %+v", err) + } + configureFunc(webApplicationFirewallManagedRuleSetsClient.Client) + + webApplicationFirewallPoliciesClient, err := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApplicationFirewallPolicies client: %+v", err) + } + configureFunc(webApplicationFirewallPoliciesClient.Client) + + return &Client{ + AFDCustomDomains: aFDCustomDomainsClient, + AFDEndpoints: aFDEndpointsClient, + AFDOriginGroups: aFDOriginGroupsClient, + AFDOrigins: aFDOriginsClient, + AFDProfiles: aFDProfilesClient, + CheckEndpointNameAvailability: checkEndpointNameAvailabilityClient, + CheckNameAvailability: checkNameAvailabilityClient, + CheckNameAvailabilityWithSubscription: checkNameAvailabilityWithSubscriptionClient, + CustomDomains: customDomainsClient, + Edgenodes: edgenodesClient, + Endpoints: endpointsClient, + LogAnalytics: logAnalyticsClient, + OriginGroups: originGroupsClient, + Origins: originsClient, + Profiles: profilesClient, + Routes: routesClient, + RuleSets: ruleSetsClient, + Rules: rulesClient, + Secrets: secretsClient, + SecurityPolicies: securityPoliciesClient, + ValidateProbe: validateProbeClient, + WafLogAnalytics: wafLogAnalyticsClient, + WebApplicationFirewallManagedRuleSets: webApplicationFirewallManagedRuleSetsClient, + WebApplicationFirewallPolicies: webApplicationFirewallPoliciesClient, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/README.md b/resource-manager/cdn/2024-09-01/customdomains/README.md new file mode 100644 index 00000000000..0e5a66768d9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/customdomains` Documentation + +The `customdomains` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/customdomains" +``` + + +### Client Initialization + +```go +client := customdomains.NewCustomDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CustomDomainsClient.Create` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + +payload := customdomains.CustomDomainParameters{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomDomainsClient.Delete` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomDomainsClient.DisableCustomHTTPS` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + +if err := client.DisableCustomHTTPSThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomDomainsClient.EnableCustomHTTPS` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + +payload := customdomains.CustomDomainHTTPSParameters{ + // ... +} + + +if err := client.EnableCustomHTTPSThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomDomainsClient.Get` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + +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: `CustomDomainsClient.ListByEndpoint` + +```go +ctx := context.TODO() +id := customdomains.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +// alternatively `client.ListByEndpoint(ctx, id)` can be used to do batched pagination +items, err := client.ListByEndpointComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/cdn/2024-09-01/customdomains/client.go b/resource-manager/cdn/2024-09-01/customdomains/client.go new file mode 100644 index 00000000000..ea9c78bea39 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/client.go @@ -0,0 +1,26 @@ +package customdomains + +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 CustomDomainsClient struct { + Client *resourcemanager.Client +} + +func NewCustomDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*CustomDomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "customdomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CustomDomainsClient: %+v", err) + } + + return &CustomDomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/constants.go b/resource-manager/cdn/2024-09-01/customdomains/constants.go new file mode 100644 index 00000000000..c61f7162c73 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/constants.go @@ -0,0 +1,453 @@ +package customdomains + +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 CertificateSource string + +const ( + CertificateSourceAzureKeyVault CertificateSource = "AzureKeyVault" + CertificateSourceCdn CertificateSource = "Cdn" +) + +func PossibleValuesForCertificateSource() []string { + return []string{ + string(CertificateSourceAzureKeyVault), + string(CertificateSourceCdn), + } +} + +func (s *CertificateSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateSource(input string) (*CertificateSource, error) { + vals := map[string]CertificateSource{ + "azurekeyvault": CertificateSourceAzureKeyVault, + "cdn": CertificateSourceCdn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateSource(input) + return &out, nil +} + +type CertificateSourceParametersType string + +const ( + CertificateSourceParametersTypeCdnCertificateSourceParameters CertificateSourceParametersType = "CdnCertificateSourceParameters" + CertificateSourceParametersTypeKeyVaultCertificateSourceParameters CertificateSourceParametersType = "KeyVaultCertificateSourceParameters" +) + +func PossibleValuesForCertificateSourceParametersType() []string { + return []string{ + string(CertificateSourceParametersTypeCdnCertificateSourceParameters), + string(CertificateSourceParametersTypeKeyVaultCertificateSourceParameters), + } +} + +func (s *CertificateSourceParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateSourceParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateSourceParametersType(input string) (*CertificateSourceParametersType, error) { + vals := map[string]CertificateSourceParametersType{ + "cdncertificatesourceparameters": CertificateSourceParametersTypeCdnCertificateSourceParameters, + "keyvaultcertificatesourceparameters": CertificateSourceParametersTypeKeyVaultCertificateSourceParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateSourceParametersType(input) + return &out, nil +} + +type CertificateType string + +const ( + CertificateTypeDedicated CertificateType = "Dedicated" + CertificateTypeShared CertificateType = "Shared" +) + +func PossibleValuesForCertificateType() []string { + return []string{ + string(CertificateTypeDedicated), + string(CertificateTypeShared), + } +} + +func (s *CertificateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateType(input string) (*CertificateType, error) { + vals := map[string]CertificateType{ + "dedicated": CertificateTypeDedicated, + "shared": CertificateTypeShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateType(input) + return &out, nil +} + +type CustomDomainResourceState string + +const ( + CustomDomainResourceStateActive CustomDomainResourceState = "Active" + CustomDomainResourceStateCreating CustomDomainResourceState = "Creating" + CustomDomainResourceStateDeleting CustomDomainResourceState = "Deleting" +) + +func PossibleValuesForCustomDomainResourceState() []string { + return []string{ + string(CustomDomainResourceStateActive), + string(CustomDomainResourceStateCreating), + string(CustomDomainResourceStateDeleting), + } +} + +func (s *CustomDomainResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDomainResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDomainResourceState(input string) (*CustomDomainResourceState, error) { + vals := map[string]CustomDomainResourceState{ + "active": CustomDomainResourceStateActive, + "creating": CustomDomainResourceStateCreating, + "deleting": CustomDomainResourceStateDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDomainResourceState(input) + return &out, nil +} + +type CustomHTTPSProvisioningState string + +const ( + CustomHTTPSProvisioningStateDisabled CustomHTTPSProvisioningState = "Disabled" + CustomHTTPSProvisioningStateDisabling CustomHTTPSProvisioningState = "Disabling" + CustomHTTPSProvisioningStateEnabled CustomHTTPSProvisioningState = "Enabled" + CustomHTTPSProvisioningStateEnabling CustomHTTPSProvisioningState = "Enabling" + CustomHTTPSProvisioningStateFailed CustomHTTPSProvisioningState = "Failed" +) + +func PossibleValuesForCustomHTTPSProvisioningState() []string { + return []string{ + string(CustomHTTPSProvisioningStateDisabled), + string(CustomHTTPSProvisioningStateDisabling), + string(CustomHTTPSProvisioningStateEnabled), + string(CustomHTTPSProvisioningStateEnabling), + string(CustomHTTPSProvisioningStateFailed), + } +} + +func (s *CustomHTTPSProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHTTPSProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHTTPSProvisioningState(input string) (*CustomHTTPSProvisioningState, error) { + vals := map[string]CustomHTTPSProvisioningState{ + "disabled": CustomHTTPSProvisioningStateDisabled, + "disabling": CustomHTTPSProvisioningStateDisabling, + "enabled": CustomHTTPSProvisioningStateEnabled, + "enabling": CustomHTTPSProvisioningStateEnabling, + "failed": CustomHTTPSProvisioningStateFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHTTPSProvisioningState(input) + return &out, nil +} + +type CustomHTTPSProvisioningSubstate string + +const ( + CustomHTTPSProvisioningSubstateCertificateDeleted CustomHTTPSProvisioningSubstate = "CertificateDeleted" + CustomHTTPSProvisioningSubstateCertificateDeployed CustomHTTPSProvisioningSubstate = "CertificateDeployed" + CustomHTTPSProvisioningSubstateDeletingCertificate CustomHTTPSProvisioningSubstate = "DeletingCertificate" + CustomHTTPSProvisioningSubstateDeployingCertificate CustomHTTPSProvisioningSubstate = "DeployingCertificate" + CustomHTTPSProvisioningSubstateDomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestApproved" + CustomHTTPSProvisioningSubstateDomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestRejected" + CustomHTTPSProvisioningSubstateDomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestTimedOut" + CustomHTTPSProvisioningSubstateIssuingCertificate CustomHTTPSProvisioningSubstate = "IssuingCertificate" + CustomHTTPSProvisioningSubstatePendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = "PendingDomainControlValidationREquestApproval" + CustomHTTPSProvisioningSubstateSubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = "SubmittingDomainControlValidationRequest" +) + +func PossibleValuesForCustomHTTPSProvisioningSubstate() []string { + return []string{ + string(CustomHTTPSProvisioningSubstateCertificateDeleted), + string(CustomHTTPSProvisioningSubstateCertificateDeployed), + string(CustomHTTPSProvisioningSubstateDeletingCertificate), + string(CustomHTTPSProvisioningSubstateDeployingCertificate), + string(CustomHTTPSProvisioningSubstateDomainControlValidationRequestApproved), + string(CustomHTTPSProvisioningSubstateDomainControlValidationRequestRejected), + string(CustomHTTPSProvisioningSubstateDomainControlValidationRequestTimedOut), + string(CustomHTTPSProvisioningSubstateIssuingCertificate), + string(CustomHTTPSProvisioningSubstatePendingDomainControlValidationREquestApproval), + string(CustomHTTPSProvisioningSubstateSubmittingDomainControlValidationRequest), + } +} + +func (s *CustomHTTPSProvisioningSubstate) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHTTPSProvisioningSubstate(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHTTPSProvisioningSubstate(input string) (*CustomHTTPSProvisioningSubstate, error) { + vals := map[string]CustomHTTPSProvisioningSubstate{ + "certificatedeleted": CustomHTTPSProvisioningSubstateCertificateDeleted, + "certificatedeployed": CustomHTTPSProvisioningSubstateCertificateDeployed, + "deletingcertificate": CustomHTTPSProvisioningSubstateDeletingCertificate, + "deployingcertificate": CustomHTTPSProvisioningSubstateDeployingCertificate, + "domaincontrolvalidationrequestapproved": CustomHTTPSProvisioningSubstateDomainControlValidationRequestApproved, + "domaincontrolvalidationrequestrejected": CustomHTTPSProvisioningSubstateDomainControlValidationRequestRejected, + "domaincontrolvalidationrequesttimedout": CustomHTTPSProvisioningSubstateDomainControlValidationRequestTimedOut, + "issuingcertificate": CustomHTTPSProvisioningSubstateIssuingCertificate, + "pendingdomaincontrolvalidationrequestapproval": CustomHTTPSProvisioningSubstatePendingDomainControlValidationREquestApproval, + "submittingdomaincontrolvalidationrequest": CustomHTTPSProvisioningSubstateSubmittingDomainControlValidationRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHTTPSProvisioningSubstate(input) + return &out, nil +} + +type DeleteRule string + +const ( + DeleteRuleNoAction DeleteRule = "NoAction" +) + +func PossibleValuesForDeleteRule() []string { + return []string{ + string(DeleteRuleNoAction), + } +} + +func (s *DeleteRule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteRule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteRule(input string) (*DeleteRule, error) { + vals := map[string]DeleteRule{ + "noaction": DeleteRuleNoAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteRule(input) + return &out, nil +} + +type MinimumTlsVersion string + +const ( + MinimumTlsVersionNone MinimumTlsVersion = "None" + MinimumTlsVersionTLSOneTwo MinimumTlsVersion = "TLS12" + MinimumTlsVersionTLSOneZero MinimumTlsVersion = "TLS10" +) + +func PossibleValuesForMinimumTlsVersion() []string { + return []string{ + string(MinimumTlsVersionNone), + string(MinimumTlsVersionTLSOneTwo), + string(MinimumTlsVersionTLSOneZero), + } +} + +func (s *MinimumTlsVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMinimumTlsVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMinimumTlsVersion(input string) (*MinimumTlsVersion, error) { + vals := map[string]MinimumTlsVersion{ + "none": MinimumTlsVersionNone, + "tls12": MinimumTlsVersionTLSOneTwo, + "tls10": MinimumTlsVersionTLSOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MinimumTlsVersion(input) + return &out, nil +} + +type ProtocolType string + +const ( + ProtocolTypeIPBased ProtocolType = "IPBased" + ProtocolTypeServerNameIndication ProtocolType = "ServerNameIndication" +) + +func PossibleValuesForProtocolType() []string { + return []string{ + string(ProtocolTypeIPBased), + string(ProtocolTypeServerNameIndication), + } +} + +func (s *ProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocolType(input string) (*ProtocolType, error) { + vals := map[string]ProtocolType{ + "ipbased": ProtocolTypeIPBased, + "servernameindication": ProtocolTypeServerNameIndication, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtocolType(input) + return &out, nil +} + +type UpdateRule string + +const ( + UpdateRuleNoAction UpdateRule = "NoAction" +) + +func PossibleValuesForUpdateRule() []string { + return []string{ + string(UpdateRuleNoAction), + } +} + +func (s *UpdateRule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpdateRule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpdateRule(input string) (*UpdateRule, error) { + vals := map[string]UpdateRule{ + "noaction": UpdateRuleNoAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpdateRule(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/id_endpoint.go b/resource-manager/cdn/2024-09-01/customdomains/id_endpoint.go new file mode 100644 index 00000000000..b9bce214c3e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/id_endpoint.go @@ -0,0 +1,139 @@ +package customdomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointId{}) +} + +var _ resourceids.ResourceId = &EndpointId{} + +// EndpointId is a struct representing the Resource ID for a Endpoint +type EndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string +} + +// NewEndpointID returns a new EndpointId struct +func NewEndpointID(subscriptionId string, resourceGroupName string, profileName string, endpointName string) EndpointId { + return EndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + } +} + +// ParseEndpointID parses 'input' into a EndpointId +func ParseEndpointID(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId +// note: this method should only be used for API response data and not user input +func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + return nil +} + +// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID +func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint ID +func (id EndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID +func (id EndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + } +} + +// String returns a human-readable description of this Endpoint ID +func (id EndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + } + return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/id_endpoint_test.go b/resource-manager/cdn/2024-09-01/customdomains/id_endpoint_test.go new file mode 100644 index 00000000000..058b3f0566e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/id_endpoint_test.go @@ -0,0 +1,327 @@ +package customdomains + +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 = &EndpointId{} + +func TestNewEndpointID(t *testing.T) { + id := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } +} + +func TestFormatEndpointID(t *testing.T) { + actual := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestParseEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestSegmentsForEndpointId(t *testing.T) { + segments := EndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointId 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/cdn/2024-09-01/customdomains/id_endpointcustomdomain.go b/resource-manager/cdn/2024-09-01/customdomains/id_endpointcustomdomain.go new file mode 100644 index 00000000000..c9f51b8ee94 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/id_endpointcustomdomain.go @@ -0,0 +1,148 @@ +package customdomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointCustomDomainId{}) +} + +var _ resourceids.ResourceId = &EndpointCustomDomainId{} + +// EndpointCustomDomainId is a struct representing the Resource ID for a Endpoint Custom Domain +type EndpointCustomDomainId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string + CustomDomainName string +} + +// NewEndpointCustomDomainID returns a new EndpointCustomDomainId struct +func NewEndpointCustomDomainID(subscriptionId string, resourceGroupName string, profileName string, endpointName string, customDomainName string) EndpointCustomDomainId { + return EndpointCustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + CustomDomainName: customDomainName, + } +} + +// ParseEndpointCustomDomainID parses 'input' into a EndpointCustomDomainId +func ParseEndpointCustomDomainID(input string) (*EndpointCustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointCustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointCustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointCustomDomainIDInsensitively parses 'input' case-insensitively into a EndpointCustomDomainId +// note: this method should only be used for API response data and not user input +func ParseEndpointCustomDomainIDInsensitively(input string) (*EndpointCustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointCustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointCustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointCustomDomainId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateEndpointCustomDomainID checks that 'input' can be parsed as a Endpoint Custom Domain ID +func ValidateEndpointCustomDomainID(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 := ParseEndpointCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint Custom Domain ID +func (id EndpointCustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint Custom Domain ID +func (id EndpointCustomDomainId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainName"), + } +} + +// String returns a human-readable description of this Endpoint Custom Domain ID +func (id EndpointCustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Endpoint Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/id_endpointcustomdomain_test.go b/resource-manager/cdn/2024-09-01/customdomains/id_endpointcustomdomain_test.go new file mode 100644 index 00000000000..8695b4bdab7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/id_endpointcustomdomain_test.go @@ -0,0 +1,372 @@ +package customdomains + +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 = &EndpointCustomDomainId{} + +func TestNewEndpointCustomDomainID(t *testing.T) { + id := NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } + + if id.CustomDomainName != "customDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainName") + } +} + +func TestFormatEndpointCustomDomainID(t *testing.T) { + actual := NewEndpointCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "customDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains/customDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointCustomDomainId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains/customDomainName", + Expected: &EndpointCustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains/customDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointCustomDomainID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseEndpointCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointCustomDomainId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains/customDomainName", + Expected: &EndpointCustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/customDomains/customDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE", + Expected: &EndpointCustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + CustomDomainName: "cUsToMdOmAiNnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointCustomDomainIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForEndpointCustomDomainId(t *testing.T) { + segments := EndpointCustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointCustomDomainId 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/cdn/2024-09-01/customdomains/method_create.go b/resource-manager/cdn/2024-09-01/customdomains/method_create.go new file mode 100644 index 00000000000..a9e4d357f5d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_create.go @@ -0,0 +1,76 @@ +package customdomains + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// Create ... +func (c CustomDomainsClient) Create(ctx context.Context, id EndpointCustomDomainId, input CustomDomainParameters) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CustomDomainsClient) CreateThenPoll(ctx context.Context, id EndpointCustomDomainId, input CustomDomainParameters) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/method_delete.go b/resource-manager/cdn/2024-09-01/customdomains/method_delete.go new file mode 100644 index 00000000000..44b72a2da70 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_delete.go @@ -0,0 +1,72 @@ +package customdomains + +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 + Model *CustomDomain +} + +// Delete ... +func (c CustomDomainsClient) Delete(ctx context.Context, id EndpointCustomDomainId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 CustomDomainsClient) DeleteThenPoll(ctx context.Context, id EndpointCustomDomainId) 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/cdn/2024-09-01/customdomains/method_disablecustomhttps.go b/resource-manager/cdn/2024-09-01/customdomains/method_disablecustomhttps.go new file mode 100644 index 00000000000..803bf0d371f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_disablecustomhttps.go @@ -0,0 +1,71 @@ +package customdomains + +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 DisableCustomHTTPSOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// DisableCustomHTTPS ... +func (c CustomDomainsClient) DisableCustomHTTPS(ctx context.Context, id EndpointCustomDomainId) (result DisableCustomHTTPSOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disableCustomHttps", 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 +} + +// DisableCustomHTTPSThenPoll performs DisableCustomHTTPS then polls until it's completed +func (c CustomDomainsClient) DisableCustomHTTPSThenPoll(ctx context.Context, id EndpointCustomDomainId) error { + result, err := c.DisableCustomHTTPS(ctx, id) + if err != nil { + return fmt.Errorf("performing DisableCustomHTTPS: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DisableCustomHTTPS: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/method_enablecustomhttps.go b/resource-manager/cdn/2024-09-01/customdomains/method_enablecustomhttps.go new file mode 100644 index 00000000000..355aba6796c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_enablecustomhttps.go @@ -0,0 +1,75 @@ +package customdomains + +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 EnableCustomHTTPSOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomDomain +} + +// EnableCustomHTTPS ... +func (c CustomDomainsClient) EnableCustomHTTPS(ctx context.Context, id EndpointCustomDomainId, input CustomDomainHTTPSParameters) (result EnableCustomHTTPSOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enableCustomHttps", 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 +} + +// EnableCustomHTTPSThenPoll performs EnableCustomHTTPS then polls until it's completed +func (c CustomDomainsClient) EnableCustomHTTPSThenPoll(ctx context.Context, id EndpointCustomDomainId, input CustomDomainHTTPSParameters) error { + result, err := c.EnableCustomHTTPS(ctx, id, input) + if err != nil { + return fmt.Errorf("performing EnableCustomHTTPS: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after EnableCustomHTTPS: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/method_get.go b/resource-manager/cdn/2024-09-01/customdomains/method_get.go new file mode 100644 index 00000000000..0217277a03b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_get.go @@ -0,0 +1,53 @@ +package customdomains + +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 *CustomDomain +} + +// Get ... +func (c CustomDomainsClient) Get(ctx context.Context, id EndpointCustomDomainId) (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 + } + + var model CustomDomain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/method_listbyendpoint.go b/resource-manager/cdn/2024-09-01/customdomains/method_listbyendpoint.go new file mode 100644 index 00000000000..393f5f431c1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/method_listbyendpoint.go @@ -0,0 +1,105 @@ +package customdomains + +import ( + "context" + "fmt" + "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 ListByEndpointOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomDomain +} + +type ListByEndpointCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomDomain +} + +type ListByEndpointCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByEndpointCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByEndpoint ... +func (c CustomDomainsClient) ListByEndpoint(ctx context.Context, id EndpointId) (result ListByEndpointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByEndpointCustomPager{}, + Path: fmt.Sprintf("%s/customDomains", 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 *[]CustomDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByEndpointComplete retrieves all the results into a single object +func (c CustomDomainsClient) ListByEndpointComplete(ctx context.Context, id EndpointId) (ListByEndpointCompleteResult, error) { + return c.ListByEndpointCompleteMatchingPredicate(ctx, id, CustomDomainOperationPredicate{}) +} + +// ListByEndpointCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CustomDomainsClient) ListByEndpointCompleteMatchingPredicate(ctx context.Context, id EndpointId, predicate CustomDomainOperationPredicate) (result ListByEndpointCompleteResult, err error) { + items := make([]CustomDomain, 0) + + resp, err := c.ListByEndpoint(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByEndpointCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_cdncertificatesourceparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_cdncertificatesourceparameters.go new file mode 100644 index 00000000000..34f774a962c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_cdncertificatesourceparameters.go @@ -0,0 +1,50 @@ +package customdomains + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CertificateSourceParameters = CdnCertificateSourceParameters{} + +type CdnCertificateSourceParameters struct { + CertificateType CertificateType `json:"certificateType"` + + // Fields inherited from CertificateSourceParameters + + TypeName CertificateSourceParametersType `json:"typeName"` +} + +func (s CdnCertificateSourceParameters) CertificateSourceParameters() BaseCertificateSourceParametersImpl { + return BaseCertificateSourceParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CdnCertificateSourceParameters{} + +func (s CdnCertificateSourceParameters) MarshalJSON() ([]byte, error) { + type wrapper CdnCertificateSourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CdnCertificateSourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CdnCertificateSourceParameters: %+v", err) + } + + decoded["typeName"] = "CdnCertificateSourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CdnCertificateSourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_cdnmanagedhttpsparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_cdnmanagedhttpsparameters.go new file mode 100644 index 00000000000..f404fdf321c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_cdnmanagedhttpsparameters.go @@ -0,0 +1,54 @@ +package customdomains + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CustomDomainHTTPSParameters = CdnManagedHTTPSParameters{} + +type CdnManagedHTTPSParameters struct { + CertificateSourceParameters CdnCertificateSourceParameters `json:"certificateSourceParameters"` + + // Fields inherited from CustomDomainHTTPSParameters + + CertificateSource CertificateSource `json:"certificateSource"` + MinimumTlsVersion *MinimumTlsVersion `json:"minimumTlsVersion,omitempty"` + ProtocolType ProtocolType `json:"protocolType"` +} + +func (s CdnManagedHTTPSParameters) CustomDomainHTTPSParameters() BaseCustomDomainHTTPSParametersImpl { + return BaseCustomDomainHTTPSParametersImpl{ + CertificateSource: s.CertificateSource, + MinimumTlsVersion: s.MinimumTlsVersion, + ProtocolType: s.ProtocolType, + } +} + +var _ json.Marshaler = CdnManagedHTTPSParameters{} + +func (s CdnManagedHTTPSParameters) MarshalJSON() ([]byte, error) { + type wrapper CdnManagedHTTPSParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CdnManagedHTTPSParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CdnManagedHTTPSParameters: %+v", err) + } + + decoded["certificateSource"] = "Cdn" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CdnManagedHTTPSParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_certificatesourceparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_certificatesourceparameters.go new file mode 100644 index 00000000000..fceb7a28e5f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_certificatesourceparameters.go @@ -0,0 +1,83 @@ +package customdomains + +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 CertificateSourceParameters interface { + CertificateSourceParameters() BaseCertificateSourceParametersImpl +} + +var _ CertificateSourceParameters = BaseCertificateSourceParametersImpl{} + +type BaseCertificateSourceParametersImpl struct { + TypeName CertificateSourceParametersType `json:"typeName"` +} + +func (s BaseCertificateSourceParametersImpl) CertificateSourceParameters() BaseCertificateSourceParametersImpl { + return s +} + +var _ CertificateSourceParameters = RawCertificateSourceParametersImpl{} + +// RawCertificateSourceParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawCertificateSourceParametersImpl struct { + certificateSourceParameters BaseCertificateSourceParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawCertificateSourceParametersImpl) CertificateSourceParameters() BaseCertificateSourceParametersImpl { + return s.certificateSourceParameters +} + +func UnmarshalCertificateSourceParametersImplementation(input []byte) (CertificateSourceParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling CertificateSourceParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["typeName"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CdnCertificateSourceParameters") { + var out CdnCertificateSourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CdnCertificateSourceParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KeyVaultCertificateSourceParameters") { + var out KeyVaultCertificateSourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KeyVaultCertificateSourceParameters: %+v", err) + } + return out, nil + } + + var parent BaseCertificateSourceParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseCertificateSourceParametersImpl: %+v", err) + } + + return RawCertificateSourceParametersImpl{ + certificateSourceParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_customdomain.go b/resource-manager/cdn/2024-09-01/customdomains/model_customdomain.go new file mode 100644 index 00000000000..540ed3151a2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_customdomain.go @@ -0,0 +1,16 @@ +package customdomains + +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 CustomDomain struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDomainProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_customdomainhttpsparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainhttpsparameters.go new file mode 100644 index 00000000000..93bff8f492d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainhttpsparameters.go @@ -0,0 +1,85 @@ +package customdomains + +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 CustomDomainHTTPSParameters interface { + CustomDomainHTTPSParameters() BaseCustomDomainHTTPSParametersImpl +} + +var _ CustomDomainHTTPSParameters = BaseCustomDomainHTTPSParametersImpl{} + +type BaseCustomDomainHTTPSParametersImpl struct { + CertificateSource CertificateSource `json:"certificateSource"` + MinimumTlsVersion *MinimumTlsVersion `json:"minimumTlsVersion,omitempty"` + ProtocolType ProtocolType `json:"protocolType"` +} + +func (s BaseCustomDomainHTTPSParametersImpl) CustomDomainHTTPSParameters() BaseCustomDomainHTTPSParametersImpl { + return s +} + +var _ CustomDomainHTTPSParameters = RawCustomDomainHTTPSParametersImpl{} + +// RawCustomDomainHTTPSParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawCustomDomainHTTPSParametersImpl struct { + customDomainHTTPSParameters BaseCustomDomainHTTPSParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawCustomDomainHTTPSParametersImpl) CustomDomainHTTPSParameters() BaseCustomDomainHTTPSParametersImpl { + return s.customDomainHTTPSParameters +} + +func UnmarshalCustomDomainHTTPSParametersImplementation(input []byte) (CustomDomainHTTPSParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling CustomDomainHTTPSParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["certificateSource"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Cdn") { + var out CdnManagedHTTPSParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CdnManagedHTTPSParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureKeyVault") { + var out UserManagedHTTPSParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UserManagedHTTPSParameters: %+v", err) + } + return out, nil + } + + var parent BaseCustomDomainHTTPSParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseCustomDomainHTTPSParametersImpl: %+v", err) + } + + return RawCustomDomainHTTPSParametersImpl{ + customDomainHTTPSParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_customdomainparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainparameters.go new file mode 100644 index 00000000000..a7dd7e903c9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainparameters.go @@ -0,0 +1,8 @@ +package customdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainParameters struct { + Properties *CustomDomainPropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_customdomainproperties.go b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainproperties.go new file mode 100644 index 00000000000..81cf92264d0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainproperties.go @@ -0,0 +1,57 @@ +package customdomains + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainProperties struct { + CustomHTTPSParameters CustomDomainHTTPSParameters `json:"customHttpsParameters"` + CustomHTTPSProvisioningState *CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` + CustomHTTPSProvisioningSubstate *CustomHTTPSProvisioningSubstate `json:"customHttpsProvisioningSubstate,omitempty"` + HostName string `json:"hostName"` + ProvisioningState *CustomHTTPSProvisioningState `json:"provisioningState,omitempty"` + ResourceState *CustomDomainResourceState `json:"resourceState,omitempty"` + ValidationData *string `json:"validationData,omitempty"` +} + +var _ json.Unmarshaler = &CustomDomainProperties{} + +func (s *CustomDomainProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CustomHTTPSProvisioningState *CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` + CustomHTTPSProvisioningSubstate *CustomHTTPSProvisioningSubstate `json:"customHttpsProvisioningSubstate,omitempty"` + HostName string `json:"hostName"` + ProvisioningState *CustomHTTPSProvisioningState `json:"provisioningState,omitempty"` + ResourceState *CustomDomainResourceState `json:"resourceState,omitempty"` + ValidationData *string `json:"validationData,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CustomHTTPSProvisioningState = decoded.CustomHTTPSProvisioningState + s.CustomHTTPSProvisioningSubstate = decoded.CustomHTTPSProvisioningSubstate + s.HostName = decoded.HostName + s.ProvisioningState = decoded.ProvisioningState + s.ResourceState = decoded.ResourceState + s.ValidationData = decoded.ValidationData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CustomDomainProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customHttpsParameters"]; ok { + impl, err := UnmarshalCustomDomainHTTPSParametersImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomHTTPSParameters' for 'CustomDomainProperties': %+v", err) + } + s.CustomHTTPSParameters = impl + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_customdomainpropertiesparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainpropertiesparameters.go new file mode 100644 index 00000000000..07f04d94e8d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_customdomainpropertiesparameters.go @@ -0,0 +1,8 @@ +package customdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainPropertiesParameters struct { + HostName string `json:"hostName"` +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_keyvaultcertificatesourceparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_keyvaultcertificatesourceparameters.go new file mode 100644 index 00000000000..141686a909e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_keyvaultcertificatesourceparameters.go @@ -0,0 +1,56 @@ +package customdomains + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CertificateSourceParameters = KeyVaultCertificateSourceParameters{} + +type KeyVaultCertificateSourceParameters struct { + DeleteRule DeleteRule `json:"deleteRule"` + ResourceGroupName string `json:"resourceGroupName"` + SecretName string `json:"secretName"` + SecretVersion *string `json:"secretVersion,omitempty"` + SubscriptionId string `json:"subscriptionId"` + UpdateRule UpdateRule `json:"updateRule"` + VaultName string `json:"vaultName"` + + // Fields inherited from CertificateSourceParameters + + TypeName CertificateSourceParametersType `json:"typeName"` +} + +func (s KeyVaultCertificateSourceParameters) CertificateSourceParameters() BaseCertificateSourceParametersImpl { + return BaseCertificateSourceParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = KeyVaultCertificateSourceParameters{} + +func (s KeyVaultCertificateSourceParameters) MarshalJSON() ([]byte, error) { + type wrapper KeyVaultCertificateSourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KeyVaultCertificateSourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KeyVaultCertificateSourceParameters: %+v", err) + } + + decoded["typeName"] = "KeyVaultCertificateSourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KeyVaultCertificateSourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/model_usermanagedhttpsparameters.go b/resource-manager/cdn/2024-09-01/customdomains/model_usermanagedhttpsparameters.go new file mode 100644 index 00000000000..50120de1186 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/model_usermanagedhttpsparameters.go @@ -0,0 +1,54 @@ +package customdomains + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CustomDomainHTTPSParameters = UserManagedHTTPSParameters{} + +type UserManagedHTTPSParameters struct { + CertificateSourceParameters KeyVaultCertificateSourceParameters `json:"certificateSourceParameters"` + + // Fields inherited from CustomDomainHTTPSParameters + + CertificateSource CertificateSource `json:"certificateSource"` + MinimumTlsVersion *MinimumTlsVersion `json:"minimumTlsVersion,omitempty"` + ProtocolType ProtocolType `json:"protocolType"` +} + +func (s UserManagedHTTPSParameters) CustomDomainHTTPSParameters() BaseCustomDomainHTTPSParametersImpl { + return BaseCustomDomainHTTPSParametersImpl{ + CertificateSource: s.CertificateSource, + MinimumTlsVersion: s.MinimumTlsVersion, + ProtocolType: s.ProtocolType, + } +} + +var _ json.Marshaler = UserManagedHTTPSParameters{} + +func (s UserManagedHTTPSParameters) MarshalJSON() ([]byte, error) { + type wrapper UserManagedHTTPSParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UserManagedHTTPSParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UserManagedHTTPSParameters: %+v", err) + } + + decoded["certificateSource"] = "AzureKeyVault" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UserManagedHTTPSParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/customdomains/predicates.go b/resource-manager/cdn/2024-09-01/customdomains/predicates.go new file mode 100644 index 00000000000..1baf6f506dd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/predicates.go @@ -0,0 +1,27 @@ +package customdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomainOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CustomDomainOperationPredicate) Matches(input CustomDomain) 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/cdn/2024-09-01/customdomains/version.go b/resource-manager/cdn/2024-09-01/customdomains/version.go new file mode 100644 index 00000000000..33917932bd8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/customdomains/version.go @@ -0,0 +1,10 @@ +package customdomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/customdomains/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/README.md b/resource-manager/cdn/2024-09-01/edgenodes/README.md new file mode 100644 index 00000000000..7cc34220419 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/edgenodes` Documentation + +The `edgenodes` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/edgenodes" +``` + + +### Client Initialization + +```go +client := edgenodes.NewEdgenodesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EdgenodesClient.List` + +```go +ctx := context.TODO() + + +// alternatively `client.List(ctx)` can be used to do batched pagination +items, err := client.ListComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/cdn/2024-09-01/edgenodes/client.go b/resource-manager/cdn/2024-09-01/edgenodes/client.go new file mode 100644 index 00000000000..4bdc5d16a2a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/client.go @@ -0,0 +1,26 @@ +package edgenodes + +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 EdgenodesClient struct { + Client *resourcemanager.Client +} + +func NewEdgenodesClientWithBaseURI(sdkApi sdkEnv.Api) (*EdgenodesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "edgenodes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EdgenodesClient: %+v", err) + } + + return &EdgenodesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/method_list.go b/resource-manager/cdn/2024-09-01/edgenodes/method_list.go new file mode 100644 index 00000000000..fd492ed7009 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/method_list.go @@ -0,0 +1,105 @@ +package edgenodes + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EdgeNode +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EdgeNode +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c EdgenodesClient) List(ctx context.Context) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: "/providers/Microsoft.CDN/edgenodes", + } + + 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 *[]EdgeNode `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 EdgenodesClient) ListComplete(ctx context.Context) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, EdgeNodeOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EdgenodesClient) ListCompleteMatchingPredicate(ctx context.Context, predicate EdgeNodeOperationPredicate) (result ListCompleteResult, err error) { + items := make([]EdgeNode, 0) + + resp, err := c.List(ctx) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/cdn/2024-09-01/edgenodes/model_cidripaddress.go b/resource-manager/cdn/2024-09-01/edgenodes/model_cidripaddress.go new file mode 100644 index 00000000000..abac7b4c8ec --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/model_cidripaddress.go @@ -0,0 +1,9 @@ +package edgenodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CidrIPAddress struct { + BaseIPAddress *string `json:"baseIpAddress,omitempty"` + PrefixLength *int64 `json:"prefixLength,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/model_edgenode.go b/resource-manager/cdn/2024-09-01/edgenodes/model_edgenode.go new file mode 100644 index 00000000000..8024e313b47 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/model_edgenode.go @@ -0,0 +1,16 @@ +package edgenodes + +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 EdgeNode struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *EdgeNodeProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/model_edgenodeproperties.go b/resource-manager/cdn/2024-09-01/edgenodes/model_edgenodeproperties.go new file mode 100644 index 00000000000..e5374afca1b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/model_edgenodeproperties.go @@ -0,0 +1,8 @@ +package edgenodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EdgeNodeProperties struct { + IPAddressGroups []IPAddressGroup `json:"ipAddressGroups"` +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/model_ipaddressgroup.go b/resource-manager/cdn/2024-09-01/edgenodes/model_ipaddressgroup.go new file mode 100644 index 00000000000..0736eeabf64 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/model_ipaddressgroup.go @@ -0,0 +1,10 @@ +package edgenodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressGroup struct { + DeliveryRegion *string `json:"deliveryRegion,omitempty"` + IPv4Addresses *[]CidrIPAddress `json:"ipv4Addresses,omitempty"` + IPv6Addresses *[]CidrIPAddress `json:"ipv6Addresses,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/edgenodes/predicates.go b/resource-manager/cdn/2024-09-01/edgenodes/predicates.go new file mode 100644 index 00000000000..db221c0d1b6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/predicates.go @@ -0,0 +1,27 @@ +package edgenodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EdgeNodeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p EdgeNodeOperationPredicate) Matches(input EdgeNode) 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/cdn/2024-09-01/edgenodes/version.go b/resource-manager/cdn/2024-09-01/edgenodes/version.go new file mode 100644 index 00000000000..237a8728ea5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/edgenodes/version.go @@ -0,0 +1,10 @@ +package edgenodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/edgenodes/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/README.md b/resource-manager/cdn/2024-09-01/endpoints/README.md new file mode 100644 index 00000000000..0e819c36267 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/README.md @@ -0,0 +1,195 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/endpoints` Documentation + +The `endpoints` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/endpoints" +``` + + +### Client Initialization + +```go +client := endpoints.NewEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EndpointsClient.Create` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +payload := endpoints.Endpoint{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Delete` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Get` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +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: `EndpointsClient.ListByProfile` + +```go +ctx := context.TODO() +id := endpoints.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `EndpointsClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `EndpointsClient.LoadContent` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +payload := endpoints.LoadParameters{ + // ... +} + + +if err := client.LoadContentThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.PurgeContent` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +payload := endpoints.PurgeParameters{ + // ... +} + + +if err := client.PurgeContentThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Start` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Stop` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Update` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +payload := endpoints.EndpointUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.ValidateCustomDomain` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +payload := endpoints.ValidateCustomDomainInput{ + // ... +} + + +read, err := client.ValidateCustomDomain(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/endpoints/client.go b/resource-manager/cdn/2024-09-01/endpoints/client.go new file mode 100644 index 00000000000..754a364cd33 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/client.go @@ -0,0 +1,26 @@ +package endpoints + +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 EndpointsClient struct { + Client *resourcemanager.Client +} + +func NewEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*EndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "endpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EndpointsClient: %+v", err) + } + + return &EndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/constants.go b/resource-manager/cdn/2024-09-01/endpoints/constants.go new file mode 100644 index 00000000000..489637e32e3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/constants.go @@ -0,0 +1,2629 @@ +package endpoints + +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 Algorithm string + +const ( + AlgorithmSHATwoFiveSix Algorithm = "SHA256" +) + +func PossibleValuesForAlgorithm() []string { + return []string{ + string(AlgorithmSHATwoFiveSix), + } +} + +func (s *Algorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlgorithm(input string) (*Algorithm, error) { + vals := map[string]Algorithm{ + "sha256": AlgorithmSHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Algorithm(input) + return &out, nil +} + +type CacheBehavior string + +const ( + CacheBehaviorBypassCache CacheBehavior = "BypassCache" + CacheBehaviorOverride CacheBehavior = "Override" + CacheBehaviorSetIfMissing CacheBehavior = "SetIfMissing" +) + +func PossibleValuesForCacheBehavior() []string { + return []string{ + string(CacheBehaviorBypassCache), + string(CacheBehaviorOverride), + string(CacheBehaviorSetIfMissing), + } +} + +func (s *CacheBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCacheBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCacheBehavior(input string) (*CacheBehavior, error) { + vals := map[string]CacheBehavior{ + "bypasscache": CacheBehaviorBypassCache, + "override": CacheBehaviorOverride, + "setifmissing": CacheBehaviorSetIfMissing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CacheBehavior(input) + return &out, nil +} + +type CacheType string + +const ( + CacheTypeAll CacheType = "All" +) + +func PossibleValuesForCacheType() []string { + return []string{ + string(CacheTypeAll), + } +} + +func (s *CacheType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCacheType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCacheType(input string) (*CacheType, error) { + vals := map[string]CacheType{ + "all": CacheTypeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CacheType(input) + return &out, nil +} + +type ClientPortOperator string + +const ( + ClientPortOperatorAny ClientPortOperator = "Any" + ClientPortOperatorBeginsWith ClientPortOperator = "BeginsWith" + ClientPortOperatorContains ClientPortOperator = "Contains" + ClientPortOperatorEndsWith ClientPortOperator = "EndsWith" + ClientPortOperatorEqual ClientPortOperator = "Equal" + ClientPortOperatorGreaterThan ClientPortOperator = "GreaterThan" + ClientPortOperatorGreaterThanOrEqual ClientPortOperator = "GreaterThanOrEqual" + ClientPortOperatorLessThan ClientPortOperator = "LessThan" + ClientPortOperatorLessThanOrEqual ClientPortOperator = "LessThanOrEqual" + ClientPortOperatorRegEx ClientPortOperator = "RegEx" +) + +func PossibleValuesForClientPortOperator() []string { + return []string{ + string(ClientPortOperatorAny), + string(ClientPortOperatorBeginsWith), + string(ClientPortOperatorContains), + string(ClientPortOperatorEndsWith), + string(ClientPortOperatorEqual), + string(ClientPortOperatorGreaterThan), + string(ClientPortOperatorGreaterThanOrEqual), + string(ClientPortOperatorLessThan), + string(ClientPortOperatorLessThanOrEqual), + string(ClientPortOperatorRegEx), + } +} + +func (s *ClientPortOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientPortOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientPortOperator(input string) (*ClientPortOperator, error) { + vals := map[string]ClientPortOperator{ + "any": ClientPortOperatorAny, + "beginswith": ClientPortOperatorBeginsWith, + "contains": ClientPortOperatorContains, + "endswith": ClientPortOperatorEndsWith, + "equal": ClientPortOperatorEqual, + "greaterthan": ClientPortOperatorGreaterThan, + "greaterthanorequal": ClientPortOperatorGreaterThanOrEqual, + "lessthan": ClientPortOperatorLessThan, + "lessthanorequal": ClientPortOperatorLessThanOrEqual, + "regex": ClientPortOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientPortOperator(input) + return &out, nil +} + +type CookiesOperator string + +const ( + CookiesOperatorAny CookiesOperator = "Any" + CookiesOperatorBeginsWith CookiesOperator = "BeginsWith" + CookiesOperatorContains CookiesOperator = "Contains" + CookiesOperatorEndsWith CookiesOperator = "EndsWith" + CookiesOperatorEqual CookiesOperator = "Equal" + CookiesOperatorGreaterThan CookiesOperator = "GreaterThan" + CookiesOperatorGreaterThanOrEqual CookiesOperator = "GreaterThanOrEqual" + CookiesOperatorLessThan CookiesOperator = "LessThan" + CookiesOperatorLessThanOrEqual CookiesOperator = "LessThanOrEqual" + CookiesOperatorRegEx CookiesOperator = "RegEx" +) + +func PossibleValuesForCookiesOperator() []string { + return []string{ + string(CookiesOperatorAny), + string(CookiesOperatorBeginsWith), + string(CookiesOperatorContains), + string(CookiesOperatorEndsWith), + string(CookiesOperatorEqual), + string(CookiesOperatorGreaterThan), + string(CookiesOperatorGreaterThanOrEqual), + string(CookiesOperatorLessThan), + string(CookiesOperatorLessThanOrEqual), + string(CookiesOperatorRegEx), + } +} + +func (s *CookiesOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookiesOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookiesOperator(input string) (*CookiesOperator, error) { + vals := map[string]CookiesOperator{ + "any": CookiesOperatorAny, + "beginswith": CookiesOperatorBeginsWith, + "contains": CookiesOperatorContains, + "endswith": CookiesOperatorEndsWith, + "equal": CookiesOperatorEqual, + "greaterthan": CookiesOperatorGreaterThan, + "greaterthanorequal": CookiesOperatorGreaterThanOrEqual, + "lessthan": CookiesOperatorLessThan, + "lessthanorequal": CookiesOperatorLessThanOrEqual, + "regex": CookiesOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookiesOperator(input) + return &out, nil +} + +type DeliveryRuleActionName string + +const ( + DeliveryRuleActionNameCacheExpiration DeliveryRuleActionName = "CacheExpiration" + DeliveryRuleActionNameCacheKeyQueryString DeliveryRuleActionName = "CacheKeyQueryString" + DeliveryRuleActionNameModifyRequestHeader DeliveryRuleActionName = "ModifyRequestHeader" + DeliveryRuleActionNameModifyResponseHeader DeliveryRuleActionName = "ModifyResponseHeader" + DeliveryRuleActionNameOriginGroupOverride DeliveryRuleActionName = "OriginGroupOverride" + DeliveryRuleActionNameRouteConfigurationOverride DeliveryRuleActionName = "RouteConfigurationOverride" + DeliveryRuleActionNameURLRedirect DeliveryRuleActionName = "UrlRedirect" + DeliveryRuleActionNameURLRewrite DeliveryRuleActionName = "UrlRewrite" + DeliveryRuleActionNameURLSigning DeliveryRuleActionName = "UrlSigning" +) + +func PossibleValuesForDeliveryRuleActionName() []string { + return []string{ + string(DeliveryRuleActionNameCacheExpiration), + string(DeliveryRuleActionNameCacheKeyQueryString), + string(DeliveryRuleActionNameModifyRequestHeader), + string(DeliveryRuleActionNameModifyResponseHeader), + string(DeliveryRuleActionNameOriginGroupOverride), + string(DeliveryRuleActionNameRouteConfigurationOverride), + string(DeliveryRuleActionNameURLRedirect), + string(DeliveryRuleActionNameURLRewrite), + string(DeliveryRuleActionNameURLSigning), + } +} + +func (s *DeliveryRuleActionName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleActionName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleActionName(input string) (*DeliveryRuleActionName, error) { + vals := map[string]DeliveryRuleActionName{ + "cacheexpiration": DeliveryRuleActionNameCacheExpiration, + "cachekeyquerystring": DeliveryRuleActionNameCacheKeyQueryString, + "modifyrequestheader": DeliveryRuleActionNameModifyRequestHeader, + "modifyresponseheader": DeliveryRuleActionNameModifyResponseHeader, + "origingroupoverride": DeliveryRuleActionNameOriginGroupOverride, + "routeconfigurationoverride": DeliveryRuleActionNameRouteConfigurationOverride, + "urlredirect": DeliveryRuleActionNameURLRedirect, + "urlrewrite": DeliveryRuleActionNameURLRewrite, + "urlsigning": DeliveryRuleActionNameURLSigning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleActionName(input) + return &out, nil +} + +type DeliveryRuleActionParametersType string + +const ( + DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters DeliveryRuleActionParametersType = "DeliveryRuleCacheExpirationActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters DeliveryRuleActionParametersType = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters DeliveryRuleActionParametersType = "DeliveryRuleHeaderActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters DeliveryRuleActionParametersType = "DeliveryRuleOriginGroupOverrideActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters DeliveryRuleActionParametersType = "DeliveryRuleRouteConfigurationOverrideActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlRedirectActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlRewriteActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlSigningActionParameters" +) + +func PossibleValuesForDeliveryRuleActionParametersType() []string { + return []string{ + string(DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters), + } +} + +func (s *DeliveryRuleActionParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleActionParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleActionParametersType(input string) (*DeliveryRuleActionParametersType, error) { + vals := map[string]DeliveryRuleActionParametersType{ + "deliveryrulecacheexpirationactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters, + "deliveryrulecachekeyquerystringbehavioractionparameters": DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters, + "deliveryruleheaderactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters, + "deliveryruleorigingroupoverrideactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters, + "deliveryrulerouteconfigurationoverrideactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters, + "deliveryruleurlredirectactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters, + "deliveryruleurlrewriteactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters, + "deliveryruleurlsigningactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleActionParametersType(input) + return &out, nil +} + +type DeliveryRuleConditionParametersType string + +const ( + DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleClientPortConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleCookiesConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleHttpVersionConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleHostNameConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleIsDeviceConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters DeliveryRuleConditionParametersType = "DeliveryRulePostArgsConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleQueryStringConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRemoteAddressConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestBodyConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestHeaderConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestMethodConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestSchemeConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestUriConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleServerPortConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleSocketAddrConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleSslProtocolConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlFilenameConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlPathMatchConditionParameters" +) + +func PossibleValuesForDeliveryRuleConditionParametersType() []string { + return []string{ + string(DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters), + } +} + +func (s *DeliveryRuleConditionParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleConditionParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleConditionParametersType(input string) (*DeliveryRuleConditionParametersType, error) { + vals := map[string]DeliveryRuleConditionParametersType{ + "deliveryruleclientportconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters, + "deliveryrulecookiesconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters, + "deliveryrulehttpversionconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters, + "deliveryrulehostnameconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters, + "deliveryruleisdeviceconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters, + "deliveryrulepostargsconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters, + "deliveryrulequerystringconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters, + "deliveryruleremoteaddressconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters, + "deliveryrulerequestbodyconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters, + "deliveryrulerequestheaderconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters, + "deliveryrulerequestmethodconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters, + "deliveryrulerequestschemeconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters, + "deliveryrulerequesturiconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters, + "deliveryruleserverportconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters, + "deliveryrulesocketaddrconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters, + "deliveryrulesslprotocolconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters, + "deliveryruleurlfileextensionmatchconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters, + "deliveryruleurlfilenameconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters, + "deliveryruleurlpathmatchconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleConditionParametersType(input) + return &out, nil +} + +type DestinationProtocol string + +const ( + DestinationProtocolHTTP DestinationProtocol = "Http" + DestinationProtocolHTTPS DestinationProtocol = "Https" + DestinationProtocolMatchRequest DestinationProtocol = "MatchRequest" +) + +func PossibleValuesForDestinationProtocol() []string { + return []string{ + string(DestinationProtocolHTTP), + string(DestinationProtocolHTTPS), + string(DestinationProtocolMatchRequest), + } +} + +func (s *DestinationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDestinationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDestinationProtocol(input string) (*DestinationProtocol, error) { + vals := map[string]DestinationProtocol{ + "http": DestinationProtocolHTTP, + "https": DestinationProtocolHTTPS, + "matchrequest": DestinationProtocolMatchRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DestinationProtocol(input) + return &out, nil +} + +type EndpointProvisioningState string + +const ( + EndpointProvisioningStateCreating EndpointProvisioningState = "Creating" + EndpointProvisioningStateDeleting EndpointProvisioningState = "Deleting" + EndpointProvisioningStateFailed EndpointProvisioningState = "Failed" + EndpointProvisioningStateSucceeded EndpointProvisioningState = "Succeeded" + EndpointProvisioningStateUpdating EndpointProvisioningState = "Updating" +) + +func PossibleValuesForEndpointProvisioningState() []string { + return []string{ + string(EndpointProvisioningStateCreating), + string(EndpointProvisioningStateDeleting), + string(EndpointProvisioningStateFailed), + string(EndpointProvisioningStateSucceeded), + string(EndpointProvisioningStateUpdating), + } +} + +func (s *EndpointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointProvisioningState(input string) (*EndpointProvisioningState, error) { + vals := map[string]EndpointProvisioningState{ + "creating": EndpointProvisioningStateCreating, + "deleting": EndpointProvisioningStateDeleting, + "failed": EndpointProvisioningStateFailed, + "succeeded": EndpointProvisioningStateSucceeded, + "updating": EndpointProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointProvisioningState(input) + return &out, nil +} + +type EndpointResourceState string + +const ( + EndpointResourceStateCreating EndpointResourceState = "Creating" + EndpointResourceStateDeleting EndpointResourceState = "Deleting" + EndpointResourceStateRunning EndpointResourceState = "Running" + EndpointResourceStateStarting EndpointResourceState = "Starting" + EndpointResourceStateStopped EndpointResourceState = "Stopped" + EndpointResourceStateStopping EndpointResourceState = "Stopping" +) + +func PossibleValuesForEndpointResourceState() []string { + return []string{ + string(EndpointResourceStateCreating), + string(EndpointResourceStateDeleting), + string(EndpointResourceStateRunning), + string(EndpointResourceStateStarting), + string(EndpointResourceStateStopped), + string(EndpointResourceStateStopping), + } +} + +func (s *EndpointResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointResourceState(input string) (*EndpointResourceState, error) { + vals := map[string]EndpointResourceState{ + "creating": EndpointResourceStateCreating, + "deleting": EndpointResourceStateDeleting, + "running": EndpointResourceStateRunning, + "starting": EndpointResourceStateStarting, + "stopped": EndpointResourceStateStopped, + "stopping": EndpointResourceStateStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointResourceState(input) + return &out, nil +} + +type ForwardingProtocol string + +const ( + ForwardingProtocolHTTPOnly ForwardingProtocol = "HttpOnly" + ForwardingProtocolHTTPSOnly ForwardingProtocol = "HttpsOnly" + ForwardingProtocolMatchRequest ForwardingProtocol = "MatchRequest" +) + +func PossibleValuesForForwardingProtocol() []string { + return []string{ + string(ForwardingProtocolHTTPOnly), + string(ForwardingProtocolHTTPSOnly), + string(ForwardingProtocolMatchRequest), + } +} + +func (s *ForwardingProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardingProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardingProtocol(input string) (*ForwardingProtocol, error) { + vals := map[string]ForwardingProtocol{ + "httponly": ForwardingProtocolHTTPOnly, + "httpsonly": ForwardingProtocolHTTPSOnly, + "matchrequest": ForwardingProtocolMatchRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardingProtocol(input) + return &out, nil +} + +type GeoFilterActions string + +const ( + GeoFilterActionsAllow GeoFilterActions = "Allow" + GeoFilterActionsBlock GeoFilterActions = "Block" +) + +func PossibleValuesForGeoFilterActions() []string { + return []string{ + string(GeoFilterActionsAllow), + string(GeoFilterActionsBlock), + } +} + +func (s *GeoFilterActions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoFilterActions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeoFilterActions(input string) (*GeoFilterActions, error) { + vals := map[string]GeoFilterActions{ + "allow": GeoFilterActionsAllow, + "block": GeoFilterActionsBlock, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GeoFilterActions(input) + return &out, nil +} + +type HTTPVersionOperator string + +const ( + HTTPVersionOperatorEqual HTTPVersionOperator = "Equal" +) + +func PossibleValuesForHTTPVersionOperator() []string { + return []string{ + string(HTTPVersionOperatorEqual), + } +} + +func (s *HTTPVersionOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPVersionOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHTTPVersionOperator(input string) (*HTTPVersionOperator, error) { + vals := map[string]HTTPVersionOperator{ + "equal": HTTPVersionOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HTTPVersionOperator(input) + return &out, nil +} + +type HeaderAction string + +const ( + HeaderActionAppend HeaderAction = "Append" + HeaderActionDelete HeaderAction = "Delete" + HeaderActionOverwrite HeaderAction = "Overwrite" +) + +func PossibleValuesForHeaderAction() []string { + return []string{ + string(HeaderActionAppend), + string(HeaderActionDelete), + string(HeaderActionOverwrite), + } +} + +func (s *HeaderAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHeaderAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHeaderAction(input string) (*HeaderAction, error) { + vals := map[string]HeaderAction{ + "append": HeaderActionAppend, + "delete": HeaderActionDelete, + "overwrite": HeaderActionOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HeaderAction(input) + return &out, nil +} + +type HealthProbeRequestType string + +const ( + HealthProbeRequestTypeGET HealthProbeRequestType = "GET" + HealthProbeRequestTypeHEAD HealthProbeRequestType = "HEAD" + HealthProbeRequestTypeNotSet HealthProbeRequestType = "NotSet" +) + +func PossibleValuesForHealthProbeRequestType() []string { + return []string{ + string(HealthProbeRequestTypeGET), + string(HealthProbeRequestTypeHEAD), + string(HealthProbeRequestTypeNotSet), + } +} + +func (s *HealthProbeRequestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthProbeRequestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthProbeRequestType(input string) (*HealthProbeRequestType, error) { + vals := map[string]HealthProbeRequestType{ + "get": HealthProbeRequestTypeGET, + "head": HealthProbeRequestTypeHEAD, + "notset": HealthProbeRequestTypeNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthProbeRequestType(input) + return &out, nil +} + +type HostNameOperator string + +const ( + HostNameOperatorAny HostNameOperator = "Any" + HostNameOperatorBeginsWith HostNameOperator = "BeginsWith" + HostNameOperatorContains HostNameOperator = "Contains" + HostNameOperatorEndsWith HostNameOperator = "EndsWith" + HostNameOperatorEqual HostNameOperator = "Equal" + HostNameOperatorGreaterThan HostNameOperator = "GreaterThan" + HostNameOperatorGreaterThanOrEqual HostNameOperator = "GreaterThanOrEqual" + HostNameOperatorLessThan HostNameOperator = "LessThan" + HostNameOperatorLessThanOrEqual HostNameOperator = "LessThanOrEqual" + HostNameOperatorRegEx HostNameOperator = "RegEx" +) + +func PossibleValuesForHostNameOperator() []string { + return []string{ + string(HostNameOperatorAny), + string(HostNameOperatorBeginsWith), + string(HostNameOperatorContains), + string(HostNameOperatorEndsWith), + string(HostNameOperatorEqual), + string(HostNameOperatorGreaterThan), + string(HostNameOperatorGreaterThanOrEqual), + string(HostNameOperatorLessThan), + string(HostNameOperatorLessThanOrEqual), + string(HostNameOperatorRegEx), + } +} + +func (s *HostNameOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameOperator(input string) (*HostNameOperator, error) { + vals := map[string]HostNameOperator{ + "any": HostNameOperatorAny, + "beginswith": HostNameOperatorBeginsWith, + "contains": HostNameOperatorContains, + "endswith": HostNameOperatorEndsWith, + "equal": HostNameOperatorEqual, + "greaterthan": HostNameOperatorGreaterThan, + "greaterthanorequal": HostNameOperatorGreaterThanOrEqual, + "lessthan": HostNameOperatorLessThan, + "lessthanorequal": HostNameOperatorLessThanOrEqual, + "regex": HostNameOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameOperator(input) + return &out, nil +} + +type IsDeviceMatchValue string + +const ( + IsDeviceMatchValueDesktop IsDeviceMatchValue = "Desktop" + IsDeviceMatchValueMobile IsDeviceMatchValue = "Mobile" +) + +func PossibleValuesForIsDeviceMatchValue() []string { + return []string{ + string(IsDeviceMatchValueDesktop), + string(IsDeviceMatchValueMobile), + } +} + +func (s *IsDeviceMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDeviceMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsDeviceMatchValue(input string) (*IsDeviceMatchValue, error) { + vals := map[string]IsDeviceMatchValue{ + "desktop": IsDeviceMatchValueDesktop, + "mobile": IsDeviceMatchValueMobile, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsDeviceMatchValue(input) + return &out, nil +} + +type IsDeviceOperator string + +const ( + IsDeviceOperatorEqual IsDeviceOperator = "Equal" +) + +func PossibleValuesForIsDeviceOperator() []string { + return []string{ + string(IsDeviceOperatorEqual), + } +} + +func (s *IsDeviceOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDeviceOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsDeviceOperator(input string) (*IsDeviceOperator, error) { + vals := map[string]IsDeviceOperator{ + "equal": IsDeviceOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsDeviceOperator(input) + return &out, nil +} + +type KeyVaultSigningKeyParametersType string + +const ( + KeyVaultSigningKeyParametersTypeKeyVaultSigningKeyParameters KeyVaultSigningKeyParametersType = "KeyVaultSigningKeyParameters" +) + +func PossibleValuesForKeyVaultSigningKeyParametersType() []string { + return []string{ + string(KeyVaultSigningKeyParametersTypeKeyVaultSigningKeyParameters), + } +} + +func (s *KeyVaultSigningKeyParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSigningKeyParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSigningKeyParametersType(input string) (*KeyVaultSigningKeyParametersType, error) { + vals := map[string]KeyVaultSigningKeyParametersType{ + "keyvaultsigningkeyparameters": KeyVaultSigningKeyParametersTypeKeyVaultSigningKeyParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSigningKeyParametersType(input) + return &out, nil +} + +type MatchVariable string + +const ( + MatchVariableClientPort MatchVariable = "ClientPort" + MatchVariableCookies MatchVariable = "Cookies" + MatchVariableHTTPVersion MatchVariable = "HttpVersion" + MatchVariableHostName MatchVariable = "HostName" + MatchVariableIsDevice MatchVariable = "IsDevice" + MatchVariablePostArgs MatchVariable = "PostArgs" + MatchVariableQueryString MatchVariable = "QueryString" + MatchVariableRemoteAddress MatchVariable = "RemoteAddress" + MatchVariableRequestBody MatchVariable = "RequestBody" + MatchVariableRequestHeader MatchVariable = "RequestHeader" + MatchVariableRequestMethod MatchVariable = "RequestMethod" + MatchVariableRequestScheme MatchVariable = "RequestScheme" + MatchVariableRequestUri MatchVariable = "RequestUri" + MatchVariableServerPort MatchVariable = "ServerPort" + MatchVariableSocketAddr MatchVariable = "SocketAddr" + MatchVariableSslProtocol MatchVariable = "SslProtocol" + MatchVariableURLFileExtension MatchVariable = "UrlFileExtension" + MatchVariableURLFileName MatchVariable = "UrlFileName" + MatchVariableURLPath MatchVariable = "UrlPath" +) + +func PossibleValuesForMatchVariable() []string { + return []string{ + string(MatchVariableClientPort), + string(MatchVariableCookies), + string(MatchVariableHTTPVersion), + string(MatchVariableHostName), + string(MatchVariableIsDevice), + string(MatchVariablePostArgs), + string(MatchVariableQueryString), + string(MatchVariableRemoteAddress), + string(MatchVariableRequestBody), + string(MatchVariableRequestHeader), + string(MatchVariableRequestMethod), + string(MatchVariableRequestScheme), + string(MatchVariableRequestUri), + string(MatchVariableServerPort), + string(MatchVariableSocketAddr), + string(MatchVariableSslProtocol), + string(MatchVariableURLFileExtension), + string(MatchVariableURLFileName), + string(MatchVariableURLPath), + } +} + +func (s *MatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMatchVariable(input string) (*MatchVariable, error) { + vals := map[string]MatchVariable{ + "clientport": MatchVariableClientPort, + "cookies": MatchVariableCookies, + "httpversion": MatchVariableHTTPVersion, + "hostname": MatchVariableHostName, + "isdevice": MatchVariableIsDevice, + "postargs": MatchVariablePostArgs, + "querystring": MatchVariableQueryString, + "remoteaddress": MatchVariableRemoteAddress, + "requestbody": MatchVariableRequestBody, + "requestheader": MatchVariableRequestHeader, + "requestmethod": MatchVariableRequestMethod, + "requestscheme": MatchVariableRequestScheme, + "requesturi": MatchVariableRequestUri, + "serverport": MatchVariableServerPort, + "socketaddr": MatchVariableSocketAddr, + "sslprotocol": MatchVariableSslProtocol, + "urlfileextension": MatchVariableURLFileExtension, + "urlfilename": MatchVariableURLFileName, + "urlpath": MatchVariableURLPath, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MatchVariable(input) + return &out, nil +} + +type Operator string + +const ( + OperatorEqual Operator = "Equal" +) + +func PossibleValuesForOperator() []string { + return []string{ + string(OperatorEqual), + } +} + +func (s *Operator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperator(input string) (*Operator, error) { + vals := map[string]Operator{ + "equal": OperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Operator(input) + return &out, nil +} + +type OptimizationType string + +const ( + OptimizationTypeDynamicSiteAcceleration OptimizationType = "DynamicSiteAcceleration" + OptimizationTypeGeneralMediaStreaming OptimizationType = "GeneralMediaStreaming" + OptimizationTypeGeneralWebDelivery OptimizationType = "GeneralWebDelivery" + OptimizationTypeLargeFileDownload OptimizationType = "LargeFileDownload" + OptimizationTypeVideoOnDemandMediaStreaming OptimizationType = "VideoOnDemandMediaStreaming" +) + +func PossibleValuesForOptimizationType() []string { + return []string{ + string(OptimizationTypeDynamicSiteAcceleration), + string(OptimizationTypeGeneralMediaStreaming), + string(OptimizationTypeGeneralWebDelivery), + string(OptimizationTypeLargeFileDownload), + string(OptimizationTypeVideoOnDemandMediaStreaming), + } +} + +func (s *OptimizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOptimizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOptimizationType(input string) (*OptimizationType, error) { + vals := map[string]OptimizationType{ + "dynamicsiteacceleration": OptimizationTypeDynamicSiteAcceleration, + "generalmediastreaming": OptimizationTypeGeneralMediaStreaming, + "generalwebdelivery": OptimizationTypeGeneralWebDelivery, + "largefiledownload": OptimizationTypeLargeFileDownload, + "videoondemandmediastreaming": OptimizationTypeVideoOnDemandMediaStreaming, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OptimizationType(input) + return &out, nil +} + +type ParamIndicator string + +const ( + ParamIndicatorExpires ParamIndicator = "Expires" + ParamIndicatorKeyId ParamIndicator = "KeyId" + ParamIndicatorSignature ParamIndicator = "Signature" +) + +func PossibleValuesForParamIndicator() []string { + return []string{ + string(ParamIndicatorExpires), + string(ParamIndicatorKeyId), + string(ParamIndicatorSignature), + } +} + +func (s *ParamIndicator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParamIndicator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParamIndicator(input string) (*ParamIndicator, error) { + vals := map[string]ParamIndicator{ + "expires": ParamIndicatorExpires, + "keyid": ParamIndicatorKeyId, + "signature": ParamIndicatorSignature, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParamIndicator(input) + return &out, nil +} + +type PostArgsOperator string + +const ( + PostArgsOperatorAny PostArgsOperator = "Any" + PostArgsOperatorBeginsWith PostArgsOperator = "BeginsWith" + PostArgsOperatorContains PostArgsOperator = "Contains" + PostArgsOperatorEndsWith PostArgsOperator = "EndsWith" + PostArgsOperatorEqual PostArgsOperator = "Equal" + PostArgsOperatorGreaterThan PostArgsOperator = "GreaterThan" + PostArgsOperatorGreaterThanOrEqual PostArgsOperator = "GreaterThanOrEqual" + PostArgsOperatorLessThan PostArgsOperator = "LessThan" + PostArgsOperatorLessThanOrEqual PostArgsOperator = "LessThanOrEqual" + PostArgsOperatorRegEx PostArgsOperator = "RegEx" +) + +func PossibleValuesForPostArgsOperator() []string { + return []string{ + string(PostArgsOperatorAny), + string(PostArgsOperatorBeginsWith), + string(PostArgsOperatorContains), + string(PostArgsOperatorEndsWith), + string(PostArgsOperatorEqual), + string(PostArgsOperatorGreaterThan), + string(PostArgsOperatorGreaterThanOrEqual), + string(PostArgsOperatorLessThan), + string(PostArgsOperatorLessThanOrEqual), + string(PostArgsOperatorRegEx), + } +} + +func (s *PostArgsOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePostArgsOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePostArgsOperator(input string) (*PostArgsOperator, error) { + vals := map[string]PostArgsOperator{ + "any": PostArgsOperatorAny, + "beginswith": PostArgsOperatorBeginsWith, + "contains": PostArgsOperatorContains, + "endswith": PostArgsOperatorEndsWith, + "equal": PostArgsOperatorEqual, + "greaterthan": PostArgsOperatorGreaterThan, + "greaterthanorequal": PostArgsOperatorGreaterThanOrEqual, + "lessthan": PostArgsOperatorLessThan, + "lessthanorequal": PostArgsOperatorLessThanOrEqual, + "regex": PostArgsOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PostArgsOperator(input) + return &out, nil +} + +type PrivateEndpointStatus string + +const ( + PrivateEndpointStatusApproved PrivateEndpointStatus = "Approved" + PrivateEndpointStatusDisconnected PrivateEndpointStatus = "Disconnected" + PrivateEndpointStatusPending PrivateEndpointStatus = "Pending" + PrivateEndpointStatusRejected PrivateEndpointStatus = "Rejected" + PrivateEndpointStatusTimeout PrivateEndpointStatus = "Timeout" +) + +func PossibleValuesForPrivateEndpointStatus() []string { + return []string{ + string(PrivateEndpointStatusApproved), + string(PrivateEndpointStatusDisconnected), + string(PrivateEndpointStatusPending), + string(PrivateEndpointStatusRejected), + string(PrivateEndpointStatusTimeout), + } +} + +func (s *PrivateEndpointStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointStatus(input string) (*PrivateEndpointStatus, error) { + vals := map[string]PrivateEndpointStatus{ + "approved": PrivateEndpointStatusApproved, + "disconnected": PrivateEndpointStatusDisconnected, + "pending": PrivateEndpointStatusPending, + "rejected": PrivateEndpointStatusRejected, + "timeout": PrivateEndpointStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointStatus(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "Http" + ProbeProtocolHTTPS ProbeProtocol = "Https" + ProbeProtocolNotSet ProbeProtocol = "NotSet" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolNotSet), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "notset": ProbeProtocolNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type QueryStringBehavior string + +const ( + QueryStringBehaviorExclude QueryStringBehavior = "Exclude" + QueryStringBehaviorExcludeAll QueryStringBehavior = "ExcludeAll" + QueryStringBehaviorInclude QueryStringBehavior = "Include" + QueryStringBehaviorIncludeAll QueryStringBehavior = "IncludeAll" +) + +func PossibleValuesForQueryStringBehavior() []string { + return []string{ + string(QueryStringBehaviorExclude), + string(QueryStringBehaviorExcludeAll), + string(QueryStringBehaviorInclude), + string(QueryStringBehaviorIncludeAll), + } +} + +func (s *QueryStringBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryStringBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryStringBehavior(input string) (*QueryStringBehavior, error) { + vals := map[string]QueryStringBehavior{ + "exclude": QueryStringBehaviorExclude, + "excludeall": QueryStringBehaviorExcludeAll, + "include": QueryStringBehaviorInclude, + "includeall": QueryStringBehaviorIncludeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryStringBehavior(input) + return &out, nil +} + +type QueryStringCachingBehavior string + +const ( + QueryStringCachingBehaviorBypassCaching QueryStringCachingBehavior = "BypassCaching" + QueryStringCachingBehaviorIgnoreQueryString QueryStringCachingBehavior = "IgnoreQueryString" + QueryStringCachingBehaviorNotSet QueryStringCachingBehavior = "NotSet" + QueryStringCachingBehaviorUseQueryString QueryStringCachingBehavior = "UseQueryString" +) + +func PossibleValuesForQueryStringCachingBehavior() []string { + return []string{ + string(QueryStringCachingBehaviorBypassCaching), + string(QueryStringCachingBehaviorIgnoreQueryString), + string(QueryStringCachingBehaviorNotSet), + string(QueryStringCachingBehaviorUseQueryString), + } +} + +func (s *QueryStringCachingBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryStringCachingBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryStringCachingBehavior(input string) (*QueryStringCachingBehavior, error) { + vals := map[string]QueryStringCachingBehavior{ + "bypasscaching": QueryStringCachingBehaviorBypassCaching, + "ignorequerystring": QueryStringCachingBehaviorIgnoreQueryString, + "notset": QueryStringCachingBehaviorNotSet, + "usequerystring": QueryStringCachingBehaviorUseQueryString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryStringCachingBehavior(input) + return &out, nil +} + +type QueryStringOperator string + +const ( + QueryStringOperatorAny QueryStringOperator = "Any" + QueryStringOperatorBeginsWith QueryStringOperator = "BeginsWith" + QueryStringOperatorContains QueryStringOperator = "Contains" + QueryStringOperatorEndsWith QueryStringOperator = "EndsWith" + QueryStringOperatorEqual QueryStringOperator = "Equal" + QueryStringOperatorGreaterThan QueryStringOperator = "GreaterThan" + QueryStringOperatorGreaterThanOrEqual QueryStringOperator = "GreaterThanOrEqual" + QueryStringOperatorLessThan QueryStringOperator = "LessThan" + QueryStringOperatorLessThanOrEqual QueryStringOperator = "LessThanOrEqual" + QueryStringOperatorRegEx QueryStringOperator = "RegEx" +) + +func PossibleValuesForQueryStringOperator() []string { + return []string{ + string(QueryStringOperatorAny), + string(QueryStringOperatorBeginsWith), + string(QueryStringOperatorContains), + string(QueryStringOperatorEndsWith), + string(QueryStringOperatorEqual), + string(QueryStringOperatorGreaterThan), + string(QueryStringOperatorGreaterThanOrEqual), + string(QueryStringOperatorLessThan), + string(QueryStringOperatorLessThanOrEqual), + string(QueryStringOperatorRegEx), + } +} + +func (s *QueryStringOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryStringOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryStringOperator(input string) (*QueryStringOperator, error) { + vals := map[string]QueryStringOperator{ + "any": QueryStringOperatorAny, + "beginswith": QueryStringOperatorBeginsWith, + "contains": QueryStringOperatorContains, + "endswith": QueryStringOperatorEndsWith, + "equal": QueryStringOperatorEqual, + "greaterthan": QueryStringOperatorGreaterThan, + "greaterthanorequal": QueryStringOperatorGreaterThanOrEqual, + "lessthan": QueryStringOperatorLessThan, + "lessthanorequal": QueryStringOperatorLessThanOrEqual, + "regex": QueryStringOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryStringOperator(input) + return &out, nil +} + +type RedirectType string + +const ( + RedirectTypeFound RedirectType = "Found" + RedirectTypeMoved RedirectType = "Moved" + RedirectTypePermanentRedirect RedirectType = "PermanentRedirect" + RedirectTypeTemporaryRedirect RedirectType = "TemporaryRedirect" +) + +func PossibleValuesForRedirectType() []string { + return []string{ + string(RedirectTypeFound), + string(RedirectTypeMoved), + string(RedirectTypePermanentRedirect), + string(RedirectTypeTemporaryRedirect), + } +} + +func (s *RedirectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedirectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedirectType(input string) (*RedirectType, error) { + vals := map[string]RedirectType{ + "found": RedirectTypeFound, + "moved": RedirectTypeMoved, + "permanentredirect": RedirectTypePermanentRedirect, + "temporaryredirect": RedirectTypeTemporaryRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedirectType(input) + return &out, nil +} + +type RemoteAddressOperator string + +const ( + RemoteAddressOperatorAny RemoteAddressOperator = "Any" + RemoteAddressOperatorGeoMatch RemoteAddressOperator = "GeoMatch" + RemoteAddressOperatorIPMatch RemoteAddressOperator = "IPMatch" +) + +func PossibleValuesForRemoteAddressOperator() []string { + return []string{ + string(RemoteAddressOperatorAny), + string(RemoteAddressOperatorGeoMatch), + string(RemoteAddressOperatorIPMatch), + } +} + +func (s *RemoteAddressOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteAddressOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteAddressOperator(input string) (*RemoteAddressOperator, error) { + vals := map[string]RemoteAddressOperator{ + "any": RemoteAddressOperatorAny, + "geomatch": RemoteAddressOperatorGeoMatch, + "ipmatch": RemoteAddressOperatorIPMatch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteAddressOperator(input) + return &out, nil +} + +type RequestBodyOperator string + +const ( + RequestBodyOperatorAny RequestBodyOperator = "Any" + RequestBodyOperatorBeginsWith RequestBodyOperator = "BeginsWith" + RequestBodyOperatorContains RequestBodyOperator = "Contains" + RequestBodyOperatorEndsWith RequestBodyOperator = "EndsWith" + RequestBodyOperatorEqual RequestBodyOperator = "Equal" + RequestBodyOperatorGreaterThan RequestBodyOperator = "GreaterThan" + RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = "GreaterThanOrEqual" + RequestBodyOperatorLessThan RequestBodyOperator = "LessThan" + RequestBodyOperatorLessThanOrEqual RequestBodyOperator = "LessThanOrEqual" + RequestBodyOperatorRegEx RequestBodyOperator = "RegEx" +) + +func PossibleValuesForRequestBodyOperator() []string { + return []string{ + string(RequestBodyOperatorAny), + string(RequestBodyOperatorBeginsWith), + string(RequestBodyOperatorContains), + string(RequestBodyOperatorEndsWith), + string(RequestBodyOperatorEqual), + string(RequestBodyOperatorGreaterThan), + string(RequestBodyOperatorGreaterThanOrEqual), + string(RequestBodyOperatorLessThan), + string(RequestBodyOperatorLessThanOrEqual), + string(RequestBodyOperatorRegEx), + } +} + +func (s *RequestBodyOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestBodyOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestBodyOperator(input string) (*RequestBodyOperator, error) { + vals := map[string]RequestBodyOperator{ + "any": RequestBodyOperatorAny, + "beginswith": RequestBodyOperatorBeginsWith, + "contains": RequestBodyOperatorContains, + "endswith": RequestBodyOperatorEndsWith, + "equal": RequestBodyOperatorEqual, + "greaterthan": RequestBodyOperatorGreaterThan, + "greaterthanorequal": RequestBodyOperatorGreaterThanOrEqual, + "lessthan": RequestBodyOperatorLessThan, + "lessthanorequal": RequestBodyOperatorLessThanOrEqual, + "regex": RequestBodyOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestBodyOperator(input) + return &out, nil +} + +type RequestHeaderOperator string + +const ( + RequestHeaderOperatorAny RequestHeaderOperator = "Any" + RequestHeaderOperatorBeginsWith RequestHeaderOperator = "BeginsWith" + RequestHeaderOperatorContains RequestHeaderOperator = "Contains" + RequestHeaderOperatorEndsWith RequestHeaderOperator = "EndsWith" + RequestHeaderOperatorEqual RequestHeaderOperator = "Equal" + RequestHeaderOperatorGreaterThan RequestHeaderOperator = "GreaterThan" + RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = "GreaterThanOrEqual" + RequestHeaderOperatorLessThan RequestHeaderOperator = "LessThan" + RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = "LessThanOrEqual" + RequestHeaderOperatorRegEx RequestHeaderOperator = "RegEx" +) + +func PossibleValuesForRequestHeaderOperator() []string { + return []string{ + string(RequestHeaderOperatorAny), + string(RequestHeaderOperatorBeginsWith), + string(RequestHeaderOperatorContains), + string(RequestHeaderOperatorEndsWith), + string(RequestHeaderOperatorEqual), + string(RequestHeaderOperatorGreaterThan), + string(RequestHeaderOperatorGreaterThanOrEqual), + string(RequestHeaderOperatorLessThan), + string(RequestHeaderOperatorLessThanOrEqual), + string(RequestHeaderOperatorRegEx), + } +} + +func (s *RequestHeaderOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestHeaderOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestHeaderOperator(input string) (*RequestHeaderOperator, error) { + vals := map[string]RequestHeaderOperator{ + "any": RequestHeaderOperatorAny, + "beginswith": RequestHeaderOperatorBeginsWith, + "contains": RequestHeaderOperatorContains, + "endswith": RequestHeaderOperatorEndsWith, + "equal": RequestHeaderOperatorEqual, + "greaterthan": RequestHeaderOperatorGreaterThan, + "greaterthanorequal": RequestHeaderOperatorGreaterThanOrEqual, + "lessthan": RequestHeaderOperatorLessThan, + "lessthanorequal": RequestHeaderOperatorLessThanOrEqual, + "regex": RequestHeaderOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestHeaderOperator(input) + return &out, nil +} + +type RequestMethodMatchValue string + +const ( + RequestMethodMatchValueDELETE RequestMethodMatchValue = "DELETE" + RequestMethodMatchValueGET RequestMethodMatchValue = "GET" + RequestMethodMatchValueHEAD RequestMethodMatchValue = "HEAD" + RequestMethodMatchValueOPTIONS RequestMethodMatchValue = "OPTIONS" + RequestMethodMatchValuePOST RequestMethodMatchValue = "POST" + RequestMethodMatchValuePUT RequestMethodMatchValue = "PUT" + RequestMethodMatchValueTRACE RequestMethodMatchValue = "TRACE" +) + +func PossibleValuesForRequestMethodMatchValue() []string { + return []string{ + string(RequestMethodMatchValueDELETE), + string(RequestMethodMatchValueGET), + string(RequestMethodMatchValueHEAD), + string(RequestMethodMatchValueOPTIONS), + string(RequestMethodMatchValuePOST), + string(RequestMethodMatchValuePUT), + string(RequestMethodMatchValueTRACE), + } +} + +func (s *RequestMethodMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestMethodMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestMethodMatchValue(input string) (*RequestMethodMatchValue, error) { + vals := map[string]RequestMethodMatchValue{ + "delete": RequestMethodMatchValueDELETE, + "get": RequestMethodMatchValueGET, + "head": RequestMethodMatchValueHEAD, + "options": RequestMethodMatchValueOPTIONS, + "post": RequestMethodMatchValuePOST, + "put": RequestMethodMatchValuePUT, + "trace": RequestMethodMatchValueTRACE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestMethodMatchValue(input) + return &out, nil +} + +type RequestMethodOperator string + +const ( + RequestMethodOperatorEqual RequestMethodOperator = "Equal" +) + +func PossibleValuesForRequestMethodOperator() []string { + return []string{ + string(RequestMethodOperatorEqual), + } +} + +func (s *RequestMethodOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestMethodOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestMethodOperator(input string) (*RequestMethodOperator, error) { + vals := map[string]RequestMethodOperator{ + "equal": RequestMethodOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestMethodOperator(input) + return &out, nil +} + +type RequestSchemeMatchValue string + +const ( + RequestSchemeMatchValueHTTP RequestSchemeMatchValue = "HTTP" + RequestSchemeMatchValueHTTPS RequestSchemeMatchValue = "HTTPS" +) + +func PossibleValuesForRequestSchemeMatchValue() []string { + return []string{ + string(RequestSchemeMatchValueHTTP), + string(RequestSchemeMatchValueHTTPS), + } +} + +func (s *RequestSchemeMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestSchemeMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestSchemeMatchValue(input string) (*RequestSchemeMatchValue, error) { + vals := map[string]RequestSchemeMatchValue{ + "http": RequestSchemeMatchValueHTTP, + "https": RequestSchemeMatchValueHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestSchemeMatchValue(input) + return &out, nil +} + +type RequestUriOperator string + +const ( + RequestUriOperatorAny RequestUriOperator = "Any" + RequestUriOperatorBeginsWith RequestUriOperator = "BeginsWith" + RequestUriOperatorContains RequestUriOperator = "Contains" + RequestUriOperatorEndsWith RequestUriOperator = "EndsWith" + RequestUriOperatorEqual RequestUriOperator = "Equal" + RequestUriOperatorGreaterThan RequestUriOperator = "GreaterThan" + RequestUriOperatorGreaterThanOrEqual RequestUriOperator = "GreaterThanOrEqual" + RequestUriOperatorLessThan RequestUriOperator = "LessThan" + RequestUriOperatorLessThanOrEqual RequestUriOperator = "LessThanOrEqual" + RequestUriOperatorRegEx RequestUriOperator = "RegEx" +) + +func PossibleValuesForRequestUriOperator() []string { + return []string{ + string(RequestUriOperatorAny), + string(RequestUriOperatorBeginsWith), + string(RequestUriOperatorContains), + string(RequestUriOperatorEndsWith), + string(RequestUriOperatorEqual), + string(RequestUriOperatorGreaterThan), + string(RequestUriOperatorGreaterThanOrEqual), + string(RequestUriOperatorLessThan), + string(RequestUriOperatorLessThanOrEqual), + string(RequestUriOperatorRegEx), + } +} + +func (s *RequestUriOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestUriOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestUriOperator(input string) (*RequestUriOperator, error) { + vals := map[string]RequestUriOperator{ + "any": RequestUriOperatorAny, + "beginswith": RequestUriOperatorBeginsWith, + "contains": RequestUriOperatorContains, + "endswith": RequestUriOperatorEndsWith, + "equal": RequestUriOperatorEqual, + "greaterthan": RequestUriOperatorGreaterThan, + "greaterthanorequal": RequestUriOperatorGreaterThanOrEqual, + "lessthan": RequestUriOperatorLessThan, + "lessthanorequal": RequestUriOperatorLessThanOrEqual, + "regex": RequestUriOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestUriOperator(input) + return &out, nil +} + +type ResourceUsageUnit string + +const ( + ResourceUsageUnitCount ResourceUsageUnit = "count" +) + +func PossibleValuesForResourceUsageUnit() []string { + return []string{ + string(ResourceUsageUnitCount), + } +} + +func (s *ResourceUsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceUsageUnit(input string) (*ResourceUsageUnit, error) { + vals := map[string]ResourceUsageUnit{ + "count": ResourceUsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceUsageUnit(input) + return &out, nil +} + +type ResponseBasedDetectedErrorTypes string + +const ( + ResponseBasedDetectedErrorTypesNone ResponseBasedDetectedErrorTypes = "None" + ResponseBasedDetectedErrorTypesTcpAndHTTPErrors ResponseBasedDetectedErrorTypes = "TcpAndHttpErrors" + ResponseBasedDetectedErrorTypesTcpErrorsOnly ResponseBasedDetectedErrorTypes = "TcpErrorsOnly" +) + +func PossibleValuesForResponseBasedDetectedErrorTypes() []string { + return []string{ + string(ResponseBasedDetectedErrorTypesNone), + string(ResponseBasedDetectedErrorTypesTcpAndHTTPErrors), + string(ResponseBasedDetectedErrorTypesTcpErrorsOnly), + } +} + +func (s *ResponseBasedDetectedErrorTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResponseBasedDetectedErrorTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResponseBasedDetectedErrorTypes(input string) (*ResponseBasedDetectedErrorTypes, error) { + vals := map[string]ResponseBasedDetectedErrorTypes{ + "none": ResponseBasedDetectedErrorTypesNone, + "tcpandhttperrors": ResponseBasedDetectedErrorTypesTcpAndHTTPErrors, + "tcperrorsonly": ResponseBasedDetectedErrorTypesTcpErrorsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResponseBasedDetectedErrorTypes(input) + return &out, nil +} + +type RuleCacheBehavior string + +const ( + RuleCacheBehaviorHonorOrigin RuleCacheBehavior = "HonorOrigin" + RuleCacheBehaviorOverrideAlways RuleCacheBehavior = "OverrideAlways" + RuleCacheBehaviorOverrideIfOriginMissing RuleCacheBehavior = "OverrideIfOriginMissing" +) + +func PossibleValuesForRuleCacheBehavior() []string { + return []string{ + string(RuleCacheBehaviorHonorOrigin), + string(RuleCacheBehaviorOverrideAlways), + string(RuleCacheBehaviorOverrideIfOriginMissing), + } +} + +func (s *RuleCacheBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleCacheBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleCacheBehavior(input string) (*RuleCacheBehavior, error) { + vals := map[string]RuleCacheBehavior{ + "honororigin": RuleCacheBehaviorHonorOrigin, + "overridealways": RuleCacheBehaviorOverrideAlways, + "overrideiforiginmissing": RuleCacheBehaviorOverrideIfOriginMissing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleCacheBehavior(input) + return &out, nil +} + +type RuleIsCompressionEnabled string + +const ( + RuleIsCompressionEnabledDisabled RuleIsCompressionEnabled = "Disabled" + RuleIsCompressionEnabledEnabled RuleIsCompressionEnabled = "Enabled" +) + +func PossibleValuesForRuleIsCompressionEnabled() []string { + return []string{ + string(RuleIsCompressionEnabledDisabled), + string(RuleIsCompressionEnabledEnabled), + } +} + +func (s *RuleIsCompressionEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleIsCompressionEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleIsCompressionEnabled(input string) (*RuleIsCompressionEnabled, error) { + vals := map[string]RuleIsCompressionEnabled{ + "disabled": RuleIsCompressionEnabledDisabled, + "enabled": RuleIsCompressionEnabledEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleIsCompressionEnabled(input) + return &out, nil +} + +type RuleQueryStringCachingBehavior string + +const ( + RuleQueryStringCachingBehaviorIgnoreQueryString RuleQueryStringCachingBehavior = "IgnoreQueryString" + RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings RuleQueryStringCachingBehavior = "IgnoreSpecifiedQueryStrings" + RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings RuleQueryStringCachingBehavior = "IncludeSpecifiedQueryStrings" + RuleQueryStringCachingBehaviorUseQueryString RuleQueryStringCachingBehavior = "UseQueryString" +) + +func PossibleValuesForRuleQueryStringCachingBehavior() []string { + return []string{ + string(RuleQueryStringCachingBehaviorIgnoreQueryString), + string(RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings), + string(RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings), + string(RuleQueryStringCachingBehaviorUseQueryString), + } +} + +func (s *RuleQueryStringCachingBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleQueryStringCachingBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleQueryStringCachingBehavior(input string) (*RuleQueryStringCachingBehavior, error) { + vals := map[string]RuleQueryStringCachingBehavior{ + "ignorequerystring": RuleQueryStringCachingBehaviorIgnoreQueryString, + "ignorespecifiedquerystrings": RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings, + "includespecifiedquerystrings": RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings, + "usequerystring": RuleQueryStringCachingBehaviorUseQueryString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleQueryStringCachingBehavior(input) + return &out, nil +} + +type ServerPortOperator string + +const ( + ServerPortOperatorAny ServerPortOperator = "Any" + ServerPortOperatorBeginsWith ServerPortOperator = "BeginsWith" + ServerPortOperatorContains ServerPortOperator = "Contains" + ServerPortOperatorEndsWith ServerPortOperator = "EndsWith" + ServerPortOperatorEqual ServerPortOperator = "Equal" + ServerPortOperatorGreaterThan ServerPortOperator = "GreaterThan" + ServerPortOperatorGreaterThanOrEqual ServerPortOperator = "GreaterThanOrEqual" + ServerPortOperatorLessThan ServerPortOperator = "LessThan" + ServerPortOperatorLessThanOrEqual ServerPortOperator = "LessThanOrEqual" + ServerPortOperatorRegEx ServerPortOperator = "RegEx" +) + +func PossibleValuesForServerPortOperator() []string { + return []string{ + string(ServerPortOperatorAny), + string(ServerPortOperatorBeginsWith), + string(ServerPortOperatorContains), + string(ServerPortOperatorEndsWith), + string(ServerPortOperatorEqual), + string(ServerPortOperatorGreaterThan), + string(ServerPortOperatorGreaterThanOrEqual), + string(ServerPortOperatorLessThan), + string(ServerPortOperatorLessThanOrEqual), + string(ServerPortOperatorRegEx), + } +} + +func (s *ServerPortOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerPortOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerPortOperator(input string) (*ServerPortOperator, error) { + vals := map[string]ServerPortOperator{ + "any": ServerPortOperatorAny, + "beginswith": ServerPortOperatorBeginsWith, + "contains": ServerPortOperatorContains, + "endswith": ServerPortOperatorEndsWith, + "equal": ServerPortOperatorEqual, + "greaterthan": ServerPortOperatorGreaterThan, + "greaterthanorequal": ServerPortOperatorGreaterThanOrEqual, + "lessthan": ServerPortOperatorLessThan, + "lessthanorequal": ServerPortOperatorLessThanOrEqual, + "regex": ServerPortOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerPortOperator(input) + return &out, nil +} + +type SocketAddrOperator string + +const ( + SocketAddrOperatorAny SocketAddrOperator = "Any" + SocketAddrOperatorIPMatch SocketAddrOperator = "IPMatch" +) + +func PossibleValuesForSocketAddrOperator() []string { + return []string{ + string(SocketAddrOperatorAny), + string(SocketAddrOperatorIPMatch), + } +} + +func (s *SocketAddrOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSocketAddrOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSocketAddrOperator(input string) (*SocketAddrOperator, error) { + vals := map[string]SocketAddrOperator{ + "any": SocketAddrOperatorAny, + "ipmatch": SocketAddrOperatorIPMatch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SocketAddrOperator(input) + return &out, nil +} + +type SslProtocol string + +const ( + SslProtocolTLSvOne SslProtocol = "TLSv1" + SslProtocolTLSvOnePointOne SslProtocol = "TLSv1.1" + SslProtocolTLSvOnePointTwo SslProtocol = "TLSv1.2" +) + +func PossibleValuesForSslProtocol() []string { + return []string{ + string(SslProtocolTLSvOne), + string(SslProtocolTLSvOnePointOne), + string(SslProtocolTLSvOnePointTwo), + } +} + +func (s *SslProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslProtocol(input string) (*SslProtocol, error) { + vals := map[string]SslProtocol{ + "tlsv1": SslProtocolTLSvOne, + "tlsv1.1": SslProtocolTLSvOnePointOne, + "tlsv1.2": SslProtocolTLSvOnePointTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslProtocol(input) + return &out, nil +} + +type SslProtocolOperator string + +const ( + SslProtocolOperatorEqual SslProtocolOperator = "Equal" +) + +func PossibleValuesForSslProtocolOperator() []string { + return []string{ + string(SslProtocolOperatorEqual), + } +} + +func (s *SslProtocolOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslProtocolOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslProtocolOperator(input string) (*SslProtocolOperator, error) { + vals := map[string]SslProtocolOperator{ + "equal": SslProtocolOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslProtocolOperator(input) + return &out, nil +} + +type Transform string + +const ( + TransformLowercase Transform = "Lowercase" + TransformRemoveNulls Transform = "RemoveNulls" + TransformTrim Transform = "Trim" + TransformURLDecode Transform = "UrlDecode" + TransformURLEncode Transform = "UrlEncode" + TransformUppercase Transform = "Uppercase" +) + +func PossibleValuesForTransform() []string { + return []string{ + string(TransformLowercase), + string(TransformRemoveNulls), + string(TransformTrim), + string(TransformURLDecode), + string(TransformURLEncode), + string(TransformUppercase), + } +} + +func (s *Transform) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransform(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransform(input string) (*Transform, error) { + vals := map[string]Transform{ + "lowercase": TransformLowercase, + "removenulls": TransformRemoveNulls, + "trim": TransformTrim, + "urldecode": TransformURLDecode, + "urlencode": TransformURLEncode, + "uppercase": TransformUppercase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Transform(input) + return &out, nil +} + +type URLFileExtensionOperator string + +const ( + URLFileExtensionOperatorAny URLFileExtensionOperator = "Any" + URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = "BeginsWith" + URLFileExtensionOperatorContains URLFileExtensionOperator = "Contains" + URLFileExtensionOperatorEndsWith URLFileExtensionOperator = "EndsWith" + URLFileExtensionOperatorEqual URLFileExtensionOperator = "Equal" + URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = "GreaterThan" + URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = "GreaterThanOrEqual" + URLFileExtensionOperatorLessThan URLFileExtensionOperator = "LessThan" + URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = "LessThanOrEqual" + URLFileExtensionOperatorRegEx URLFileExtensionOperator = "RegEx" +) + +func PossibleValuesForURLFileExtensionOperator() []string { + return []string{ + string(URLFileExtensionOperatorAny), + string(URLFileExtensionOperatorBeginsWith), + string(URLFileExtensionOperatorContains), + string(URLFileExtensionOperatorEndsWith), + string(URLFileExtensionOperatorEqual), + string(URLFileExtensionOperatorGreaterThan), + string(URLFileExtensionOperatorGreaterThanOrEqual), + string(URLFileExtensionOperatorLessThan), + string(URLFileExtensionOperatorLessThanOrEqual), + string(URLFileExtensionOperatorRegEx), + } +} + +func (s *URLFileExtensionOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLFileExtensionOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLFileExtensionOperator(input string) (*URLFileExtensionOperator, error) { + vals := map[string]URLFileExtensionOperator{ + "any": URLFileExtensionOperatorAny, + "beginswith": URLFileExtensionOperatorBeginsWith, + "contains": URLFileExtensionOperatorContains, + "endswith": URLFileExtensionOperatorEndsWith, + "equal": URLFileExtensionOperatorEqual, + "greaterthan": URLFileExtensionOperatorGreaterThan, + "greaterthanorequal": URLFileExtensionOperatorGreaterThanOrEqual, + "lessthan": URLFileExtensionOperatorLessThan, + "lessthanorequal": URLFileExtensionOperatorLessThanOrEqual, + "regex": URLFileExtensionOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLFileExtensionOperator(input) + return &out, nil +} + +type URLFileNameOperator string + +const ( + URLFileNameOperatorAny URLFileNameOperator = "Any" + URLFileNameOperatorBeginsWith URLFileNameOperator = "BeginsWith" + URLFileNameOperatorContains URLFileNameOperator = "Contains" + URLFileNameOperatorEndsWith URLFileNameOperator = "EndsWith" + URLFileNameOperatorEqual URLFileNameOperator = "Equal" + URLFileNameOperatorGreaterThan URLFileNameOperator = "GreaterThan" + URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = "GreaterThanOrEqual" + URLFileNameOperatorLessThan URLFileNameOperator = "LessThan" + URLFileNameOperatorLessThanOrEqual URLFileNameOperator = "LessThanOrEqual" + URLFileNameOperatorRegEx URLFileNameOperator = "RegEx" +) + +func PossibleValuesForURLFileNameOperator() []string { + return []string{ + string(URLFileNameOperatorAny), + string(URLFileNameOperatorBeginsWith), + string(URLFileNameOperatorContains), + string(URLFileNameOperatorEndsWith), + string(URLFileNameOperatorEqual), + string(URLFileNameOperatorGreaterThan), + string(URLFileNameOperatorGreaterThanOrEqual), + string(URLFileNameOperatorLessThan), + string(URLFileNameOperatorLessThanOrEqual), + string(URLFileNameOperatorRegEx), + } +} + +func (s *URLFileNameOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLFileNameOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLFileNameOperator(input string) (*URLFileNameOperator, error) { + vals := map[string]URLFileNameOperator{ + "any": URLFileNameOperatorAny, + "beginswith": URLFileNameOperatorBeginsWith, + "contains": URLFileNameOperatorContains, + "endswith": URLFileNameOperatorEndsWith, + "equal": URLFileNameOperatorEqual, + "greaterthan": URLFileNameOperatorGreaterThan, + "greaterthanorequal": URLFileNameOperatorGreaterThanOrEqual, + "lessthan": URLFileNameOperatorLessThan, + "lessthanorequal": URLFileNameOperatorLessThanOrEqual, + "regex": URLFileNameOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLFileNameOperator(input) + return &out, nil +} + +type URLPathOperator string + +const ( + URLPathOperatorAny URLPathOperator = "Any" + URLPathOperatorBeginsWith URLPathOperator = "BeginsWith" + URLPathOperatorContains URLPathOperator = "Contains" + URLPathOperatorEndsWith URLPathOperator = "EndsWith" + URLPathOperatorEqual URLPathOperator = "Equal" + URLPathOperatorGreaterThan URLPathOperator = "GreaterThan" + URLPathOperatorGreaterThanOrEqual URLPathOperator = "GreaterThanOrEqual" + URLPathOperatorLessThan URLPathOperator = "LessThan" + URLPathOperatorLessThanOrEqual URLPathOperator = "LessThanOrEqual" + URLPathOperatorRegEx URLPathOperator = "RegEx" + URLPathOperatorWildcard URLPathOperator = "Wildcard" +) + +func PossibleValuesForURLPathOperator() []string { + return []string{ + string(URLPathOperatorAny), + string(URLPathOperatorBeginsWith), + string(URLPathOperatorContains), + string(URLPathOperatorEndsWith), + string(URLPathOperatorEqual), + string(URLPathOperatorGreaterThan), + string(URLPathOperatorGreaterThanOrEqual), + string(URLPathOperatorLessThan), + string(URLPathOperatorLessThanOrEqual), + string(URLPathOperatorRegEx), + string(URLPathOperatorWildcard), + } +} + +func (s *URLPathOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLPathOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLPathOperator(input string) (*URLPathOperator, error) { + vals := map[string]URLPathOperator{ + "any": URLPathOperatorAny, + "beginswith": URLPathOperatorBeginsWith, + "contains": URLPathOperatorContains, + "endswith": URLPathOperatorEndsWith, + "equal": URLPathOperatorEqual, + "greaterthan": URLPathOperatorGreaterThan, + "greaterthanorequal": URLPathOperatorGreaterThanOrEqual, + "lessthan": URLPathOperatorLessThan, + "lessthanorequal": URLPathOperatorLessThanOrEqual, + "regex": URLPathOperatorRegEx, + "wildcard": URLPathOperatorWildcard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLPathOperator(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/id_endpoint.go b/resource-manager/cdn/2024-09-01/endpoints/id_endpoint.go new file mode 100644 index 00000000000..8a9834bf7cb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/id_endpoint.go @@ -0,0 +1,139 @@ +package endpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointId{}) +} + +var _ resourceids.ResourceId = &EndpointId{} + +// EndpointId is a struct representing the Resource ID for a Endpoint +type EndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string +} + +// NewEndpointID returns a new EndpointId struct +func NewEndpointID(subscriptionId string, resourceGroupName string, profileName string, endpointName string) EndpointId { + return EndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + } +} + +// ParseEndpointID parses 'input' into a EndpointId +func ParseEndpointID(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId +// note: this method should only be used for API response data and not user input +func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + return nil +} + +// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID +func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint ID +func (id EndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID +func (id EndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + } +} + +// String returns a human-readable description of this Endpoint ID +func (id EndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + } + return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/id_endpoint_test.go b/resource-manager/cdn/2024-09-01/endpoints/id_endpoint_test.go new file mode 100644 index 00000000000..f43a17e1a36 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/id_endpoint_test.go @@ -0,0 +1,327 @@ +package endpoints + +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 = &EndpointId{} + +func TestNewEndpointID(t *testing.T) { + id := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } +} + +func TestFormatEndpointID(t *testing.T) { + actual := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestParseEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestSegmentsForEndpointId(t *testing.T) { + segments := EndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointId 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/cdn/2024-09-01/endpoints/id_profile.go b/resource-manager/cdn/2024-09-01/endpoints/id_profile.go new file mode 100644 index 00000000000..d2eda294d59 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/id_profile.go @@ -0,0 +1,130 @@ +package endpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/id_profile_test.go b/resource-manager/cdn/2024-09-01/endpoints/id_profile_test.go new file mode 100644 index 00000000000..64c8c048094 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/id_profile_test.go @@ -0,0 +1,282 @@ +package endpoints + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/endpoints/method_create.go b/resource-manager/cdn/2024-09-01/endpoints/method_create.go new file mode 100644 index 00000000000..f5a28f25dec --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_create.go @@ -0,0 +1,76 @@ +package endpoints + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Endpoint +} + +// Create ... +func (c EndpointsClient) Create(ctx context.Context, id EndpointId, input Endpoint) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c EndpointsClient) CreateThenPoll(ctx context.Context, id EndpointId, input Endpoint) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_delete.go b/resource-manager/cdn/2024-09-01/endpoints/method_delete.go new file mode 100644 index 00000000000..466f6bc5065 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_delete.go @@ -0,0 +1,71 @@ +package endpoints + +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 EndpointsClient) Delete(ctx context.Context, id EndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 EndpointsClient) DeleteThenPoll(ctx context.Context, id EndpointId) 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/cdn/2024-09-01/endpoints/method_get.go b/resource-manager/cdn/2024-09-01/endpoints/method_get.go new file mode 100644 index 00000000000..b81e42bd7da --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_get.go @@ -0,0 +1,53 @@ +package endpoints + +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 *Endpoint +} + +// Get ... +func (c EndpointsClient) Get(ctx context.Context, id EndpointId) (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 + } + + var model Endpoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/endpoints/method_listbyprofile.go new file mode 100644 index 00000000000..4cc86b4aa69 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_listbyprofile.go @@ -0,0 +1,105 @@ +package endpoints + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Endpoint +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []Endpoint +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c EndpointsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/endpoints", 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 *[]Endpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c EndpointsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, EndpointOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EndpointsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate EndpointOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]Endpoint, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/endpoints/method_listresourceusage.go new file mode 100644 index 00000000000..31b7829b979 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_listresourceusage.go @@ -0,0 +1,105 @@ +package endpoints + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceUsage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceUsage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c EndpointsClient) ListResourceUsage(ctx context.Context, id EndpointId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/checkResourceUsage", 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 *[]ResourceUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c EndpointsClient) ListResourceUsageComplete(ctx context.Context, id EndpointId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, ResourceUsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EndpointsClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id EndpointId, predicate ResourceUsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]ResourceUsage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_loadcontent.go b/resource-manager/cdn/2024-09-01/endpoints/method_loadcontent.go new file mode 100644 index 00000000000..b1ba0411544 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_loadcontent.go @@ -0,0 +1,74 @@ +package endpoints + +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 LoadContentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// LoadContent ... +func (c EndpointsClient) LoadContent(ctx context.Context, id EndpointId, input LoadParameters) (result LoadContentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/load", 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 +} + +// LoadContentThenPoll performs LoadContent then polls until it's completed +func (c EndpointsClient) LoadContentThenPoll(ctx context.Context, id EndpointId, input LoadParameters) error { + result, err := c.LoadContent(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LoadContent: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LoadContent: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_purgecontent.go b/resource-manager/cdn/2024-09-01/endpoints/method_purgecontent.go new file mode 100644 index 00000000000..075274be601 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_purgecontent.go @@ -0,0 +1,74 @@ +package endpoints + +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 PurgeContentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PurgeContent ... +func (c EndpointsClient) PurgeContent(ctx context.Context, id EndpointId, input PurgeParameters) (result PurgeContentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", 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 +} + +// PurgeContentThenPoll performs PurgeContent then polls until it's completed +func (c EndpointsClient) PurgeContentThenPoll(ctx context.Context, id EndpointId, input PurgeParameters) error { + result, err := c.PurgeContent(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PurgeContent: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PurgeContent: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/method_start.go b/resource-manager/cdn/2024-09-01/endpoints/method_start.go new file mode 100644 index 00000000000..c5c1f2c28a6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_start.go @@ -0,0 +1,71 @@ +package endpoints + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Endpoint +} + +// Start ... +func (c EndpointsClient) Start(ctx context.Context, id EndpointId) (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/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 EndpointsClient) StartThenPoll(ctx context.Context, id EndpointId) 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/cdn/2024-09-01/endpoints/method_stop.go b/resource-manager/cdn/2024-09-01/endpoints/method_stop.go new file mode 100644 index 00000000000..84477fff9db --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_stop.go @@ -0,0 +1,71 @@ +package endpoints + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Endpoint +} + +// Stop ... +func (c EndpointsClient) Stop(ctx context.Context, id EndpointId) (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/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 EndpointsClient) StopThenPoll(ctx context.Context, id EndpointId) 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/cdn/2024-09-01/endpoints/method_update.go b/resource-manager/cdn/2024-09-01/endpoints/method_update.go new file mode 100644 index 00000000000..b61db980e96 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_update.go @@ -0,0 +1,75 @@ +package endpoints + +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 + Model *Endpoint +} + +// Update ... +func (c EndpointsClient) Update(ctx context.Context, id EndpointId, input EndpointUpdateParameters) (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 EndpointsClient) UpdateThenPoll(ctx context.Context, id EndpointId, input EndpointUpdateParameters) 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/cdn/2024-09-01/endpoints/method_validatecustomdomain.go b/resource-manager/cdn/2024-09-01/endpoints/method_validatecustomdomain.go new file mode 100644 index 00000000000..9d585f35d78 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/method_validatecustomdomain.go @@ -0,0 +1,58 @@ +package endpoints + +import ( + "context" + "fmt" + "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 ValidateCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateCustomDomainOutput +} + +// ValidateCustomDomain ... +func (c EndpointsClient) ValidateCustomDomain(ctx context.Context, id EndpointId, input ValidateCustomDomainInput) (result ValidateCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateCustomDomain", 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 + } + + var model ValidateCustomDomainOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_cacheconfiguration.go b/resource-manager/cdn/2024-09-01/endpoints/model_cacheconfiguration.go new file mode 100644 index 00000000000..21f119971ed --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_cacheconfiguration.go @@ -0,0 +1,12 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheConfiguration struct { + CacheBehavior *RuleCacheBehavior `json:"cacheBehavior,omitempty"` + CacheDuration *string `json:"cacheDuration,omitempty"` + IsCompressionEnabled *RuleIsCompressionEnabled `json:"isCompressionEnabled,omitempty"` + QueryParameters *string `json:"queryParameters,omitempty"` + QueryStringCachingBehavior *RuleQueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_cacheexpirationactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_cacheexpirationactionparameters.go new file mode 100644 index 00000000000..d3a3dc2bc48 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_cacheexpirationactionparameters.go @@ -0,0 +1,52 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = CacheExpirationActionParameters{} + +type CacheExpirationActionParameters struct { + CacheBehavior CacheBehavior `json:"cacheBehavior"` + CacheDuration *string `json:"cacheDuration,omitempty"` + CacheType CacheType `json:"cacheType"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s CacheExpirationActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CacheExpirationActionParameters{} + +func (s CacheExpirationActionParameters) MarshalJSON() ([]byte, error) { + type wrapper CacheExpirationActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CacheExpirationActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CacheExpirationActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCacheExpirationActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CacheExpirationActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_cachekeyquerystringactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_cachekeyquerystringactionparameters.go new file mode 100644 index 00000000000..a04c58620d0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_cachekeyquerystringactionparameters.go @@ -0,0 +1,51 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = CacheKeyQueryStringActionParameters{} + +type CacheKeyQueryStringActionParameters struct { + QueryParameters *string `json:"queryParameters,omitempty"` + QueryStringBehavior QueryStringBehavior `json:"queryStringBehavior"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s CacheKeyQueryStringActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CacheKeyQueryStringActionParameters{} + +func (s CacheKeyQueryStringActionParameters) MarshalJSON() ([]byte, error) { + type wrapper CacheKeyQueryStringActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_clientportmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_clientportmatchconditionparameters.go new file mode 100644 index 00000000000..39bfc0ecd8a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_clientportmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = ClientPortMatchConditionParameters{} + +type ClientPortMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator ClientPortOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s ClientPortMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = ClientPortMatchConditionParameters{} + +func (s ClientPortMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper ClientPortMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClientPortMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClientPortMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleClientPortConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClientPortMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_cookiesmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_cookiesmatchconditionparameters.go new file mode 100644 index 00000000000..4ed28470256 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_cookiesmatchconditionparameters.go @@ -0,0 +1,54 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = CookiesMatchConditionParameters{} + +type CookiesMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator CookiesOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s CookiesMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CookiesMatchConditionParameters{} + +func (s CookiesMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper CookiesMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CookiesMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CookiesMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCookiesConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CookiesMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomain.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomain.go new file mode 100644 index 00000000000..ec8b3de7b4b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomain.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedCustomDomain struct { + Name string `json:"name"` + Properties *DeepCreatedCustomDomainProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomainproperties.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomainproperties.go new file mode 100644 index 00000000000..6e671e7d83c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedcustomdomainproperties.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedCustomDomainProperties struct { + HostName string `json:"hostName"` + ValidationData *string `json:"validationData,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigin.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigin.go new file mode 100644 index 00000000000..690b78c5197 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigin.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedOrigin struct { + Name string `json:"name"` + Properties *DeepCreatedOriginProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroup.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroup.go new file mode 100644 index 00000000000..254badd74b7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroup.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedOriginGroup struct { + Name string `json:"name"` + Properties *DeepCreatedOriginGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroupproperties.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroupproperties.go new file mode 100644 index 00000000000..f29aff0fea0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedorigingroupproperties.go @@ -0,0 +1,11 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedOriginGroupProperties struct { + HealthProbeSettings *HealthProbeParameters `json:"healthProbeSettings,omitempty"` + Origins []ResourceReference `json:"origins"` + ResponseBasedOriginErrorDetectionSettings *ResponseBasedOriginErrorDetectionParameters `json:"responseBasedOriginErrorDetectionSettings,omitempty"` + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes *int64 `json:"trafficRestorationTimeToHealedOrNewEndpointsInMinutes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedoriginproperties.go b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedoriginproperties.go new file mode 100644 index 00000000000..71dbdd39e96 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deepcreatedoriginproperties.go @@ -0,0 +1,19 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeepCreatedOriginProperties struct { + Enabled *bool `json:"enabled,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + HostName string `json:"hostName"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + Priority *int64 `json:"priority,omitempty"` + PrivateEndpointStatus *PrivateEndpointStatus `json:"privateEndpointStatus,omitempty"` + PrivateLinkAlias *string `json:"privateLinkAlias,omitempty"` + PrivateLinkApprovalMessage *string `json:"privateLinkApprovalMessage,omitempty"` + PrivateLinkLocation *string `json:"privateLinkLocation,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrule.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrule.go new file mode 100644 index 00000000000..1ff519e4e5d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrule.go @@ -0,0 +1,72 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeliveryRule struct { + Actions []DeliveryRuleAction `json:"actions"` + Conditions *[]DeliveryRuleCondition `json:"conditions,omitempty"` + Name *string `json:"name,omitempty"` + Order int64 `json:"order"` +} + +var _ json.Unmarshaler = &DeliveryRule{} + +func (s *DeliveryRule) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Name *string `json:"name,omitempty"` + Order int64 `json:"order"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Name = decoded.Name + s.Order = decoded.Order + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeliveryRule into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["actions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Actions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleAction, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleActionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Actions' for 'DeliveryRule': %+v", i, err) + } + output = append(output, impl) + } + s.Actions = output + } + + if v, ok := temp["conditions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Conditions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleCondition, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleConditionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Conditions' for 'DeliveryRule': %+v", i, err) + } + output = append(output, impl) + } + s.Conditions = &output + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleaction.go new file mode 100644 index 00000000000..1f623094311 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleaction.go @@ -0,0 +1,139 @@ +package endpoints + +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 DeliveryRuleAction interface { + DeliveryRuleAction() BaseDeliveryRuleActionImpl +} + +var _ DeliveryRuleAction = BaseDeliveryRuleActionImpl{} + +type BaseDeliveryRuleActionImpl struct { + Name DeliveryRuleActionName `json:"name"` +} + +func (s BaseDeliveryRuleActionImpl) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return s +} + +var _ DeliveryRuleAction = RawDeliveryRuleActionImpl{} + +// RawDeliveryRuleActionImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleActionImpl struct { + deliveryRuleAction BaseDeliveryRuleActionImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleActionImpl) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return s.deliveryRuleAction +} + +func UnmarshalDeliveryRuleActionImplementation(input []byte) (DeliveryRuleAction, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleAction into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["name"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CacheExpiration") { + var out DeliveryRuleCacheExpirationAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCacheExpirationAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CacheKeyQueryString") { + var out DeliveryRuleCacheKeyQueryStringAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ModifyRequestHeader") { + var out DeliveryRuleRequestHeaderAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestHeaderAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ModifyResponseHeader") { + var out DeliveryRuleResponseHeaderAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleResponseHeaderAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RouteConfigurationOverride") { + var out DeliveryRuleRouteConfigurationOverrideAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "OriginGroupOverride") { + var out OriginGroupOverrideAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OriginGroupOverrideAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlRedirect") { + var out URLRedirectAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRedirectAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlRewrite") { + var out URLRewriteAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRewriteAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlSigning") { + var out URLSigningAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLSigningAction: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleActionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleActionImpl: %+v", err) + } + + return RawDeliveryRuleActionImpl{ + deliveryRuleAction: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleactionparameters.go new file mode 100644 index 00000000000..e239eb6b31e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleactionparameters.go @@ -0,0 +1,131 @@ +package endpoints + +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 DeliveryRuleActionParameters interface { + DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl +} + +var _ DeliveryRuleActionParameters = BaseDeliveryRuleActionParametersImpl{} + +type BaseDeliveryRuleActionParametersImpl struct { + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s BaseDeliveryRuleActionParametersImpl) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return s +} + +var _ DeliveryRuleActionParameters = RawDeliveryRuleActionParametersImpl{} + +// RawDeliveryRuleActionParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleActionParametersImpl struct { + deliveryRuleActionParameters BaseDeliveryRuleActionParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleActionParametersImpl) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return s.deliveryRuleActionParameters +} + +func UnmarshalDeliveryRuleActionParametersImplementation(input []byte) (DeliveryRuleActionParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleActionParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["typeName"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DeliveryRuleCacheExpirationActionParameters") { + var out CacheExpirationActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CacheExpirationActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters") { + var out CacheKeyQueryStringActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CacheKeyQueryStringActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHeaderActionParameters") { + var out HeaderActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HeaderActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleOriginGroupOverrideActionParameters") { + var out OriginGroupOverrideActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OriginGroupOverrideActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRouteConfigurationOverrideActionParameters") { + var out RouteConfigurationOverrideActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RouteConfigurationOverrideActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlRedirectActionParameters") { + var out URLRedirectActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRedirectActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlRewriteActionParameters") { + var out URLRewriteActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRewriteActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlSigningActionParameters") { + var out URLSigningActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLSigningActionParameters: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleActionParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleActionParametersImpl: %+v", err) + } + + return RawDeliveryRuleActionParametersImpl{ + deliveryRuleActionParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecacheexpirationaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecacheexpirationaction.go new file mode 100644 index 00000000000..254053e11ec --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecacheexpirationaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleCacheExpirationAction{} + +type DeliveryRuleCacheExpirationAction struct { + Parameters CacheExpirationActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleCacheExpirationAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCacheExpirationAction{} + +func (s DeliveryRuleCacheExpirationAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCacheExpirationAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + decoded["name"] = "CacheExpiration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecachekeyquerystringaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecachekeyquerystringaction.go new file mode 100644 index 00000000000..c50984c2481 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecachekeyquerystringaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleCacheKeyQueryStringAction{} + +type DeliveryRuleCacheKeyQueryStringAction struct { + Parameters CacheKeyQueryStringActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleCacheKeyQueryStringAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCacheKeyQueryStringAction{} + +func (s DeliveryRuleCacheKeyQueryStringAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCacheKeyQueryStringAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + decoded["name"] = "CacheKeyQueryString" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleclientportcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleclientportcondition.go new file mode 100644 index 00000000000..d2f98e9677f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleclientportcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleClientPortCondition{} + +type DeliveryRuleClientPortCondition struct { + Parameters ClientPortMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleClientPortCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleClientPortCondition{} + +func (s DeliveryRuleClientPortCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleClientPortCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleClientPortCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleClientPortCondition: %+v", err) + } + + decoded["name"] = "ClientPort" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleClientPortCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecondition.go new file mode 100644 index 00000000000..bf2d6ee9d79 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecondition.go @@ -0,0 +1,219 @@ +package endpoints + +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 DeliveryRuleCondition interface { + DeliveryRuleCondition() BaseDeliveryRuleConditionImpl +} + +var _ DeliveryRuleCondition = BaseDeliveryRuleConditionImpl{} + +type BaseDeliveryRuleConditionImpl struct { + Name MatchVariable `json:"name"` +} + +func (s BaseDeliveryRuleConditionImpl) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return s +} + +var _ DeliveryRuleCondition = RawDeliveryRuleConditionImpl{} + +// RawDeliveryRuleConditionImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleConditionImpl struct { + deliveryRuleCondition BaseDeliveryRuleConditionImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleConditionImpl) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return s.deliveryRuleCondition +} + +func UnmarshalDeliveryRuleConditionImplementation(input []byte) (DeliveryRuleCondition, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCondition into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["name"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ClientPort") { + var out DeliveryRuleClientPortCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleClientPortCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Cookies") { + var out DeliveryRuleCookiesCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCookiesCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HttpVersion") { + var out DeliveryRuleHTTPVersionCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleHTTPVersionCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HostName") { + var out DeliveryRuleHostNameCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleHostNameCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IsDevice") { + var out DeliveryRuleIsDeviceCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleIsDeviceCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PostArgs") { + var out DeliveryRulePostArgsCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRulePostArgsCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "QueryString") { + var out DeliveryRuleQueryStringCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleQueryStringCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RemoteAddress") { + var out DeliveryRuleRemoteAddressCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRemoteAddressCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestBody") { + var out DeliveryRuleRequestBodyCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestBodyCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestHeader") { + var out DeliveryRuleRequestHeaderCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestHeaderCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestMethod") { + var out DeliveryRuleRequestMethodCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestMethodCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestScheme") { + var out DeliveryRuleRequestSchemeCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestSchemeCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestUri") { + var out DeliveryRuleRequestUriCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestUriCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServerPort") { + var out DeliveryRuleServerPortCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleServerPortCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SocketAddr") { + var out DeliveryRuleSocketAddrCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleSocketAddrCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SslProtocol") { + var out DeliveryRuleSslProtocolCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleSslProtocolCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlFileExtension") { + var out DeliveryRuleURLFileExtensionCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLFileExtensionCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlFileName") { + var out DeliveryRuleURLFileNameCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLFileNameCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlPath") { + var out DeliveryRuleURLPathCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLPathCondition: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleConditionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleConditionImpl: %+v", err) + } + + return RawDeliveryRuleConditionImpl{ + deliveryRuleCondition: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleconditionparameters.go new file mode 100644 index 00000000000..0dfb89f8c21 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleconditionparameters.go @@ -0,0 +1,219 @@ +package endpoints + +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 DeliveryRuleConditionParameters interface { + DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl +} + +var _ DeliveryRuleConditionParameters = BaseDeliveryRuleConditionParametersImpl{} + +type BaseDeliveryRuleConditionParametersImpl struct { + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s BaseDeliveryRuleConditionParametersImpl) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return s +} + +var _ DeliveryRuleConditionParameters = RawDeliveryRuleConditionParametersImpl{} + +// RawDeliveryRuleConditionParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleConditionParametersImpl struct { + deliveryRuleConditionParameters BaseDeliveryRuleConditionParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleConditionParametersImpl) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return s.deliveryRuleConditionParameters +} + +func UnmarshalDeliveryRuleConditionParametersImplementation(input []byte) (DeliveryRuleConditionParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleConditionParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["typeName"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DeliveryRuleClientPortConditionParameters") { + var out ClientPortMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClientPortMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleCookiesConditionParameters") { + var out CookiesMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CookiesMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHttpVersionConditionParameters") { + var out HTTPVersionMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HTTPVersionMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHostNameConditionParameters") { + var out HostNameMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HostNameMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleIsDeviceConditionParameters") { + var out IsDeviceMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IsDeviceMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRulePostArgsConditionParameters") { + var out PostArgsMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PostArgsMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleQueryStringConditionParameters") { + var out QueryStringMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into QueryStringMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRemoteAddressConditionParameters") { + var out RemoteAddressMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RemoteAddressMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestBodyConditionParameters") { + var out RequestBodyMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestBodyMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestHeaderConditionParameters") { + var out RequestHeaderMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestHeaderMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestMethodConditionParameters") { + var out RequestMethodMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestMethodMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestSchemeConditionParameters") { + var out RequestSchemeMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestSchemeMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestUriConditionParameters") { + var out RequestUriMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestUriMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleServerPortConditionParameters") { + var out ServerPortMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServerPortMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleSocketAddrConditionParameters") { + var out SocketAddrMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SocketAddrMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleSslProtocolConditionParameters") { + var out SslProtocolMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SslProtocolMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlFileExtensionMatchConditionParameters") { + var out URLFileExtensionMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLFileExtensionMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlFilenameConditionParameters") { + var out URLFileNameMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLFileNameMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlPathMatchConditionParameters") { + var out URLPathMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLPathMatchConditionParameters: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleConditionParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleConditionParametersImpl: %+v", err) + } + + return RawDeliveryRuleConditionParametersImpl{ + deliveryRuleConditionParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecookiescondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecookiescondition.go new file mode 100644 index 00000000000..40445e78379 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulecookiescondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleCookiesCondition{} + +type DeliveryRuleCookiesCondition struct { + Parameters CookiesMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleCookiesCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCookiesCondition{} + +func (s DeliveryRuleCookiesCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCookiesCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCookiesCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCookiesCondition: %+v", err) + } + + decoded["name"] = "Cookies" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCookiesCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehostnamecondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehostnamecondition.go new file mode 100644 index 00000000000..f697d6cfe3d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehostnamecondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleHostNameCondition{} + +type DeliveryRuleHostNameCondition struct { + Parameters HostNameMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleHostNameCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleHostNameCondition{} + +func (s DeliveryRuleHostNameCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleHostNameCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleHostNameCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleHostNameCondition: %+v", err) + } + + decoded["name"] = "HostName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleHostNameCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehttpversioncondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehttpversioncondition.go new file mode 100644 index 00000000000..3f619a9613b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulehttpversioncondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleHTTPVersionCondition{} + +type DeliveryRuleHTTPVersionCondition struct { + Parameters HTTPVersionMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleHTTPVersionCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleHTTPVersionCondition{} + +func (s DeliveryRuleHTTPVersionCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleHTTPVersionCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + decoded["name"] = "HttpVersion" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleisdevicecondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleisdevicecondition.go new file mode 100644 index 00000000000..d491df21148 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleisdevicecondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleIsDeviceCondition{} + +type DeliveryRuleIsDeviceCondition struct { + Parameters IsDeviceMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleIsDeviceCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleIsDeviceCondition{} + +func (s DeliveryRuleIsDeviceCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleIsDeviceCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + decoded["name"] = "IsDevice" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulepostargscondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulepostargscondition.go new file mode 100644 index 00000000000..d9405b44ca7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulepostargscondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRulePostArgsCondition{} + +type DeliveryRulePostArgsCondition struct { + Parameters PostArgsMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRulePostArgsCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRulePostArgsCondition{} + +func (s DeliveryRulePostArgsCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRulePostArgsCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRulePostArgsCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRulePostArgsCondition: %+v", err) + } + + decoded["name"] = "PostArgs" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRulePostArgsCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulequerystringcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulequerystringcondition.go new file mode 100644 index 00000000000..2e0f6b1b798 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulequerystringcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleQueryStringCondition{} + +type DeliveryRuleQueryStringCondition struct { + Parameters QueryStringMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleQueryStringCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleQueryStringCondition{} + +func (s DeliveryRuleQueryStringCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleQueryStringCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + decoded["name"] = "QueryString" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleremoteaddresscondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleremoteaddresscondition.go new file mode 100644 index 00000000000..0f2374f5f2a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleremoteaddresscondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRemoteAddressCondition{} + +type DeliveryRuleRemoteAddressCondition struct { + Parameters RemoteAddressMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRemoteAddressCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRemoteAddressCondition{} + +func (s DeliveryRuleRemoteAddressCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRemoteAddressCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + decoded["name"] = "RemoteAddress" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestbodycondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestbodycondition.go new file mode 100644 index 00000000000..1ad88833bf2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestbodycondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestBodyCondition{} + +type DeliveryRuleRequestBodyCondition struct { + Parameters RequestBodyMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestBodyCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestBodyCondition{} + +func (s DeliveryRuleRequestBodyCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestBodyCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + decoded["name"] = "RequestBody" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheaderaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheaderaction.go new file mode 100644 index 00000000000..7432a3b4eea --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheaderaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleRequestHeaderAction{} + +type DeliveryRuleRequestHeaderAction struct { + Parameters HeaderActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleRequestHeaderAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestHeaderAction{} + +func (s DeliveryRuleRequestHeaderAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestHeaderAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + decoded["name"] = "ModifyRequestHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheadercondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheadercondition.go new file mode 100644 index 00000000000..c19f7f765d2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestheadercondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestHeaderCondition{} + +type DeliveryRuleRequestHeaderCondition struct { + Parameters RequestHeaderMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestHeaderCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestHeaderCondition{} + +func (s DeliveryRuleRequestHeaderCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestHeaderCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + decoded["name"] = "RequestHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestmethodcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestmethodcondition.go new file mode 100644 index 00000000000..beae9e17f39 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestmethodcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestMethodCondition{} + +type DeliveryRuleRequestMethodCondition struct { + Parameters RequestMethodMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestMethodCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestMethodCondition{} + +func (s DeliveryRuleRequestMethodCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestMethodCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + decoded["name"] = "RequestMethod" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestschemecondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestschemecondition.go new file mode 100644 index 00000000000..0b59c0fccc9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequestschemecondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestSchemeCondition{} + +type DeliveryRuleRequestSchemeCondition struct { + Parameters RequestSchemeMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestSchemeCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestSchemeCondition{} + +func (s DeliveryRuleRequestSchemeCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestSchemeCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + decoded["name"] = "RequestScheme" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequesturicondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequesturicondition.go new file mode 100644 index 00000000000..f57742a7df8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerequesturicondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestUriCondition{} + +type DeliveryRuleRequestUriCondition struct { + Parameters RequestUriMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestUriCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestUriCondition{} + +func (s DeliveryRuleRequestUriCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestUriCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + decoded["name"] = "RequestUri" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleresponseheaderaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleresponseheaderaction.go new file mode 100644 index 00000000000..fd59a2b461d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleresponseheaderaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleResponseHeaderAction{} + +type DeliveryRuleResponseHeaderAction struct { + Parameters HeaderActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleResponseHeaderAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleResponseHeaderAction{} + +func (s DeliveryRuleResponseHeaderAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleResponseHeaderAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + decoded["name"] = "ModifyResponseHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerouteconfigurationoverrideaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerouteconfigurationoverrideaction.go new file mode 100644 index 00000000000..58797deab40 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulerouteconfigurationoverrideaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleRouteConfigurationOverrideAction{} + +type DeliveryRuleRouteConfigurationOverrideAction struct { + Parameters RouteConfigurationOverrideActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleRouteConfigurationOverrideAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRouteConfigurationOverrideAction{} + +func (s DeliveryRuleRouteConfigurationOverrideAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRouteConfigurationOverrideAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + decoded["name"] = "RouteConfigurationOverride" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleserverportcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleserverportcondition.go new file mode 100644 index 00000000000..7b1c12f5b1b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleserverportcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleServerPortCondition{} + +type DeliveryRuleServerPortCondition struct { + Parameters ServerPortMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleServerPortCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleServerPortCondition{} + +func (s DeliveryRuleServerPortCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleServerPortCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleServerPortCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleServerPortCondition: %+v", err) + } + + decoded["name"] = "ServerPort" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleServerPortCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesocketaddrcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesocketaddrcondition.go new file mode 100644 index 00000000000..73de4ae88f7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesocketaddrcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleSocketAddrCondition{} + +type DeliveryRuleSocketAddrCondition struct { + Parameters SocketAddrMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleSocketAddrCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleSocketAddrCondition{} + +func (s DeliveryRuleSocketAddrCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleSocketAddrCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + decoded["name"] = "SocketAddr" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesslprotocolcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesslprotocolcondition.go new file mode 100644 index 00000000000..072201f5372 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryrulesslprotocolcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleSslProtocolCondition{} + +type DeliveryRuleSslProtocolCondition struct { + Parameters SslProtocolMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleSslProtocolCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleSslProtocolCondition{} + +func (s DeliveryRuleSslProtocolCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleSslProtocolCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + decoded["name"] = "SslProtocol" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfileextensioncondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfileextensioncondition.go new file mode 100644 index 00000000000..caf12ca2fd7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfileextensioncondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLFileExtensionCondition{} + +type DeliveryRuleURLFileExtensionCondition struct { + Parameters URLFileExtensionMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLFileExtensionCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLFileExtensionCondition{} + +func (s DeliveryRuleURLFileExtensionCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLFileExtensionCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + decoded["name"] = "UrlFileExtension" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfilenamecondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfilenamecondition.go new file mode 100644 index 00000000000..c2c6f61a99d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlfilenamecondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLFileNameCondition{} + +type DeliveryRuleURLFileNameCondition struct { + Parameters URLFileNameMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLFileNameCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLFileNameCondition{} + +func (s DeliveryRuleURLFileNameCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLFileNameCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + decoded["name"] = "UrlFileName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlpathcondition.go b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlpathcondition.go new file mode 100644 index 00000000000..c67b5fa29ac --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_deliveryruleurlpathcondition.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLPathCondition{} + +type DeliveryRuleURLPathCondition struct { + Parameters URLPathMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLPathCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLPathCondition{} + +func (s DeliveryRuleURLPathCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLPathCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLPathCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLPathCondition: %+v", err) + } + + decoded["name"] = "UrlPath" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLPathCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_endpoint.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpoint.go new file mode 100644 index 00000000000..1367b86ec12 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpoint.go @@ -0,0 +1,18 @@ +package endpoints + +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 Endpoint struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *EndpointProperties `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/cdn/2024-09-01/endpoints/model_endpointproperties.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpointproperties.go new file mode 100644 index 00000000000..35d5341712d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpointproperties.go @@ -0,0 +1,27 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointProperties struct { + ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` + CustomDomains *[]DeepCreatedCustomDomain `json:"customDomains,omitempty"` + DefaultOriginGroup *ResourceReference `json:"defaultOriginGroup,omitempty"` + DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` + GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` + HostName *string `json:"hostName,omitempty"` + IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` + IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` + IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` + OptimizationType *OptimizationType `json:"optimizationType,omitempty"` + OriginGroups *[]DeepCreatedOriginGroup `json:"originGroups,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + OriginPath *string `json:"originPath,omitempty"` + Origins []DeepCreatedOrigin `json:"origins"` + ProbePath *string `json:"probePath,omitempty"` + ProvisioningState *EndpointProvisioningState `json:"provisioningState,omitempty"` + QueryStringCachingBehavior *QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` + ResourceState *EndpointResourceState `json:"resourceState,omitempty"` + UrlSigningKeys *[]URLSigningKey `json:"urlSigningKeys,omitempty"` + WebApplicationFirewallPolicyLink *EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink `json:"webApplicationFirewallPolicyLink,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameters.go new file mode 100644 index 00000000000..adb1f260474 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameters.go @@ -0,0 +1,21 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointPropertiesUpdateParameters struct { + ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` + DefaultOriginGroup *ResourceReference `json:"defaultOriginGroup,omitempty"` + DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` + GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` + IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` + IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` + IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` + OptimizationType *OptimizationType `json:"optimizationType,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + OriginPath *string `json:"originPath,omitempty"` + ProbePath *string `json:"probePath,omitempty"` + QueryStringCachingBehavior *QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` + UrlSigningKeys *[]URLSigningKey `json:"urlSigningKeys,omitempty"` + WebApplicationFirewallPolicyLink *EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink `json:"webApplicationFirewallPolicyLink,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparametersdeliverypolicy.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparametersdeliverypolicy.go new file mode 100644 index 00000000000..fc16bce3fc3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparametersdeliverypolicy.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointPropertiesUpdateParametersDeliveryPolicy struct { + Description *string `json:"description,omitempty"` + Rules []DeliveryRule `json:"rules"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameterswebapplicationfirewallpolicylink.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameterswebapplicationfirewallpolicylink.go new file mode 100644 index 00000000000..334f027af8d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpointpropertiesupdateparameterswebapplicationfirewallpolicylink.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_endpointupdateparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_endpointupdateparameters.go new file mode 100644 index 00000000000..8e59a3fc5f8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_endpointupdateparameters.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointUpdateParameters struct { + Properties *EndpointPropertiesUpdateParameters `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_geofilter.go b/resource-manager/cdn/2024-09-01/endpoints/model_geofilter.go new file mode 100644 index 00000000000..245420ec643 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_geofilter.go @@ -0,0 +1,10 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoFilter struct { + Action GeoFilterActions `json:"action"` + CountryCodes []string `json:"countryCodes"` + RelativePath string `json:"relativePath"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_headeractionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_headeractionparameters.go new file mode 100644 index 00000000000..3753776b30a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_headeractionparameters.go @@ -0,0 +1,52 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = HeaderActionParameters{} + +type HeaderActionParameters struct { + HeaderAction HeaderAction `json:"headerAction"` + HeaderName string `json:"headerName"` + Value *string `json:"value,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s HeaderActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HeaderActionParameters{} + +func (s HeaderActionParameters) MarshalJSON() ([]byte, error) { + type wrapper HeaderActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HeaderActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HeaderActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHeaderActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HeaderActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_healthprobeparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_healthprobeparameters.go new file mode 100644 index 00000000000..f7491e35f6a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_healthprobeparameters.go @@ -0,0 +1,11 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthProbeParameters struct { + ProbeIntervalInSeconds *int64 `json:"probeIntervalInSeconds,omitempty"` + ProbePath *string `json:"probePath,omitempty"` + ProbeProtocol *ProbeProtocol `json:"probeProtocol,omitempty"` + ProbeRequestType *HealthProbeRequestType `json:"probeRequestType,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_hostnamematchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_hostnamematchconditionparameters.go new file mode 100644 index 00000000000..ab3ac42a66a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_hostnamematchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = HostNameMatchConditionParameters{} + +type HostNameMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator HostNameOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s HostNameMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HostNameMatchConditionParameters{} + +func (s HostNameMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper HostNameMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HostNameMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HostNameMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHostNameConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HostNameMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_httperrorrangeparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_httperrorrangeparameters.go new file mode 100644 index 00000000000..7ee3f694daa --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_httperrorrangeparameters.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPErrorRangeParameters struct { + Begin *int64 `json:"begin,omitempty"` + End *int64 `json:"end,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_httpversionmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_httpversionmatchconditionparameters.go new file mode 100644 index 00000000000..3e6ff5da2c4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_httpversionmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = HTTPVersionMatchConditionParameters{} + +type HTTPVersionMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator HTTPVersionOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s HTTPVersionMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HTTPVersionMatchConditionParameters{} + +func (s HTTPVersionMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper HTTPVersionMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHttpVersionConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_isdevicematchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_isdevicematchconditionparameters.go new file mode 100644 index 00000000000..d5dc64eb8b4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_isdevicematchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = IsDeviceMatchConditionParameters{} + +type IsDeviceMatchConditionParameters struct { + MatchValues *[]IsDeviceMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator IsDeviceOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s IsDeviceMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = IsDeviceMatchConditionParameters{} + +func (s IsDeviceMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper IsDeviceMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IsDeviceMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IsDeviceMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleIsDeviceConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IsDeviceMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_keyvaultsigningkeyparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_keyvaultsigningkeyparameters.go new file mode 100644 index 00000000000..9c7b3e64eb1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_keyvaultsigningkeyparameters.go @@ -0,0 +1,13 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultSigningKeyParameters struct { + ResourceGroupName string `json:"resourceGroupName"` + SecretName string `json:"secretName"` + SecretVersion string `json:"secretVersion"` + SubscriptionId string `json:"subscriptionId"` + TypeName KeyVaultSigningKeyParametersType `json:"typeName"` + VaultName string `json:"vaultName"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_loadparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_loadparameters.go new file mode 100644 index 00000000000..4ba6766cb34 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_loadparameters.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadParameters struct { + ContentPaths []string `json:"contentPaths"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverride.go b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverride.go new file mode 100644 index 00000000000..e01336f6451 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverride.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupOverride struct { + ForwardingProtocol *ForwardingProtocol `json:"forwardingProtocol,omitempty"` + OriginGroup *ResourceReference `json:"originGroup,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideaction.go new file mode 100644 index 00000000000..48eb25360ed --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = OriginGroupOverrideAction{} + +type OriginGroupOverrideAction struct { + Parameters OriginGroupOverrideActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s OriginGroupOverrideAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = OriginGroupOverrideAction{} + +func (s OriginGroupOverrideAction) MarshalJSON() ([]byte, error) { + type wrapper OriginGroupOverrideAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OriginGroupOverrideAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OriginGroupOverrideAction: %+v", err) + } + + decoded["name"] = "OriginGroupOverride" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OriginGroupOverrideAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideactionparameters.go new file mode 100644 index 00000000000..0a949266e4d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_origingroupoverrideactionparameters.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = OriginGroupOverrideActionParameters{} + +type OriginGroupOverrideActionParameters struct { + OriginGroup ResourceReference `json:"originGroup"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s OriginGroupOverrideActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = OriginGroupOverrideActionParameters{} + +func (s OriginGroupOverrideActionParameters) MarshalJSON() ([]byte, error) { + type wrapper OriginGroupOverrideActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OriginGroupOverrideActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OriginGroupOverrideActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleOriginGroupOverrideActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OriginGroupOverrideActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_postargsmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_postargsmatchconditionparameters.go new file mode 100644 index 00000000000..19dab87e852 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_postargsmatchconditionparameters.go @@ -0,0 +1,54 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = PostArgsMatchConditionParameters{} + +type PostArgsMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator PostArgsOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s PostArgsMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = PostArgsMatchConditionParameters{} + +func (s PostArgsMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper PostArgsMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PostArgsMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PostArgsMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRulePostArgsConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PostArgsMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_purgeparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_purgeparameters.go new file mode 100644 index 00000000000..7df637012d1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_purgeparameters.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeParameters struct { + ContentPaths []string `json:"contentPaths"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_querystringmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_querystringmatchconditionparameters.go new file mode 100644 index 00000000000..fc8bf16d226 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_querystringmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = QueryStringMatchConditionParameters{} + +type QueryStringMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator QueryStringOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s QueryStringMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = QueryStringMatchConditionParameters{} + +func (s QueryStringMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper QueryStringMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling QueryStringMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling QueryStringMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleQueryStringConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling QueryStringMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_remoteaddressmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_remoteaddressmatchconditionparameters.go new file mode 100644 index 00000000000..5c923d39500 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_remoteaddressmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RemoteAddressMatchConditionParameters{} + +type RemoteAddressMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RemoteAddressOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RemoteAddressMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RemoteAddressMatchConditionParameters{} + +func (s RemoteAddressMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RemoteAddressMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRemoteAddressConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_requestbodymatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_requestbodymatchconditionparameters.go new file mode 100644 index 00000000000..3c56322cee3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_requestbodymatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestBodyMatchConditionParameters{} + +type RequestBodyMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestBodyOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestBodyMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestBodyMatchConditionParameters{} + +func (s RequestBodyMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestBodyMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestBodyMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestBodyMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestBodyConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestBodyMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_requestheadermatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_requestheadermatchconditionparameters.go new file mode 100644 index 00000000000..9ab38ac5afb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_requestheadermatchconditionparameters.go @@ -0,0 +1,54 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestHeaderMatchConditionParameters{} + +type RequestHeaderMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestHeaderOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestHeaderMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestHeaderMatchConditionParameters{} + +func (s RequestHeaderMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestHeaderMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestHeaderConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_requestmethodmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_requestmethodmatchconditionparameters.go new file mode 100644 index 00000000000..d2b7b5f6d62 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_requestmethodmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestMethodMatchConditionParameters{} + +type RequestMethodMatchConditionParameters struct { + MatchValues *[]RequestMethodMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestMethodOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestMethodMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestMethodMatchConditionParameters{} + +func (s RequestMethodMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestMethodMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestMethodMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestMethodMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestMethodConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestMethodMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_requestschemematchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_requestschemematchconditionparameters.go new file mode 100644 index 00000000000..f90b69b35bf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_requestschemematchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestSchemeMatchConditionParameters{} + +type RequestSchemeMatchConditionParameters struct { + MatchValues *[]RequestSchemeMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator Operator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestSchemeMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestSchemeMatchConditionParameters{} + +func (s RequestSchemeMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestSchemeMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestSchemeConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_requesturimatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_requesturimatchconditionparameters.go new file mode 100644 index 00000000000..5ddcfe8d72c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_requesturimatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestUriMatchConditionParameters{} + +type RequestUriMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestUriOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestUriMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestUriMatchConditionParameters{} + +func (s RequestUriMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestUriMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestUriMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestUriMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestUriConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestUriMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_resourcereference.go b/resource-manager/cdn/2024-09-01/endpoints/model_resourcereference.go new file mode 100644 index 00000000000..d2738a85404 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_resourcereference.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_resourceusage.go b/resource-manager/cdn/2024-09-01/endpoints/model_resourceusage.go new file mode 100644 index 00000000000..e9ab54ffd5c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_resourceusage.go @@ -0,0 +1,11 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Unit *ResourceUsageUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_responsebasedoriginerrordetectionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_responsebasedoriginerrordetectionparameters.go new file mode 100644 index 00000000000..e9d37b8212f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_responsebasedoriginerrordetectionparameters.go @@ -0,0 +1,10 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseBasedOriginErrorDetectionParameters struct { + HTTPErrorRanges *[]HTTPErrorRangeParameters `json:"httpErrorRanges,omitempty"` + ResponseBasedDetectedErrorTypes *ResponseBasedDetectedErrorTypes `json:"responseBasedDetectedErrorTypes,omitempty"` + ResponseBasedFailoverThresholdPercentage *int64 `json:"responseBasedFailoverThresholdPercentage,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_routeconfigurationoverrideactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_routeconfigurationoverrideactionparameters.go new file mode 100644 index 00000000000..7bfb2fb6be3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_routeconfigurationoverrideactionparameters.go @@ -0,0 +1,51 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = RouteConfigurationOverrideActionParameters{} + +type RouteConfigurationOverrideActionParameters struct { + CacheConfiguration *CacheConfiguration `json:"cacheConfiguration,omitempty"` + OriginGroupOverride *OriginGroupOverride `json:"originGroupOverride,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s RouteConfigurationOverrideActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RouteConfigurationOverrideActionParameters{} + +func (s RouteConfigurationOverrideActionParameters) MarshalJSON() ([]byte, error) { + type wrapper RouteConfigurationOverrideActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRouteConfigurationOverrideActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_serverportmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_serverportmatchconditionparameters.go new file mode 100644 index 00000000000..27d2be14b5d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_serverportmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = ServerPortMatchConditionParameters{} + +type ServerPortMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator ServerPortOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s ServerPortMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = ServerPortMatchConditionParameters{} + +func (s ServerPortMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper ServerPortMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServerPortMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServerPortMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleServerPortConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServerPortMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_socketaddrmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_socketaddrmatchconditionparameters.go new file mode 100644 index 00000000000..ebc67818797 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_socketaddrmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = SocketAddrMatchConditionParameters{} + +type SocketAddrMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator SocketAddrOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s SocketAddrMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = SocketAddrMatchConditionParameters{} + +func (s SocketAddrMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper SocketAddrMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SocketAddrMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SocketAddrMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleSocketAddrConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SocketAddrMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_sslprotocolmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_sslprotocolmatchconditionparameters.go new file mode 100644 index 00000000000..875a8a68b53 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_sslprotocolmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = SslProtocolMatchConditionParameters{} + +type SslProtocolMatchConditionParameters struct { + MatchValues *[]SslProtocol `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator SslProtocolOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s SslProtocolMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = SslProtocolMatchConditionParameters{} + +func (s SslProtocolMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper SslProtocolMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SslProtocolMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SslProtocolMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleSslProtocolConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SslProtocolMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlfileextensionmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlfileextensionmatchconditionparameters.go new file mode 100644 index 00000000000..543a890572f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlfileextensionmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLFileExtensionMatchConditionParameters{} + +type URLFileExtensionMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLFileExtensionOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLFileExtensionMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLFileExtensionMatchConditionParameters{} + +func (s URLFileExtensionMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLFileExtensionMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlfilenamematchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlfilenamematchconditionparameters.go new file mode 100644 index 00000000000..af287a69d2e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlfilenamematchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLFileNameMatchConditionParameters{} + +type URLFileNameMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLFileNameOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLFileNameMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLFileNameMatchConditionParameters{} + +func (s URLFileNameMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLFileNameMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLFileNameMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLFileNameMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlFilenameConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLFileNameMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlpathmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlpathmatchconditionparameters.go new file mode 100644 index 00000000000..fc1e2b837d5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlpathmatchconditionparameters.go @@ -0,0 +1,53 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLPathMatchConditionParameters{} + +type URLPathMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLPathOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLPathMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLPathMatchConditionParameters{} + +func (s URLPathMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLPathMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLPathMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLPathMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlPathMatchConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLPathMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectaction.go new file mode 100644 index 00000000000..a82af931aaa --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLRedirectAction{} + +type URLRedirectAction struct { + Parameters URLRedirectActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLRedirectAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLRedirectAction{} + +func (s URLRedirectAction) MarshalJSON() ([]byte, error) { + type wrapper URLRedirectAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRedirectAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRedirectAction: %+v", err) + } + + decoded["name"] = "UrlRedirect" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRedirectAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectactionparameters.go new file mode 100644 index 00000000000..9d30e3ee1d9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlredirectactionparameters.go @@ -0,0 +1,55 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLRedirectActionParameters{} + +type URLRedirectActionParameters struct { + CustomFragment *string `json:"customFragment,omitempty"` + CustomHostname *string `json:"customHostname,omitempty"` + CustomPath *string `json:"customPath,omitempty"` + CustomQueryString *string `json:"customQueryString,omitempty"` + DestinationProtocol *DestinationProtocol `json:"destinationProtocol,omitempty"` + RedirectType RedirectType `json:"redirectType"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLRedirectActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLRedirectActionParameters{} + +func (s URLRedirectActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLRedirectActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRedirectActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRedirectActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlRedirectActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRedirectActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteaction.go new file mode 100644 index 00000000000..f45df93ec32 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLRewriteAction{} + +type URLRewriteAction struct { + Parameters URLRewriteActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLRewriteAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLRewriteAction{} + +func (s URLRewriteAction) MarshalJSON() ([]byte, error) { + type wrapper URLRewriteAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRewriteAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRewriteAction: %+v", err) + } + + decoded["name"] = "UrlRewrite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRewriteAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteactionparameters.go new file mode 100644 index 00000000000..dd8bafa33f1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlrewriteactionparameters.go @@ -0,0 +1,52 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLRewriteActionParameters{} + +type URLRewriteActionParameters struct { + Destination string `json:"destination"` + PreserveUnmatchedPath *bool `json:"preserveUnmatchedPath,omitempty"` + SourcePattern string `json:"sourcePattern"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLRewriteActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLRewriteActionParameters{} + +func (s URLRewriteActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLRewriteActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRewriteActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRewriteActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlRewriteActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRewriteActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningaction.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningaction.go new file mode 100644 index 00000000000..5bb4b815f27 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningaction.go @@ -0,0 +1,50 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLSigningAction{} + +type URLSigningAction struct { + Parameters URLSigningActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLSigningAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLSigningAction{} + +func (s URLSigningAction) MarshalJSON() ([]byte, error) { + type wrapper URLSigningAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLSigningAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLSigningAction: %+v", err) + } + + decoded["name"] = "UrlSigning" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLSigningAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningactionparameters.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningactionparameters.go new file mode 100644 index 00000000000..2d8b2ce8da7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningactionparameters.go @@ -0,0 +1,51 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLSigningActionParameters{} + +type URLSigningActionParameters struct { + Algorithm *Algorithm `json:"algorithm,omitempty"` + ParameterNameOverride *[]URLSigningParamIdentifier `json:"parameterNameOverride,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLSigningActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLSigningActionParameters{} + +func (s URLSigningActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLSigningActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLSigningActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLSigningActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlSigningActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLSigningActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningkey.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningkey.go new file mode 100644 index 00000000000..7e788a39c7c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningkey.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type URLSigningKey struct { + KeyId string `json:"keyId"` + KeySourceParameters KeyVaultSigningKeyParameters `json:"keySourceParameters"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningparamidentifier.go b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningparamidentifier.go new file mode 100644 index 00000000000..537fae3e438 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_urlsigningparamidentifier.go @@ -0,0 +1,9 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type URLSigningParamIdentifier struct { + ParamIndicator ParamIndicator `json:"paramIndicator"` + ParamName string `json:"paramName"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomaininput.go b/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomaininput.go new file mode 100644 index 00000000000..e143829b2e9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomaininput.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCustomDomainInput struct { + HostName string `json:"hostName"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomainoutput.go b/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomainoutput.go new file mode 100644 index 00000000000..ca152306143 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/model_validatecustomdomainoutput.go @@ -0,0 +1,10 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCustomDomainOutput struct { + CustomDomainValidated *bool `json:"customDomainValidated,omitempty"` + Message *string `json:"message,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/predicates.go b/resource-manager/cdn/2024-09-01/endpoints/predicates.go new file mode 100644 index 00000000000..bb41ee6d27a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/predicates.go @@ -0,0 +1,55 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p EndpointOperationPredicate) Matches(input Endpoint) 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 +} + +type ResourceUsageOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + ResourceType *string +} + +func (p ResourceUsageOperationPredicate) Matches(input ResourceUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/endpoints/version.go b/resource-manager/cdn/2024-09-01/endpoints/version.go new file mode 100644 index 00000000000..b28949aa653 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/endpoints/version.go @@ -0,0 +1,10 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/endpoints/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/README.md b/resource-manager/cdn/2024-09-01/loganalytics/README.md new file mode 100644 index 00000000000..53c0bfc614f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/README.md @@ -0,0 +1,84 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/loganalytics` Documentation + +The `loganalytics` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/loganalytics" +``` + + +### Client Initialization + +```go +client := loganalytics.NewLogAnalyticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LogAnalyticsClient.GetLogAnalyticsLocations` + +```go +ctx := context.TODO() +id := loganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.GetLogAnalyticsLocations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LogAnalyticsClient.GetLogAnalyticsMetrics` + +```go +ctx := context.TODO() +id := loganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.GetLogAnalyticsMetrics(ctx, id, loganalytics.DefaultGetLogAnalyticsMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LogAnalyticsClient.GetLogAnalyticsRankings` + +```go +ctx := context.TODO() +id := loganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.GetLogAnalyticsRankings(ctx, id, loganalytics.DefaultGetLogAnalyticsRankingsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LogAnalyticsClient.GetLogAnalyticsResources` + +```go +ctx := context.TODO() +id := loganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.GetLogAnalyticsResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/loganalytics/client.go b/resource-manager/cdn/2024-09-01/loganalytics/client.go new file mode 100644 index 00000000000..b32a74cf728 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/client.go @@ -0,0 +1,26 @@ +package loganalytics + +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 LogAnalyticsClient struct { + Client *resourcemanager.Client +} + +func NewLogAnalyticsClientWithBaseURI(sdkApi sdkEnv.Api) (*LogAnalyticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "loganalytics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LogAnalyticsClient: %+v", err) + } + + return &LogAnalyticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/constants.go b/resource-manager/cdn/2024-09-01/loganalytics/constants.go new file mode 100644 index 00000000000..b6b4815c44d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/constants.go @@ -0,0 +1,145 @@ +package loganalytics + +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 LogMetricsGranularity string + +const ( + LogMetricsGranularityPOneD LogMetricsGranularity = "P1D" + LogMetricsGranularityPTFiveM LogMetricsGranularity = "PT5M" + LogMetricsGranularityPTOneH LogMetricsGranularity = "PT1H" +) + +func PossibleValuesForLogMetricsGranularity() []string { + return []string{ + string(LogMetricsGranularityPOneD), + string(LogMetricsGranularityPTFiveM), + string(LogMetricsGranularityPTOneH), + } +} + +func (s *LogMetricsGranularity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogMetricsGranularity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogMetricsGranularity(input string) (*LogMetricsGranularity, error) { + vals := map[string]LogMetricsGranularity{ + "p1d": LogMetricsGranularityPOneD, + "pt5m": LogMetricsGranularityPTFiveM, + "pt1h": LogMetricsGranularityPTOneH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogMetricsGranularity(input) + return &out, nil +} + +type MetricsGranularity string + +const ( + MetricsGranularityPOneD MetricsGranularity = "P1D" + MetricsGranularityPTFiveM MetricsGranularity = "PT5M" + MetricsGranularityPTOneH MetricsGranularity = "PT1H" +) + +func PossibleValuesForMetricsGranularity() []string { + return []string{ + string(MetricsGranularityPOneD), + string(MetricsGranularityPTFiveM), + string(MetricsGranularityPTOneH), + } +} + +func (s *MetricsGranularity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMetricsGranularity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMetricsGranularity(input string) (*MetricsGranularity, error) { + vals := map[string]MetricsGranularity{ + "p1d": MetricsGranularityPOneD, + "pt5m": MetricsGranularityPTFiveM, + "pt1h": MetricsGranularityPTOneH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MetricsGranularity(input) + return &out, nil +} + +type MetricsSeriesUnit string + +const ( + MetricsSeriesUnitBitsPerSecond MetricsSeriesUnit = "bitsPerSecond" + MetricsSeriesUnitBytes MetricsSeriesUnit = "bytes" + MetricsSeriesUnitCount MetricsSeriesUnit = "count" + MetricsSeriesUnitMilliSeconds MetricsSeriesUnit = "milliSeconds" +) + +func PossibleValuesForMetricsSeriesUnit() []string { + return []string{ + string(MetricsSeriesUnitBitsPerSecond), + string(MetricsSeriesUnitBytes), + string(MetricsSeriesUnitCount), + string(MetricsSeriesUnitMilliSeconds), + } +} + +func (s *MetricsSeriesUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMetricsSeriesUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMetricsSeriesUnit(input string) (*MetricsSeriesUnit, error) { + vals := map[string]MetricsSeriesUnit{ + "bitspersecond": MetricsSeriesUnitBitsPerSecond, + "bytes": MetricsSeriesUnitBytes, + "count": MetricsSeriesUnitCount, + "milliseconds": MetricsSeriesUnitMilliSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MetricsSeriesUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/id_profile.go b/resource-manager/cdn/2024-09-01/loganalytics/id_profile.go new file mode 100644 index 00000000000..2e590cde444 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/id_profile.go @@ -0,0 +1,130 @@ +package loganalytics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/id_profile_test.go b/resource-manager/cdn/2024-09-01/loganalytics/id_profile_test.go new file mode 100644 index 00000000000..20e4f761319 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/id_profile_test.go @@ -0,0 +1,282 @@ +package loganalytics + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/loganalytics/method_getloganalyticslocations.go b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticslocations.go new file mode 100644 index 00000000000..8fc487bb49d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticslocations.go @@ -0,0 +1,54 @@ +package loganalytics + +import ( + "context" + "fmt" + "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 GetLogAnalyticsLocationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinentsResponse +} + +// GetLogAnalyticsLocations ... +func (c LogAnalyticsClient) GetLogAnalyticsLocations(ctx context.Context, id ProfileId) (result GetLogAnalyticsLocationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/getLogAnalyticsLocations", 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 + } + + var model ContinentsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsmetrics.go b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsmetrics.go new file mode 100644 index 00000000000..a4b28e022a0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsmetrics.go @@ -0,0 +1,115 @@ +package loganalytics + +import ( + "context" + "fmt" + "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 GetLogAnalyticsMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricsResponse +} + +type GetLogAnalyticsMetricsOperationOptions struct { + Continents *[]string + CountryOrRegions *[]string + CustomDomains *[]string + DateTimeBegin *string + DateTimeEnd *string + Granularity *LogMetricsGranularity + GroupBy *[]string + Metrics *[]string + Protocols *[]string +} + +func DefaultGetLogAnalyticsMetricsOperationOptions() GetLogAnalyticsMetricsOperationOptions { + return GetLogAnalyticsMetricsOperationOptions{} +} + +func (o GetLogAnalyticsMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetLogAnalyticsMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetLogAnalyticsMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Continents != nil { + out.Append("continents", fmt.Sprintf("%v", *o.Continents)) + } + if o.CountryOrRegions != nil { + out.Append("countryOrRegions", fmt.Sprintf("%v", *o.CountryOrRegions)) + } + if o.CustomDomains != nil { + out.Append("customDomains", fmt.Sprintf("%v", *o.CustomDomains)) + } + if o.DateTimeBegin != nil { + out.Append("dateTimeBegin", fmt.Sprintf("%v", *o.DateTimeBegin)) + } + if o.DateTimeEnd != nil { + out.Append("dateTimeEnd", fmt.Sprintf("%v", *o.DateTimeEnd)) + } + if o.Granularity != nil { + out.Append("granularity", fmt.Sprintf("%v", *o.Granularity)) + } + if o.GroupBy != nil { + out.Append("groupBy", fmt.Sprintf("%v", *o.GroupBy)) + } + if o.Metrics != nil { + out.Append("metrics", fmt.Sprintf("%v", *o.Metrics)) + } + if o.Protocols != nil { + out.Append("protocols", fmt.Sprintf("%v", *o.Protocols)) + } + return &out +} + +// GetLogAnalyticsMetrics ... +func (c LogAnalyticsClient) GetLogAnalyticsMetrics(ctx context.Context, id ProfileId, options GetLogAnalyticsMetricsOperationOptions) (result GetLogAnalyticsMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/getLogAnalyticsMetrics", 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 + } + + var model MetricsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsrankings.go b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsrankings.go new file mode 100644 index 00000000000..4f42f8fd86c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsrankings.go @@ -0,0 +1,103 @@ +package loganalytics + +import ( + "context" + "fmt" + "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 GetLogAnalyticsRankingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RankingsResponse +} + +type GetLogAnalyticsRankingsOperationOptions struct { + CustomDomains *[]string + DateTimeBegin *string + DateTimeEnd *string + MaxRanking *int64 + Metrics *[]string + Rankings *[]string +} + +func DefaultGetLogAnalyticsRankingsOperationOptions() GetLogAnalyticsRankingsOperationOptions { + return GetLogAnalyticsRankingsOperationOptions{} +} + +func (o GetLogAnalyticsRankingsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetLogAnalyticsRankingsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetLogAnalyticsRankingsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CustomDomains != nil { + out.Append("customDomains", fmt.Sprintf("%v", *o.CustomDomains)) + } + if o.DateTimeBegin != nil { + out.Append("dateTimeBegin", fmt.Sprintf("%v", *o.DateTimeBegin)) + } + if o.DateTimeEnd != nil { + out.Append("dateTimeEnd", fmt.Sprintf("%v", *o.DateTimeEnd)) + } + if o.MaxRanking != nil { + out.Append("maxRanking", fmt.Sprintf("%v", *o.MaxRanking)) + } + if o.Metrics != nil { + out.Append("metrics", fmt.Sprintf("%v", *o.Metrics)) + } + if o.Rankings != nil { + out.Append("rankings", fmt.Sprintf("%v", *o.Rankings)) + } + return &out +} + +// GetLogAnalyticsRankings ... +func (c LogAnalyticsClient) GetLogAnalyticsRankings(ctx context.Context, id ProfileId, options GetLogAnalyticsRankingsOperationOptions) (result GetLogAnalyticsRankingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/getLogAnalyticsRankings", 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 + } + + var model RankingsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsresources.go b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsresources.go new file mode 100644 index 00000000000..ebb8ef4109a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/method_getloganalyticsresources.go @@ -0,0 +1,54 @@ +package loganalytics + +import ( + "context" + "fmt" + "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 GetLogAnalyticsResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourcesResponse +} + +// GetLogAnalyticsResources ... +func (c LogAnalyticsClient) GetLogAnalyticsResources(ctx context.Context, id ProfileId) (result GetLogAnalyticsResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/getLogAnalyticsResources", 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 + } + + var model ResourcesResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponse.go b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponse.go new file mode 100644 index 00000000000..2769d4b2734 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponse.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinentsResponse struct { + Continents *[]ContinentsResponseContinentsInlined `json:"continents,omitempty"` + CountryOrRegions *[]ContinentsResponseCountryOrRegionsInlined `json:"countryOrRegions,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecontinentsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecontinentsinlined.go new file mode 100644 index 00000000000..78369bd519c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecontinentsinlined.go @@ -0,0 +1,8 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinentsResponseContinentsInlined struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecountryorregionsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecountryorregionsinlined.go new file mode 100644 index 00000000000..5fc2ba4521d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_continentsresponsecountryorregionsinlined.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinentsResponseCountryOrRegionsInlined struct { + ContinentId *string `json:"continentId,omitempty"` + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponse.go b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponse.go new file mode 100644 index 00000000000..0bbcacac905 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponse.go @@ -0,0 +1,41 @@ +package loganalytics + +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 MetricsResponse struct { + DateTimeBegin *string `json:"dateTimeBegin,omitempty"` + DateTimeEnd *string `json:"dateTimeEnd,omitempty"` + Granularity *MetricsGranularity `json:"granularity,omitempty"` + Series *[]MetricsResponseSeriesInlined `json:"series,omitempty"` +} + +func (o *MetricsResponse) GetDateTimeBeginAsTime() (*time.Time, error) { + if o.DateTimeBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *MetricsResponse) SetDateTimeBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeBegin = &formatted +} + +func (o *MetricsResponse) GetDateTimeEndAsTime() (*time.Time, error) { + if o.DateTimeEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *MetricsResponse) SetDateTimeEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeEnd = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlined.go new file mode 100644 index 00000000000..2f151cc93d3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlined.go @@ -0,0 +1,11 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricsResponseSeriesInlined struct { + Data *[]MetricsResponseSeriesInlinedDataInlined `json:"data,omitempty"` + Groups *[]MetricsResponseSeriesInlinedGroupsInlined `json:"groups,omitempty"` + Metric *string `json:"metric,omitempty"` + Unit *MetricsSeriesUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlineddatainlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlineddatainlined.go new file mode 100644 index 00000000000..7d848aecfce --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlineddatainlined.go @@ -0,0 +1,27 @@ +package loganalytics + +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 MetricsResponseSeriesInlinedDataInlined struct { + DateTime *string `json:"dateTime,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +func (o *MetricsResponseSeriesInlinedDataInlined) GetDateTimeAsTime() (*time.Time, error) { + if o.DateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MetricsResponseSeriesInlinedDataInlined) SetDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTime = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlinedgroupsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlinedgroupsinlined.go new file mode 100644 index 00000000000..ffd5770e6f5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_metricsresponseseriesinlinedgroupsinlined.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricsResponseSeriesInlinedGroupsInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponse.go b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponse.go new file mode 100644 index 00000000000..c7d2cbd3a7e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponse.go @@ -0,0 +1,40 @@ +package loganalytics + +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 RankingsResponse struct { + DateTimeBegin *string `json:"dateTimeBegin,omitempty"` + DateTimeEnd *string `json:"dateTimeEnd,omitempty"` + Tables *[]RankingsResponseTablesInlined `json:"tables,omitempty"` +} + +func (o *RankingsResponse) GetDateTimeBeginAsTime() (*time.Time, error) { + if o.DateTimeBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *RankingsResponse) SetDateTimeBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeBegin = &formatted +} + +func (o *RankingsResponse) GetDateTimeEndAsTime() (*time.Time, error) { + if o.DateTimeEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *RankingsResponse) SetDateTimeEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeEnd = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlined.go new file mode 100644 index 00000000000..41b56e2085e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlined.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RankingsResponseTablesInlined struct { + Data *[]RankingsResponseTablesInlinedDataInlined `json:"data,omitempty"` + Ranking *string `json:"ranking,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlined.go new file mode 100644 index 00000000000..4cc5bfe9476 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlined.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RankingsResponseTablesInlinedDataInlined struct { + Metrics *[]RankingsResponseTablesInlinedDataInlinedMetricsInlined `json:"metrics,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlinedmetricsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlinedmetricsinlined.go new file mode 100644 index 00000000000..61a3412e580 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_rankingsresponsetablesinlineddatainlinedmetricsinlined.go @@ -0,0 +1,10 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RankingsResponseTablesInlinedDataInlinedMetricsInlined struct { + Metric *string `json:"metric,omitempty"` + Percentage *float64 `json:"percentage,omitempty"` + Value *int64 `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponse.go b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponse.go new file mode 100644 index 00000000000..3def33df803 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponse.go @@ -0,0 +1,9 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesResponse struct { + CustomDomains *[]ResourcesResponseCustomDomainsInlined `json:"customDomains,omitempty"` + Endpoints *[]ResourcesResponseEndpointsInlined `json:"endpoints,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponsecustomdomainsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponsecustomdomainsinlined.go new file mode 100644 index 00000000000..1414be5266a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponsecustomdomainsinlined.go @@ -0,0 +1,11 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesResponseCustomDomainsInlined struct { + EndpointId *string `json:"endpointId,omitempty"` + History *bool `json:"history,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlined.go new file mode 100644 index 00000000000..086302ac252 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlined.go @@ -0,0 +1,11 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesResponseEndpointsInlined struct { + CustomDomains *[]ResourcesResponseEndpointsInlinedCustomDomainsInlined `json:"customDomains,omitempty"` + History *bool `json:"history,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlinedcustomdomainsinlined.go b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlinedcustomdomainsinlined.go new file mode 100644 index 00000000000..5b907cc5cf7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/model_resourcesresponseendpointsinlinedcustomdomainsinlined.go @@ -0,0 +1,11 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourcesResponseEndpointsInlinedCustomDomainsInlined struct { + EndpointId *string `json:"endpointId,omitempty"` + History *bool `json:"history,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/loganalytics/version.go b/resource-manager/cdn/2024-09-01/loganalytics/version.go new file mode 100644 index 00000000000..6b0cf79d0b0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/loganalytics/version.go @@ -0,0 +1,10 @@ +package loganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/loganalytics/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/README.md b/resource-manager/cdn/2024-09-01/origingroups/README.md new file mode 100644 index 00000000000..93505d20597 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/origingroups` Documentation + +The `origingroups` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/origingroups" +``` + + +### Client Initialization + +```go +client := origingroups.NewOriginGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OriginGroupsClient.Create` + +```go +ctx := context.TODO() +id := origingroups.NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName") + +payload := origingroups.OriginGroup{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OriginGroupsClient.Delete` + +```go +ctx := context.TODO() +id := origingroups.NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OriginGroupsClient.Get` + +```go +ctx := context.TODO() +id := origingroups.NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName") + +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: `OriginGroupsClient.ListByEndpoint` + +```go +ctx := context.TODO() +id := origingroups.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +// alternatively `client.ListByEndpoint(ctx, id)` can be used to do batched pagination +items, err := client.ListByEndpointComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OriginGroupsClient.Update` + +```go +ctx := context.TODO() +id := origingroups.NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName") + +payload := origingroups.OriginGroupUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/origingroups/client.go b/resource-manager/cdn/2024-09-01/origingroups/client.go new file mode 100644 index 00000000000..cd67131f745 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/client.go @@ -0,0 +1,26 @@ +package origingroups + +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 OriginGroupsClient struct { + Client *resourcemanager.Client +} + +func NewOriginGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*OriginGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "origingroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OriginGroupsClient: %+v", err) + } + + return &OriginGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/constants.go b/resource-manager/cdn/2024-09-01/origingroups/constants.go new file mode 100644 index 00000000000..b7f9848fff3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/constants.go @@ -0,0 +1,236 @@ +package origingroups + +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 HealthProbeRequestType string + +const ( + HealthProbeRequestTypeGET HealthProbeRequestType = "GET" + HealthProbeRequestTypeHEAD HealthProbeRequestType = "HEAD" + HealthProbeRequestTypeNotSet HealthProbeRequestType = "NotSet" +) + +func PossibleValuesForHealthProbeRequestType() []string { + return []string{ + string(HealthProbeRequestTypeGET), + string(HealthProbeRequestTypeHEAD), + string(HealthProbeRequestTypeNotSet), + } +} + +func (s *HealthProbeRequestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthProbeRequestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthProbeRequestType(input string) (*HealthProbeRequestType, error) { + vals := map[string]HealthProbeRequestType{ + "get": HealthProbeRequestTypeGET, + "head": HealthProbeRequestTypeHEAD, + "notset": HealthProbeRequestTypeNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthProbeRequestType(input) + return &out, nil +} + +type OriginGroupProvisioningState string + +const ( + OriginGroupProvisioningStateCreating OriginGroupProvisioningState = "Creating" + OriginGroupProvisioningStateDeleting OriginGroupProvisioningState = "Deleting" + OriginGroupProvisioningStateFailed OriginGroupProvisioningState = "Failed" + OriginGroupProvisioningStateSucceeded OriginGroupProvisioningState = "Succeeded" + OriginGroupProvisioningStateUpdating OriginGroupProvisioningState = "Updating" +) + +func PossibleValuesForOriginGroupProvisioningState() []string { + return []string{ + string(OriginGroupProvisioningStateCreating), + string(OriginGroupProvisioningStateDeleting), + string(OriginGroupProvisioningStateFailed), + string(OriginGroupProvisioningStateSucceeded), + string(OriginGroupProvisioningStateUpdating), + } +} + +func (s *OriginGroupProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOriginGroupProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOriginGroupProvisioningState(input string) (*OriginGroupProvisioningState, error) { + vals := map[string]OriginGroupProvisioningState{ + "creating": OriginGroupProvisioningStateCreating, + "deleting": OriginGroupProvisioningStateDeleting, + "failed": OriginGroupProvisioningStateFailed, + "succeeded": OriginGroupProvisioningStateSucceeded, + "updating": OriginGroupProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OriginGroupProvisioningState(input) + return &out, nil +} + +type OriginGroupResourceState string + +const ( + OriginGroupResourceStateActive OriginGroupResourceState = "Active" + OriginGroupResourceStateCreating OriginGroupResourceState = "Creating" + OriginGroupResourceStateDeleting OriginGroupResourceState = "Deleting" +) + +func PossibleValuesForOriginGroupResourceState() []string { + return []string{ + string(OriginGroupResourceStateActive), + string(OriginGroupResourceStateCreating), + string(OriginGroupResourceStateDeleting), + } +} + +func (s *OriginGroupResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOriginGroupResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOriginGroupResourceState(input string) (*OriginGroupResourceState, error) { + vals := map[string]OriginGroupResourceState{ + "active": OriginGroupResourceStateActive, + "creating": OriginGroupResourceStateCreating, + "deleting": OriginGroupResourceStateDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OriginGroupResourceState(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "Http" + ProbeProtocolHTTPS ProbeProtocol = "Https" + ProbeProtocolNotSet ProbeProtocol = "NotSet" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolNotSet), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "notset": ProbeProtocolNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type ResponseBasedDetectedErrorTypes string + +const ( + ResponseBasedDetectedErrorTypesNone ResponseBasedDetectedErrorTypes = "None" + ResponseBasedDetectedErrorTypesTcpAndHTTPErrors ResponseBasedDetectedErrorTypes = "TcpAndHttpErrors" + ResponseBasedDetectedErrorTypesTcpErrorsOnly ResponseBasedDetectedErrorTypes = "TcpErrorsOnly" +) + +func PossibleValuesForResponseBasedDetectedErrorTypes() []string { + return []string{ + string(ResponseBasedDetectedErrorTypesNone), + string(ResponseBasedDetectedErrorTypesTcpAndHTTPErrors), + string(ResponseBasedDetectedErrorTypesTcpErrorsOnly), + } +} + +func (s *ResponseBasedDetectedErrorTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResponseBasedDetectedErrorTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResponseBasedDetectedErrorTypes(input string) (*ResponseBasedDetectedErrorTypes, error) { + vals := map[string]ResponseBasedDetectedErrorTypes{ + "none": ResponseBasedDetectedErrorTypesNone, + "tcpandhttperrors": ResponseBasedDetectedErrorTypesTcpAndHTTPErrors, + "tcperrorsonly": ResponseBasedDetectedErrorTypesTcpErrorsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResponseBasedDetectedErrorTypes(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/id_endpoint.go b/resource-manager/cdn/2024-09-01/origingroups/id_endpoint.go new file mode 100644 index 00000000000..9eddd0035c5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/id_endpoint.go @@ -0,0 +1,139 @@ +package origingroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointId{}) +} + +var _ resourceids.ResourceId = &EndpointId{} + +// EndpointId is a struct representing the Resource ID for a Endpoint +type EndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string +} + +// NewEndpointID returns a new EndpointId struct +func NewEndpointID(subscriptionId string, resourceGroupName string, profileName string, endpointName string) EndpointId { + return EndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + } +} + +// ParseEndpointID parses 'input' into a EndpointId +func ParseEndpointID(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId +// note: this method should only be used for API response data and not user input +func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + return nil +} + +// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID +func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint ID +func (id EndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID +func (id EndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + } +} + +// String returns a human-readable description of this Endpoint ID +func (id EndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + } + return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/id_endpoint_test.go b/resource-manager/cdn/2024-09-01/origingroups/id_endpoint_test.go new file mode 100644 index 00000000000..22971f3780b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/id_endpoint_test.go @@ -0,0 +1,327 @@ +package origingroups + +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 = &EndpointId{} + +func TestNewEndpointID(t *testing.T) { + id := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } +} + +func TestFormatEndpointID(t *testing.T) { + actual := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestParseEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestSegmentsForEndpointId(t *testing.T) { + segments := EndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointId 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/cdn/2024-09-01/origingroups/id_endpointorigingroup.go b/resource-manager/cdn/2024-09-01/origingroups/id_endpointorigingroup.go new file mode 100644 index 00000000000..552ccfc8436 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/id_endpointorigingroup.go @@ -0,0 +1,148 @@ +package origingroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointOriginGroupId{}) +} + +var _ resourceids.ResourceId = &EndpointOriginGroupId{} + +// EndpointOriginGroupId is a struct representing the Resource ID for a Endpoint Origin Group +type EndpointOriginGroupId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string + OriginGroupName string +} + +// NewEndpointOriginGroupID returns a new EndpointOriginGroupId struct +func NewEndpointOriginGroupID(subscriptionId string, resourceGroupName string, profileName string, endpointName string, originGroupName string) EndpointOriginGroupId { + return EndpointOriginGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + OriginGroupName: originGroupName, + } +} + +// ParseEndpointOriginGroupID parses 'input' into a EndpointOriginGroupId +func ParseEndpointOriginGroupID(input string) (*EndpointOriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointOriginGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointOriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointOriginGroupIDInsensitively parses 'input' case-insensitively into a EndpointOriginGroupId +// note: this method should only be used for API response data and not user input +func ParseEndpointOriginGroupIDInsensitively(input string) (*EndpointOriginGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointOriginGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointOriginGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointOriginGroupId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + if id.OriginGroupName, ok = input.Parsed["originGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originGroupName", input) + } + + return nil +} + +// ValidateEndpointOriginGroupID checks that 'input' can be parsed as a Endpoint Origin Group ID +func ValidateEndpointOriginGroupID(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 := ParseEndpointOriginGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint Origin Group ID +func (id EndpointOriginGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s/originGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName, id.OriginGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint Origin Group ID +func (id EndpointOriginGroupId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + resourceids.StaticSegment("staticOriginGroups", "originGroups", "originGroups"), + resourceids.UserSpecifiedSegment("originGroupName", "originGroupName"), + } +} + +// String returns a human-readable description of this Endpoint Origin Group ID +func (id EndpointOriginGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + fmt.Sprintf("Origin Group Name: %q", id.OriginGroupName), + } + return fmt.Sprintf("Endpoint Origin Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/id_endpointorigingroup_test.go b/resource-manager/cdn/2024-09-01/origingroups/id_endpointorigingroup_test.go new file mode 100644 index 00000000000..02e190abebf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/id_endpointorigingroup_test.go @@ -0,0 +1,372 @@ +package origingroups + +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 = &EndpointOriginGroupId{} + +func TestNewEndpointOriginGroupID(t *testing.T) { + id := NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } + + if id.OriginGroupName != "originGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginGroupName'", id.OriginGroupName, "originGroupName") + } +} + +func TestFormatEndpointOriginGroupID(t *testing.T) { + actual := NewEndpointOriginGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups/originGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointOriginGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointOriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups/originGroupName", + Expected: &EndpointOriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups/originGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointOriginGroupID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestParseEndpointOriginGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointOriginGroupId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups/originGroupName", + Expected: &EndpointOriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + OriginGroupName: "originGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/originGroups/originGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNgRoUpS/oRiGiNgRoUpNaMe", + Expected: &EndpointOriginGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + OriginGroupName: "oRiGiNgRoUpNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNgRoUpS/oRiGiNgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointOriginGroupIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.OriginGroupName != v.Expected.OriginGroupName { + t.Fatalf("Expected %q but got %q for OriginGroupName", v.Expected.OriginGroupName, actual.OriginGroupName) + } + + } +} + +func TestSegmentsForEndpointOriginGroupId(t *testing.T) { + segments := EndpointOriginGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointOriginGroupId 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/cdn/2024-09-01/origingroups/method_create.go b/resource-manager/cdn/2024-09-01/origingroups/method_create.go new file mode 100644 index 00000000000..db797b0f3e0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/method_create.go @@ -0,0 +1,76 @@ +package origingroups + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OriginGroup +} + +// Create ... +func (c OriginGroupsClient) Create(ctx context.Context, id EndpointOriginGroupId, input OriginGroup) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c OriginGroupsClient) CreateThenPoll(ctx context.Context, id EndpointOriginGroupId, input OriginGroup) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/method_delete.go b/resource-manager/cdn/2024-09-01/origingroups/method_delete.go new file mode 100644 index 00000000000..81cc0819cdc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/method_delete.go @@ -0,0 +1,71 @@ +package origingroups + +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 OriginGroupsClient) Delete(ctx context.Context, id EndpointOriginGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 OriginGroupsClient) DeleteThenPoll(ctx context.Context, id EndpointOriginGroupId) 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/cdn/2024-09-01/origingroups/method_get.go b/resource-manager/cdn/2024-09-01/origingroups/method_get.go new file mode 100644 index 00000000000..e23e01f71fb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/method_get.go @@ -0,0 +1,53 @@ +package origingroups + +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 *OriginGroup +} + +// Get ... +func (c OriginGroupsClient) Get(ctx context.Context, id EndpointOriginGroupId) (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 + } + + var model OriginGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/method_listbyendpoint.go b/resource-manager/cdn/2024-09-01/origingroups/method_listbyendpoint.go new file mode 100644 index 00000000000..fa1f3ae0b80 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/method_listbyendpoint.go @@ -0,0 +1,105 @@ +package origingroups + +import ( + "context" + "fmt" + "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 ListByEndpointOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OriginGroup +} + +type ListByEndpointCompleteResult struct { + LatestHttpResponse *http.Response + Items []OriginGroup +} + +type ListByEndpointCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByEndpointCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByEndpoint ... +func (c OriginGroupsClient) ListByEndpoint(ctx context.Context, id EndpointId) (result ListByEndpointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByEndpointCustomPager{}, + Path: fmt.Sprintf("%s/originGroups", 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 *[]OriginGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByEndpointComplete retrieves all the results into a single object +func (c OriginGroupsClient) ListByEndpointComplete(ctx context.Context, id EndpointId) (ListByEndpointCompleteResult, error) { + return c.ListByEndpointCompleteMatchingPredicate(ctx, id, OriginGroupOperationPredicate{}) +} + +// ListByEndpointCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OriginGroupsClient) ListByEndpointCompleteMatchingPredicate(ctx context.Context, id EndpointId, predicate OriginGroupOperationPredicate) (result ListByEndpointCompleteResult, err error) { + items := make([]OriginGroup, 0) + + resp, err := c.ListByEndpoint(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByEndpointCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/method_update.go b/resource-manager/cdn/2024-09-01/origingroups/method_update.go new file mode 100644 index 00000000000..b4051dee39a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/method_update.go @@ -0,0 +1,75 @@ +package origingroups + +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 + Model *OriginGroup +} + +// Update ... +func (c OriginGroupsClient) Update(ctx context.Context, id EndpointOriginGroupId, input OriginGroupUpdateParameters) (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 OriginGroupsClient) UpdateThenPoll(ctx context.Context, id EndpointOriginGroupId, input OriginGroupUpdateParameters) 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/cdn/2024-09-01/origingroups/model_healthprobeparameters.go b/resource-manager/cdn/2024-09-01/origingroups/model_healthprobeparameters.go new file mode 100644 index 00000000000..67018c3f6da --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_healthprobeparameters.go @@ -0,0 +1,11 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthProbeParameters struct { + ProbeIntervalInSeconds *int64 `json:"probeIntervalInSeconds,omitempty"` + ProbePath *string `json:"probePath,omitempty"` + ProbeProtocol *ProbeProtocol `json:"probeProtocol,omitempty"` + ProbeRequestType *HealthProbeRequestType `json:"probeRequestType,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_httperrorrangeparameters.go b/resource-manager/cdn/2024-09-01/origingroups/model_httperrorrangeparameters.go new file mode 100644 index 00000000000..b6b3fe27f23 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_httperrorrangeparameters.go @@ -0,0 +1,9 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPErrorRangeParameters struct { + Begin *int64 `json:"begin,omitempty"` + End *int64 `json:"end,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_origingroup.go b/resource-manager/cdn/2024-09-01/origingroups/model_origingroup.go new file mode 100644 index 00000000000..649ed9a3b6b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_origingroup.go @@ -0,0 +1,16 @@ +package origingroups + +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 OriginGroup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OriginGroupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_origingroupproperties.go b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupproperties.go new file mode 100644 index 00000000000..a407158a8d0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupproperties.go @@ -0,0 +1,13 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupProperties struct { + HealthProbeSettings *HealthProbeParameters `json:"healthProbeSettings,omitempty"` + Origins *[]ResourceReference `json:"origins,omitempty"` + ProvisioningState *OriginGroupProvisioningState `json:"provisioningState,omitempty"` + ResourceState *OriginGroupResourceState `json:"resourceState,omitempty"` + ResponseBasedOriginErrorDetectionSettings *ResponseBasedOriginErrorDetectionParameters `json:"responseBasedOriginErrorDetectionSettings,omitempty"` + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes *int64 `json:"trafficRestorationTimeToHealedOrNewEndpointsInMinutes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdateparameters.go b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdateparameters.go new file mode 100644 index 00000000000..03f4cb09dc3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdateparameters.go @@ -0,0 +1,8 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupUpdateParameters struct { + Properties *OriginGroupUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdatepropertiesparameters.go new file mode 100644 index 00000000000..12ea2b4d7f5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_origingroupupdatepropertiesparameters.go @@ -0,0 +1,11 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupUpdatePropertiesParameters struct { + HealthProbeSettings *HealthProbeParameters `json:"healthProbeSettings,omitempty"` + Origins *[]ResourceReference `json:"origins,omitempty"` + ResponseBasedOriginErrorDetectionSettings *ResponseBasedOriginErrorDetectionParameters `json:"responseBasedOriginErrorDetectionSettings,omitempty"` + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes *int64 `json:"trafficRestorationTimeToHealedOrNewEndpointsInMinutes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_resourcereference.go b/resource-manager/cdn/2024-09-01/origingroups/model_resourcereference.go new file mode 100644 index 00000000000..67700c54e20 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_resourcereference.go @@ -0,0 +1,8 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/model_responsebasedoriginerrordetectionparameters.go b/resource-manager/cdn/2024-09-01/origingroups/model_responsebasedoriginerrordetectionparameters.go new file mode 100644 index 00000000000..f6bdf7d8ced --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/model_responsebasedoriginerrordetectionparameters.go @@ -0,0 +1,10 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseBasedOriginErrorDetectionParameters struct { + HTTPErrorRanges *[]HTTPErrorRangeParameters `json:"httpErrorRanges,omitempty"` + ResponseBasedDetectedErrorTypes *ResponseBasedDetectedErrorTypes `json:"responseBasedDetectedErrorTypes,omitempty"` + ResponseBasedFailoverThresholdPercentage *int64 `json:"responseBasedFailoverThresholdPercentage,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origingroups/predicates.go b/resource-manager/cdn/2024-09-01/origingroups/predicates.go new file mode 100644 index 00000000000..74bab74fc98 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/predicates.go @@ -0,0 +1,27 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p OriginGroupOperationPredicate) Matches(input OriginGroup) 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/cdn/2024-09-01/origingroups/version.go b/resource-manager/cdn/2024-09-01/origingroups/version.go new file mode 100644 index 00000000000..24cc10d10bd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origingroups/version.go @@ -0,0 +1,10 @@ +package origingroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/origingroups/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/origins/README.md b/resource-manager/cdn/2024-09-01/origins/README.md new file mode 100644 index 00000000000..1065a378629 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/origins` Documentation + +The `origins` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/origins" +``` + + +### Client Initialization + +```go +client := origins.NewOriginsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OriginsClient.Create` + +```go +ctx := context.TODO() +id := origins.NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName") + +payload := origins.Origin{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OriginsClient.Delete` + +```go +ctx := context.TODO() +id := origins.NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OriginsClient.Get` + +```go +ctx := context.TODO() +id := origins.NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName") + +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: `OriginsClient.ListByEndpoint` + +```go +ctx := context.TODO() +id := origins.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + +// alternatively `client.ListByEndpoint(ctx, id)` can be used to do batched pagination +items, err := client.ListByEndpointComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OriginsClient.Update` + +```go +ctx := context.TODO() +id := origins.NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName") + +payload := origins.OriginUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/origins/client.go b/resource-manager/cdn/2024-09-01/origins/client.go new file mode 100644 index 00000000000..ce3ee970663 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/client.go @@ -0,0 +1,26 @@ +package origins + +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 OriginsClient struct { + Client *resourcemanager.Client +} + +func NewOriginsClientWithBaseURI(sdkApi sdkEnv.Api) (*OriginsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "origins", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OriginsClient: %+v", err) + } + + return &OriginsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/origins/constants.go b/resource-manager/cdn/2024-09-01/origins/constants.go new file mode 100644 index 00000000000..a04f9ed83bf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/constants.go @@ -0,0 +1,154 @@ +package origins + +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 OriginProvisioningState string + +const ( + OriginProvisioningStateCreating OriginProvisioningState = "Creating" + OriginProvisioningStateDeleting OriginProvisioningState = "Deleting" + OriginProvisioningStateFailed OriginProvisioningState = "Failed" + OriginProvisioningStateSucceeded OriginProvisioningState = "Succeeded" + OriginProvisioningStateUpdating OriginProvisioningState = "Updating" +) + +func PossibleValuesForOriginProvisioningState() []string { + return []string{ + string(OriginProvisioningStateCreating), + string(OriginProvisioningStateDeleting), + string(OriginProvisioningStateFailed), + string(OriginProvisioningStateSucceeded), + string(OriginProvisioningStateUpdating), + } +} + +func (s *OriginProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOriginProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOriginProvisioningState(input string) (*OriginProvisioningState, error) { + vals := map[string]OriginProvisioningState{ + "creating": OriginProvisioningStateCreating, + "deleting": OriginProvisioningStateDeleting, + "failed": OriginProvisioningStateFailed, + "succeeded": OriginProvisioningStateSucceeded, + "updating": OriginProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OriginProvisioningState(input) + return &out, nil +} + +type OriginResourceState string + +const ( + OriginResourceStateActive OriginResourceState = "Active" + OriginResourceStateCreating OriginResourceState = "Creating" + OriginResourceStateDeleting OriginResourceState = "Deleting" +) + +func PossibleValuesForOriginResourceState() []string { + return []string{ + string(OriginResourceStateActive), + string(OriginResourceStateCreating), + string(OriginResourceStateDeleting), + } +} + +func (s *OriginResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOriginResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOriginResourceState(input string) (*OriginResourceState, error) { + vals := map[string]OriginResourceState{ + "active": OriginResourceStateActive, + "creating": OriginResourceStateCreating, + "deleting": OriginResourceStateDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OriginResourceState(input) + return &out, nil +} + +type PrivateEndpointStatus string + +const ( + PrivateEndpointStatusApproved PrivateEndpointStatus = "Approved" + PrivateEndpointStatusDisconnected PrivateEndpointStatus = "Disconnected" + PrivateEndpointStatusPending PrivateEndpointStatus = "Pending" + PrivateEndpointStatusRejected PrivateEndpointStatus = "Rejected" + PrivateEndpointStatusTimeout PrivateEndpointStatus = "Timeout" +) + +func PossibleValuesForPrivateEndpointStatus() []string { + return []string{ + string(PrivateEndpointStatusApproved), + string(PrivateEndpointStatusDisconnected), + string(PrivateEndpointStatusPending), + string(PrivateEndpointStatusRejected), + string(PrivateEndpointStatusTimeout), + } +} + +func (s *PrivateEndpointStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointStatus(input string) (*PrivateEndpointStatus, error) { + vals := map[string]PrivateEndpointStatus{ + "approved": PrivateEndpointStatusApproved, + "disconnected": PrivateEndpointStatusDisconnected, + "pending": PrivateEndpointStatusPending, + "rejected": PrivateEndpointStatusRejected, + "timeout": PrivateEndpointStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointStatus(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/origins/id_endpoint.go b/resource-manager/cdn/2024-09-01/origins/id_endpoint.go new file mode 100644 index 00000000000..80eaed95acc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/id_endpoint.go @@ -0,0 +1,139 @@ +package origins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&EndpointId{}) +} + +var _ resourceids.ResourceId = &EndpointId{} + +// EndpointId is a struct representing the Resource ID for a Endpoint +type EndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string +} + +// NewEndpointID returns a new EndpointId struct +func NewEndpointID(subscriptionId string, resourceGroupName string, profileName string, endpointName string) EndpointId { + return EndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + } +} + +// ParseEndpointID parses 'input' into a EndpointId +func ParseEndpointID(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId +// note: this method should only be used for API response data and not user input +func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&EndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + return nil +} + +// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID +func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint ID +func (id EndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID +func (id EndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + } +} + +// String returns a human-readable description of this Endpoint ID +func (id EndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + } + return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/origins/id_endpoint_test.go b/resource-manager/cdn/2024-09-01/origins/id_endpoint_test.go new file mode 100644 index 00000000000..fa48c9a4372 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/id_endpoint_test.go @@ -0,0 +1,327 @@ +package origins + +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 = &EndpointId{} + +func TestNewEndpointID(t *testing.T) { + id := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } +} + +func TestFormatEndpointID(t *testing.T) { + actual := NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestParseEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Expected: &EndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + } +} + +func TestSegmentsForEndpointId(t *testing.T) { + segments := EndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EndpointId 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/cdn/2024-09-01/origins/id_origin.go b/resource-manager/cdn/2024-09-01/origins/id_origin.go new file mode 100644 index 00000000000..2a50c9e02c8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/id_origin.go @@ -0,0 +1,148 @@ +package origins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&OriginId{}) +} + +var _ resourceids.ResourceId = &OriginId{} + +// OriginId is a struct representing the Resource ID for a Origin +type OriginId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + EndpointName string + OriginName string +} + +// NewOriginID returns a new OriginId struct +func NewOriginID(subscriptionId string, resourceGroupName string, profileName string, endpointName string, originName string) OriginId { + return OriginId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + EndpointName: endpointName, + OriginName: originName, + } +} + +// ParseOriginID parses 'input' into a OriginId +func ParseOriginID(input string) (*OriginId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOriginIDInsensitively parses 'input' case-insensitively into a OriginId +// note: this method should only be used for API response data and not user input +func ParseOriginIDInsensitively(input string) (*OriginId, error) { + parser := resourceids.NewParserFromResourceIdType(&OriginId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OriginId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OriginId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.EndpointName, ok = input.Parsed["endpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "endpointName", input) + } + + if id.OriginName, ok = input.Parsed["originName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "originName", input) + } + + return nil +} + +// ValidateOriginID checks that 'input' can be parsed as a Origin ID +func ValidateOriginID(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 := ParseOriginID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Origin ID +func (id OriginId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/endpoints/%s/origins/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.EndpointName, id.OriginName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Origin ID +func (id OriginId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointName"), + resourceids.StaticSegment("staticOrigins", "origins", "origins"), + resourceids.UserSpecifiedSegment("originName", "originName"), + } +} + +// String returns a human-readable description of this Origin ID +func (id OriginId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + fmt.Sprintf("Origin Name: %q", id.OriginName), + } + return fmt.Sprintf("Origin (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/origins/id_origin_test.go b/resource-manager/cdn/2024-09-01/origins/id_origin_test.go new file mode 100644 index 00000000000..091aa245e02 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/id_origin_test.go @@ -0,0 +1,372 @@ +package origins + +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 = &OriginId{} + +func TestNewOriginID(t *testing.T) { + id := NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.EndpointName != "endpointName" { + t.Fatalf("Expected %q but got %q for Segment 'EndpointName'", id.EndpointName, "endpointName") + } + + if id.OriginName != "originName" { + t.Fatalf("Expected %q but got %q for Segment 'OriginName'", id.OriginName, "originName") + } +} + +func TestFormatOriginID(t *testing.T) { + actual := NewOriginID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "endpointName", "originName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins/originName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOriginID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins/originName", + Expected: &OriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + OriginName: "originName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins/originName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.OriginName != v.Expected.OriginName { + t.Fatalf("Expected %q but got %q for OriginName", v.Expected.OriginName, actual.OriginName) + } + + } +} + +func TestParseOriginIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OriginId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins/originName", + Expected: &OriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + EndpointName: "endpointName", + OriginName: "originName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/endpoints/endpointName/origins/originName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNs/oRiGiNnAmE", + Expected: &OriginId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + EndpointName: "eNdPoInTnAmE", + OriginName: "oRiGiNnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/eNdPoInTs/eNdPoInTnAmE/oRiGiNs/oRiGiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOriginIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.EndpointName != v.Expected.EndpointName { + t.Fatalf("Expected %q but got %q for EndpointName", v.Expected.EndpointName, actual.EndpointName) + } + + if actual.OriginName != v.Expected.OriginName { + t.Fatalf("Expected %q but got %q for OriginName", v.Expected.OriginName, actual.OriginName) + } + + } +} + +func TestSegmentsForOriginId(t *testing.T) { + segments := OriginId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OriginId 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/cdn/2024-09-01/origins/method_create.go b/resource-manager/cdn/2024-09-01/origins/method_create.go new file mode 100644 index 00000000000..e6005a205a4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/method_create.go @@ -0,0 +1,76 @@ +package origins + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Origin +} + +// Create ... +func (c OriginsClient) Create(ctx context.Context, id OriginId, input Origin) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c OriginsClient) CreateThenPoll(ctx context.Context, id OriginId, input Origin) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/origins/method_delete.go b/resource-manager/cdn/2024-09-01/origins/method_delete.go new file mode 100644 index 00000000000..47d36e6e87f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/method_delete.go @@ -0,0 +1,71 @@ +package origins + +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 OriginsClient) Delete(ctx context.Context, id OriginId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 OriginsClient) DeleteThenPoll(ctx context.Context, id OriginId) 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/cdn/2024-09-01/origins/method_get.go b/resource-manager/cdn/2024-09-01/origins/method_get.go new file mode 100644 index 00000000000..a7594c26290 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/method_get.go @@ -0,0 +1,53 @@ +package origins + +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 *Origin +} + +// Get ... +func (c OriginsClient) Get(ctx context.Context, id OriginId) (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 + } + + var model Origin + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/origins/method_listbyendpoint.go b/resource-manager/cdn/2024-09-01/origins/method_listbyendpoint.go new file mode 100644 index 00000000000..476f311d7bb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/method_listbyendpoint.go @@ -0,0 +1,105 @@ +package origins + +import ( + "context" + "fmt" + "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 ListByEndpointOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Origin +} + +type ListByEndpointCompleteResult struct { + LatestHttpResponse *http.Response + Items []Origin +} + +type ListByEndpointCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByEndpointCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByEndpoint ... +func (c OriginsClient) ListByEndpoint(ctx context.Context, id EndpointId) (result ListByEndpointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByEndpointCustomPager{}, + Path: fmt.Sprintf("%s/origins", 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 *[]Origin `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByEndpointComplete retrieves all the results into a single object +func (c OriginsClient) ListByEndpointComplete(ctx context.Context, id EndpointId) (ListByEndpointCompleteResult, error) { + return c.ListByEndpointCompleteMatchingPredicate(ctx, id, OriginOperationPredicate{}) +} + +// ListByEndpointCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OriginsClient) ListByEndpointCompleteMatchingPredicate(ctx context.Context, id EndpointId, predicate OriginOperationPredicate) (result ListByEndpointCompleteResult, err error) { + items := make([]Origin, 0) + + resp, err := c.ListByEndpoint(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByEndpointCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/origins/method_update.go b/resource-manager/cdn/2024-09-01/origins/method_update.go new file mode 100644 index 00000000000..830da0e27ff --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/method_update.go @@ -0,0 +1,75 @@ +package origins + +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 + Model *Origin +} + +// Update ... +func (c OriginsClient) Update(ctx context.Context, id OriginId, input OriginUpdateParameters) (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 OriginsClient) UpdateThenPoll(ctx context.Context, id OriginId, input OriginUpdateParameters) 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/cdn/2024-09-01/origins/model_origin.go b/resource-manager/cdn/2024-09-01/origins/model_origin.go new file mode 100644 index 00000000000..38f21bdbd29 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/model_origin.go @@ -0,0 +1,16 @@ +package origins + +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 Origin struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OriginProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origins/model_originproperties.go b/resource-manager/cdn/2024-09-01/origins/model_originproperties.go new file mode 100644 index 00000000000..1c6a60f33a7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/model_originproperties.go @@ -0,0 +1,21 @@ +package origins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginProperties struct { + Enabled *bool `json:"enabled,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + Priority *int64 `json:"priority,omitempty"` + PrivateEndpointStatus *PrivateEndpointStatus `json:"privateEndpointStatus,omitempty"` + PrivateLinkAlias *string `json:"privateLinkAlias,omitempty"` + PrivateLinkApprovalMessage *string `json:"privateLinkApprovalMessage,omitempty"` + PrivateLinkLocation *string `json:"privateLinkLocation,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + ProvisioningState *OriginProvisioningState `json:"provisioningState,omitempty"` + ResourceState *OriginResourceState `json:"resourceState,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origins/model_originupdateparameters.go b/resource-manager/cdn/2024-09-01/origins/model_originupdateparameters.go new file mode 100644 index 00000000000..7277698e9d5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/model_originupdateparameters.go @@ -0,0 +1,8 @@ +package origins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginUpdateParameters struct { + Properties *OriginUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origins/model_originupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/origins/model_originupdatepropertiesparameters.go new file mode 100644 index 00000000000..c442bb8d4d9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/model_originupdatepropertiesparameters.go @@ -0,0 +1,18 @@ +package origins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginUpdatePropertiesParameters struct { + Enabled *bool `json:"enabled,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + OriginHostHeader *string `json:"originHostHeader,omitempty"` + Priority *int64 `json:"priority,omitempty"` + PrivateLinkAlias *string `json:"privateLinkAlias,omitempty"` + PrivateLinkApprovalMessage *string `json:"privateLinkApprovalMessage,omitempty"` + PrivateLinkLocation *string `json:"privateLinkLocation,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/origins/predicates.go b/resource-manager/cdn/2024-09-01/origins/predicates.go new file mode 100644 index 00000000000..2424013ceb9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/predicates.go @@ -0,0 +1,27 @@ +package origins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p OriginOperationPredicate) Matches(input Origin) 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/cdn/2024-09-01/origins/version.go b/resource-manager/cdn/2024-09-01/origins/version.go new file mode 100644 index 00000000000..9ecc07ba5d4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/origins/version.go @@ -0,0 +1,10 @@ +package origins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/origins/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/profiles/README.md b/resource-manager/cdn/2024-09-01/profiles/README.md new file mode 100644 index 00000000000..47cf78529e0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/README.md @@ -0,0 +1,253 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/profiles` Documentation + +The `profiles` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/profiles" +``` + + +### Client Initialization + +```go +client := profiles.NewProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProfilesClient.CanMigrate` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := profiles.CanMigrateParameters{ + // ... +} + + +if err := client.CanMigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.CdnCanMigrateToAfd` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +if err := client.CdnCanMigrateToAfdThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.CdnMigrateToAfd` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := profiles.CdnMigrationToAfdParameters{ + // ... +} + + +if err := client.CdnMigrateToAfdThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.Create` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := profiles.Profile{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.Delete` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.GenerateSsoUri` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.GenerateSsoUri(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProfilesClient.Get` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +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: `ProfilesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `ProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProfilesClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProfilesClient.ListSupportedOptimizationTypes` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.ListSupportedOptimizationTypes(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProfilesClient.Migrate` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := profiles.MigrationParameters{ + // ... +} + + +if err := client.MigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.MigrationAbort` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +if err := client.MigrationAbortThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.MigrationCommit` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +if err := client.MigrationCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProfilesClient.Update` + +```go +ctx := context.TODO() +id := profiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +payload := profiles.ProfileUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/profiles/client.go b/resource-manager/cdn/2024-09-01/profiles/client.go new file mode 100644 index 00000000000..16eaef71194 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/client.go @@ -0,0 +1,26 @@ +package profiles + +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 ProfilesClient struct { + Client *resourcemanager.Client +} + +func NewProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*ProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "profiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProfilesClient: %+v", err) + } + + return &ProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/constants.go b/resource-manager/cdn/2024-09-01/profiles/constants.go new file mode 100644 index 00000000000..7c46f402b9a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/constants.go @@ -0,0 +1,489 @@ +package profiles + +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 CanMigrateDefaultSku string + +const ( + CanMigrateDefaultSkuPremiumAzureFrontDoor CanMigrateDefaultSku = "Premium_AzureFrontDoor" + CanMigrateDefaultSkuStandardAzureFrontDoor CanMigrateDefaultSku = "Standard_AzureFrontDoor" +) + +func PossibleValuesForCanMigrateDefaultSku() []string { + return []string{ + string(CanMigrateDefaultSkuPremiumAzureFrontDoor), + string(CanMigrateDefaultSkuStandardAzureFrontDoor), + } +} + +func (s *CanMigrateDefaultSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCanMigrateDefaultSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCanMigrateDefaultSku(input string) (*CanMigrateDefaultSku, error) { + vals := map[string]CanMigrateDefaultSku{ + "premium_azurefrontdoor": CanMigrateDefaultSkuPremiumAzureFrontDoor, + "standard_azurefrontdoor": CanMigrateDefaultSkuStandardAzureFrontDoor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CanMigrateDefaultSku(input) + return &out, nil +} + +type OptimizationType string + +const ( + OptimizationTypeDynamicSiteAcceleration OptimizationType = "DynamicSiteAcceleration" + OptimizationTypeGeneralMediaStreaming OptimizationType = "GeneralMediaStreaming" + OptimizationTypeGeneralWebDelivery OptimizationType = "GeneralWebDelivery" + OptimizationTypeLargeFileDownload OptimizationType = "LargeFileDownload" + OptimizationTypeVideoOnDemandMediaStreaming OptimizationType = "VideoOnDemandMediaStreaming" +) + +func PossibleValuesForOptimizationType() []string { + return []string{ + string(OptimizationTypeDynamicSiteAcceleration), + string(OptimizationTypeGeneralMediaStreaming), + string(OptimizationTypeGeneralWebDelivery), + string(OptimizationTypeLargeFileDownload), + string(OptimizationTypeVideoOnDemandMediaStreaming), + } +} + +func (s *OptimizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOptimizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOptimizationType(input string) (*OptimizationType, error) { + vals := map[string]OptimizationType{ + "dynamicsiteacceleration": OptimizationTypeDynamicSiteAcceleration, + "generalmediastreaming": OptimizationTypeGeneralMediaStreaming, + "generalwebdelivery": OptimizationTypeGeneralWebDelivery, + "largefiledownload": OptimizationTypeLargeFileDownload, + "videoondemandmediastreaming": OptimizationTypeVideoOnDemandMediaStreaming, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OptimizationType(input) + return &out, nil +} + +type ProfileProvisioningState string + +const ( + ProfileProvisioningStateCreating ProfileProvisioningState = "Creating" + ProfileProvisioningStateDeleting ProfileProvisioningState = "Deleting" + ProfileProvisioningStateFailed ProfileProvisioningState = "Failed" + ProfileProvisioningStateSucceeded ProfileProvisioningState = "Succeeded" + ProfileProvisioningStateUpdating ProfileProvisioningState = "Updating" +) + +func PossibleValuesForProfileProvisioningState() []string { + return []string{ + string(ProfileProvisioningStateCreating), + string(ProfileProvisioningStateDeleting), + string(ProfileProvisioningStateFailed), + string(ProfileProvisioningStateSucceeded), + string(ProfileProvisioningStateUpdating), + } +} + +func (s *ProfileProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileProvisioningState(input string) (*ProfileProvisioningState, error) { + vals := map[string]ProfileProvisioningState{ + "creating": ProfileProvisioningStateCreating, + "deleting": ProfileProvisioningStateDeleting, + "failed": ProfileProvisioningStateFailed, + "succeeded": ProfileProvisioningStateSucceeded, + "updating": ProfileProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileProvisioningState(input) + return &out, nil +} + +type ProfileResourceState string + +const ( + ProfileResourceStateAbortingMigration ProfileResourceState = "AbortingMigration" + ProfileResourceStateActive ProfileResourceState = "Active" + ProfileResourceStateCommittingMigration ProfileResourceState = "CommittingMigration" + ProfileResourceStateCreating ProfileResourceState = "Creating" + ProfileResourceStateDeleting ProfileResourceState = "Deleting" + ProfileResourceStateDisabled ProfileResourceState = "Disabled" + ProfileResourceStateMigrated ProfileResourceState = "Migrated" + ProfileResourceStateMigrating ProfileResourceState = "Migrating" + ProfileResourceStatePendingMigrationCommit ProfileResourceState = "PendingMigrationCommit" +) + +func PossibleValuesForProfileResourceState() []string { + return []string{ + string(ProfileResourceStateAbortingMigration), + string(ProfileResourceStateActive), + string(ProfileResourceStateCommittingMigration), + string(ProfileResourceStateCreating), + string(ProfileResourceStateDeleting), + string(ProfileResourceStateDisabled), + string(ProfileResourceStateMigrated), + string(ProfileResourceStateMigrating), + string(ProfileResourceStatePendingMigrationCommit), + } +} + +func (s *ProfileResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileResourceState(input string) (*ProfileResourceState, error) { + vals := map[string]ProfileResourceState{ + "abortingmigration": ProfileResourceStateAbortingMigration, + "active": ProfileResourceStateActive, + "committingmigration": ProfileResourceStateCommittingMigration, + "creating": ProfileResourceStateCreating, + "deleting": ProfileResourceStateDeleting, + "disabled": ProfileResourceStateDisabled, + "migrated": ProfileResourceStateMigrated, + "migrating": ProfileResourceStateMigrating, + "pendingmigrationcommit": ProfileResourceStatePendingMigrationCommit, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileResourceState(input) + return &out, nil +} + +type ProfileScrubbingState string + +const ( + ProfileScrubbingStateDisabled ProfileScrubbingState = "Disabled" + ProfileScrubbingStateEnabled ProfileScrubbingState = "Enabled" +) + +func PossibleValuesForProfileScrubbingState() []string { + return []string{ + string(ProfileScrubbingStateDisabled), + string(ProfileScrubbingStateEnabled), + } +} + +func (s *ProfileScrubbingState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileScrubbingState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileScrubbingState(input string) (*ProfileScrubbingState, error) { + vals := map[string]ProfileScrubbingState{ + "disabled": ProfileScrubbingStateDisabled, + "enabled": ProfileScrubbingStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileScrubbingState(input) + return &out, nil +} + +type ResourceUsageUnit string + +const ( + ResourceUsageUnitCount ResourceUsageUnit = "count" +) + +func PossibleValuesForResourceUsageUnit() []string { + return []string{ + string(ResourceUsageUnitCount), + } +} + +func (s *ResourceUsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceUsageUnit(input string) (*ResourceUsageUnit, error) { + vals := map[string]ResourceUsageUnit{ + "count": ResourceUsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceUsageUnit(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchOperator string + +const ( + ScrubbingRuleEntryMatchOperatorEqualsAny ScrubbingRuleEntryMatchOperator = "EqualsAny" +) + +func PossibleValuesForScrubbingRuleEntryMatchOperator() []string { + return []string{ + string(ScrubbingRuleEntryMatchOperatorEqualsAny), + } +} + +func (s *ScrubbingRuleEntryMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchOperator(input string) (*ScrubbingRuleEntryMatchOperator, error) { + vals := map[string]ScrubbingRuleEntryMatchOperator{ + "equalsany": ScrubbingRuleEntryMatchOperatorEqualsAny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchOperator(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchVariable string + +const ( + ScrubbingRuleEntryMatchVariableQueryStringArgNames ScrubbingRuleEntryMatchVariable = "QueryStringArgNames" + ScrubbingRuleEntryMatchVariableRequestIPAddress ScrubbingRuleEntryMatchVariable = "RequestIPAddress" + ScrubbingRuleEntryMatchVariableRequestUri ScrubbingRuleEntryMatchVariable = "RequestUri" +) + +func PossibleValuesForScrubbingRuleEntryMatchVariable() []string { + return []string{ + string(ScrubbingRuleEntryMatchVariableQueryStringArgNames), + string(ScrubbingRuleEntryMatchVariableRequestIPAddress), + string(ScrubbingRuleEntryMatchVariableRequestUri), + } +} + +func (s *ScrubbingRuleEntryMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchVariable(input string) (*ScrubbingRuleEntryMatchVariable, error) { + vals := map[string]ScrubbingRuleEntryMatchVariable{ + "querystringargnames": ScrubbingRuleEntryMatchVariableQueryStringArgNames, + "requestipaddress": ScrubbingRuleEntryMatchVariableRequestIPAddress, + "requesturi": ScrubbingRuleEntryMatchVariableRequestUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchVariable(input) + return &out, nil +} + +type ScrubbingRuleEntryState string + +const ( + ScrubbingRuleEntryStateDisabled ScrubbingRuleEntryState = "Disabled" + ScrubbingRuleEntryStateEnabled ScrubbingRuleEntryState = "Enabled" +) + +func PossibleValuesForScrubbingRuleEntryState() []string { + return []string{ + string(ScrubbingRuleEntryStateDisabled), + string(ScrubbingRuleEntryStateEnabled), + } +} + +func (s *ScrubbingRuleEntryState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryState(input string) (*ScrubbingRuleEntryState, error) { + vals := map[string]ScrubbingRuleEntryState{ + "disabled": ScrubbingRuleEntryStateDisabled, + "enabled": ScrubbingRuleEntryStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameCustomVerizon SkuName = "Custom_Verizon" + SkuNamePremiumAzureFrontDoor SkuName = "Premium_AzureFrontDoor" + SkuNamePremiumVerizon SkuName = "Premium_Verizon" + SkuNameStandardAkamai SkuName = "Standard_Akamai" + SkuNameStandardAvgBandWidthChinaCdn SkuName = "Standard_AvgBandWidth_ChinaCdn" + SkuNameStandardAzureFrontDoor SkuName = "Standard_AzureFrontDoor" + SkuNameStandardChinaCdn SkuName = "Standard_ChinaCdn" + SkuNameStandardMicrosoft SkuName = "Standard_Microsoft" + SkuNameStandardNineFiveFiveBandWidthChinaCdn SkuName = "Standard_955BandWidth_ChinaCdn" + SkuNameStandardPlusAvgBandWidthChinaCdn SkuName = "StandardPlus_AvgBandWidth_ChinaCdn" + SkuNameStandardPlusChinaCdn SkuName = "StandardPlus_ChinaCdn" + SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn SkuName = "StandardPlus_955BandWidth_ChinaCdn" + SkuNameStandardVerizon SkuName = "Standard_Verizon" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameCustomVerizon), + string(SkuNamePremiumAzureFrontDoor), + string(SkuNamePremiumVerizon), + string(SkuNameStandardAkamai), + string(SkuNameStandardAvgBandWidthChinaCdn), + string(SkuNameStandardAzureFrontDoor), + string(SkuNameStandardChinaCdn), + string(SkuNameStandardMicrosoft), + string(SkuNameStandardNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardPlusAvgBandWidthChinaCdn), + string(SkuNameStandardPlusChinaCdn), + string(SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardVerizon), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "custom_verizon": SkuNameCustomVerizon, + "premium_azurefrontdoor": SkuNamePremiumAzureFrontDoor, + "premium_verizon": SkuNamePremiumVerizon, + "standard_akamai": SkuNameStandardAkamai, + "standard_avgbandwidth_chinacdn": SkuNameStandardAvgBandWidthChinaCdn, + "standard_azurefrontdoor": SkuNameStandardAzureFrontDoor, + "standard_chinacdn": SkuNameStandardChinaCdn, + "standard_microsoft": SkuNameStandardMicrosoft, + "standard_955bandwidth_chinacdn": SkuNameStandardNineFiveFiveBandWidthChinaCdn, + "standardplus_avgbandwidth_chinacdn": SkuNameStandardPlusAvgBandWidthChinaCdn, + "standardplus_chinacdn": SkuNameStandardPlusChinaCdn, + "standardplus_955bandwidth_chinacdn": SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn, + "standard_verizon": SkuNameStandardVerizon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/id_profile.go b/resource-manager/cdn/2024-09-01/profiles/id_profile.go new file mode 100644 index 00000000000..41542427251 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/id_profile.go @@ -0,0 +1,130 @@ +package profiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/profiles/id_profile_test.go b/resource-manager/cdn/2024-09-01/profiles/id_profile_test.go new file mode 100644 index 00000000000..0d1b4273bc8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/id_profile_test.go @@ -0,0 +1,282 @@ +package profiles + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/profiles/method_canmigrate.go b/resource-manager/cdn/2024-09-01/profiles/method_canmigrate.go new file mode 100644 index 00000000000..edda0638219 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_canmigrate.go @@ -0,0 +1,76 @@ +package profiles + +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 CanMigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CanMigrateResult +} + +// CanMigrate ... +func (c ProfilesClient) CanMigrate(ctx context.Context, id commonids.ResourceGroupId, input CanMigrateParameters) (result CanMigrateOperationResponse, 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.CDN/canMigrate", 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 +} + +// CanMigrateThenPoll performs CanMigrate then polls until it's completed +func (c ProfilesClient) CanMigrateThenPoll(ctx context.Context, id commonids.ResourceGroupId, input CanMigrateParameters) error { + result, err := c.CanMigrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CanMigrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CanMigrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_cdncanmigratetoafd.go b/resource-manager/cdn/2024-09-01/profiles/method_cdncanmigratetoafd.go new file mode 100644 index 00000000000..374c4d8bd18 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_cdncanmigratetoafd.go @@ -0,0 +1,71 @@ +package profiles + +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 CdnCanMigrateToAfdOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CanMigrateResult +} + +// CdnCanMigrateToAfd ... +func (c ProfilesClient) CdnCanMigrateToAfd(ctx context.Context, id ProfileId) (result CdnCanMigrateToAfdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cdnCanMigrateToAfd", 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 +} + +// CdnCanMigrateToAfdThenPoll performs CdnCanMigrateToAfd then polls until it's completed +func (c ProfilesClient) CdnCanMigrateToAfdThenPoll(ctx context.Context, id ProfileId) error { + result, err := c.CdnCanMigrateToAfd(ctx, id) + if err != nil { + return fmt.Errorf("performing CdnCanMigrateToAfd: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CdnCanMigrateToAfd: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_cdnmigratetoafd.go b/resource-manager/cdn/2024-09-01/profiles/method_cdnmigratetoafd.go new file mode 100644 index 00000000000..6bfd5f4039b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_cdnmigratetoafd.go @@ -0,0 +1,75 @@ +package profiles + +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 CdnMigrateToAfdOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrateResult +} + +// CdnMigrateToAfd ... +func (c ProfilesClient) CdnMigrateToAfd(ctx context.Context, id ProfileId, input CdnMigrationToAfdParameters) (result CdnMigrateToAfdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cdnMigrateToAfd", 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 +} + +// CdnMigrateToAfdThenPoll performs CdnMigrateToAfd then polls until it's completed +func (c ProfilesClient) CdnMigrateToAfdThenPoll(ctx context.Context, id ProfileId, input CdnMigrationToAfdParameters) error { + result, err := c.CdnMigrateToAfd(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CdnMigrateToAfd: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CdnMigrateToAfd: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_create.go b/resource-manager/cdn/2024-09-01/profiles/method_create.go new file mode 100644 index 00000000000..fdde9d737ec --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_create.go @@ -0,0 +1,76 @@ +package profiles + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Profile +} + +// Create ... +func (c ProfilesClient) Create(ctx context.Context, id ProfileId, input Profile) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ProfilesClient) CreateThenPoll(ctx context.Context, id ProfileId, input Profile) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_delete.go b/resource-manager/cdn/2024-09-01/profiles/method_delete.go new file mode 100644 index 00000000000..8d46fe3a4ff --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_delete.go @@ -0,0 +1,71 @@ +package profiles + +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 ProfilesClient) Delete(ctx context.Context, id ProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ProfilesClient) DeleteThenPoll(ctx context.Context, id ProfileId) 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/cdn/2024-09-01/profiles/method_generatessouri.go b/resource-manager/cdn/2024-09-01/profiles/method_generatessouri.go new file mode 100644 index 00000000000..763f54f9cc5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_generatessouri.go @@ -0,0 +1,54 @@ +package profiles + +import ( + "context" + "fmt" + "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 GenerateSsoUriOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SsoUri +} + +// GenerateSsoUri ... +func (c ProfilesClient) GenerateSsoUri(ctx context.Context, id ProfileId) (result GenerateSsoUriOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateSsoUri", 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 + } + + var model SsoUri + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_get.go b/resource-manager/cdn/2024-09-01/profiles/method_get.go new file mode 100644 index 00000000000..d26affa96a5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_get.go @@ -0,0 +1,53 @@ +package profiles + +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 *Profile +} + +// Get ... +func (c ProfilesClient) Get(ctx context.Context, id ProfileId) (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 + } + + var model Profile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_list.go b/resource-manager/cdn/2024-09-01/profiles/method_list.go new file mode 100644 index 00000000000..3a6e95d2b42 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_list.go @@ -0,0 +1,106 @@ +package profiles + +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 *[]Profile +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Profile +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ProfilesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/profiles", 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 *[]Profile `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 ProfilesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProfileOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProfilesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ProfileOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Profile, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/cdn/2024-09-01/profiles/method_listbyresourcegroup.go b/resource-manager/cdn/2024-09-01/profiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..da005d4d92c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package profiles + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Profile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Profile +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/profiles", 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 *[]Profile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Profile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/profiles/method_listresourceusage.go new file mode 100644 index 00000000000..1f51a1643fd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_listresourceusage.go @@ -0,0 +1,105 @@ +package profiles + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceUsage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceUsage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c ProfilesClient) ListResourceUsage(ctx context.Context, id ProfileId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/checkResourceUsage", 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 *[]ResourceUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c ProfilesClient) ListResourceUsageComplete(ctx context.Context, id ProfileId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, ResourceUsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProfilesClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate ResourceUsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]ResourceUsage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_listsupportedoptimizationtypes.go b/resource-manager/cdn/2024-09-01/profiles/method_listsupportedoptimizationtypes.go new file mode 100644 index 00000000000..e743655689a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_listsupportedoptimizationtypes.go @@ -0,0 +1,54 @@ +package profiles + +import ( + "context" + "fmt" + "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 ListSupportedOptimizationTypesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SupportedOptimizationTypesListResult +} + +// ListSupportedOptimizationTypes ... +func (c ProfilesClient) ListSupportedOptimizationTypes(ctx context.Context, id ProfileId) (result ListSupportedOptimizationTypesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getSupportedOptimizationTypes", 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 + } + + var model SupportedOptimizationTypesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_migrate.go b/resource-manager/cdn/2024-09-01/profiles/method_migrate.go new file mode 100644 index 00000000000..cb3ea6cce65 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_migrate.go @@ -0,0 +1,76 @@ +package profiles + +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 MigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrateResult +} + +// Migrate ... +func (c ProfilesClient) Migrate(ctx context.Context, id commonids.ResourceGroupId, input MigrationParameters) (result MigrateOperationResponse, 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.CDN/migrate", 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 +} + +// MigrateThenPoll performs Migrate then polls until it's completed +func (c ProfilesClient) MigrateThenPoll(ctx context.Context, id commonids.ResourceGroupId, input MigrationParameters) error { + result, err := c.Migrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Migrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Migrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_migrationabort.go b/resource-manager/cdn/2024-09-01/profiles/method_migrationabort.go new file mode 100644 index 00000000000..85b18d157c1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_migrationabort.go @@ -0,0 +1,69 @@ +package profiles + +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 MigrationAbortOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrationAbort ... +func (c ProfilesClient) MigrationAbort(ctx context.Context, id ProfileId) (result MigrationAbortOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrationAbort", 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 +} + +// MigrationAbortThenPoll performs MigrationAbort then polls until it's completed +func (c ProfilesClient) MigrationAbortThenPoll(ctx context.Context, id ProfileId) error { + result, err := c.MigrationAbort(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrationAbort: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrationAbort: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_migrationcommit.go b/resource-manager/cdn/2024-09-01/profiles/method_migrationcommit.go new file mode 100644 index 00000000000..eb5e0a88a27 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_migrationcommit.go @@ -0,0 +1,70 @@ +package profiles + +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 MigrationCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrationCommit ... +func (c ProfilesClient) MigrationCommit(ctx context.Context, id ProfileId) (result MigrationCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrationCommit", 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 +} + +// MigrationCommitThenPoll performs MigrationCommit then polls until it's completed +func (c ProfilesClient) MigrationCommitThenPoll(ctx context.Context, id ProfileId) error { + result, err := c.MigrationCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrationCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrationCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/profiles/method_update.go b/resource-manager/cdn/2024-09-01/profiles/method_update.go new file mode 100644 index 00000000000..5694b5666a6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/method_update.go @@ -0,0 +1,75 @@ +package profiles + +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 + Model *Profile +} + +// Update ... +func (c ProfilesClient) Update(ctx context.Context, id ProfileId, input ProfileUpdateParameters) (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 ProfilesClient) UpdateThenPoll(ctx context.Context, id ProfileId, input ProfileUpdateParameters) 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/cdn/2024-09-01/profiles/model_canmigrateparameters.go b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateparameters.go new file mode 100644 index 00000000000..cba030af8d7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateparameters.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CanMigrateParameters struct { + ClassicResourceReference ResourceReference `json:"classicResourceReference"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_canmigrateproperties.go b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateproperties.go new file mode 100644 index 00000000000..8a79f4648c1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateproperties.go @@ -0,0 +1,10 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CanMigrateProperties struct { + CanMigrate *bool `json:"canMigrate,omitempty"` + DefaultSku *CanMigrateDefaultSku `json:"defaultSku,omitempty"` + Errors *[]MigrationErrorType `json:"errors,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_canmigrateresult.go b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateresult.go new file mode 100644 index 00000000000..500699ff775 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_canmigrateresult.go @@ -0,0 +1,10 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CanMigrateResult struct { + Id *string `json:"id,omitempty"` + Properties *CanMigrateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_cdnmigrationtoafdparameters.go b/resource-manager/cdn/2024-09-01/profiles/model_cdnmigrationtoafdparameters.go new file mode 100644 index 00000000000..094fabf1c46 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_cdnmigrationtoafdparameters.go @@ -0,0 +1,9 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CdnMigrationToAfdParameters struct { + MigrationEndpointMappings *[]MigrationEndpointMapping `json:"migrationEndpointMappings,omitempty"` + Sku Sku `json:"sku"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrateresult.go b/resource-manager/cdn/2024-09-01/profiles/model_migrateresult.go new file mode 100644 index 00000000000..c53f7a73fc5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrateresult.go @@ -0,0 +1,10 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateResult struct { + Id *string `json:"id,omitempty"` + Properties *MigrateResultProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrateresultproperties.go b/resource-manager/cdn/2024-09-01/profiles/model_migrateresultproperties.go new file mode 100644 index 00000000000..ad533db013d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrateresultproperties.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateResultProperties struct { + MigratedProfileResourceId *ResourceReference `json:"migratedProfileResourceId,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrationendpointmapping.go b/resource-manager/cdn/2024-09-01/profiles/model_migrationendpointmapping.go new file mode 100644 index 00000000000..9d0a3ded3cd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrationendpointmapping.go @@ -0,0 +1,9 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationEndpointMapping struct { + MigratedFrom *string `json:"migratedFrom,omitempty"` + MigratedTo *string `json:"migratedTo,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrationerrortype.go b/resource-manager/cdn/2024-09-01/profiles/model_migrationerrortype.go new file mode 100644 index 00000000000..6155279d9c1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrationerrortype.go @@ -0,0 +1,11 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationErrorType struct { + Code *string `json:"code,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + NextSteps *string `json:"nextSteps,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrationparameters.go b/resource-manager/cdn/2024-09-01/profiles/model_migrationparameters.go new file mode 100644 index 00000000000..37a14cc634b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrationparameters.go @@ -0,0 +1,11 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationParameters struct { + ClassicResourceReference ResourceReference `json:"classicResourceReference"` + MigrationWebApplicationFirewallMappings *[]MigrationWebApplicationFirewallMapping `json:"migrationWebApplicationFirewallMappings,omitempty"` + ProfileName string `json:"profileName"` + Sku Sku `json:"sku"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_migrationwebapplicationfirewallmapping.go b/resource-manager/cdn/2024-09-01/profiles/model_migrationwebapplicationfirewallmapping.go new file mode 100644 index 00000000000..342be305588 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_migrationwebapplicationfirewallmapping.go @@ -0,0 +1,9 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationWebApplicationFirewallMapping struct { + MigratedFrom *ResourceReference `json:"migratedFrom,omitempty"` + MigratedTo *ResourceReference `json:"migratedTo,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profile.go b/resource-manager/cdn/2024-09-01/profiles/model_profile.go new file mode 100644 index 00000000000..2568ad9b130 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profile.go @@ -0,0 +1,22 @@ +package profiles + +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 Profile struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ProfileProperties `json:"properties,omitempty"` + Sku Sku `json:"sku"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profilelogscrubbing.go b/resource-manager/cdn/2024-09-01/profiles/model_profilelogscrubbing.go new file mode 100644 index 00000000000..f897715e8c2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profilelogscrubbing.go @@ -0,0 +1,9 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileLogScrubbing struct { + ScrubbingRules *[]ProfileScrubbingRules `json:"scrubbingRules,omitempty"` + State *ProfileScrubbingState `json:"state,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profileproperties.go b/resource-manager/cdn/2024-09-01/profiles/model_profileproperties.go new file mode 100644 index 00000000000..6c9e4d175b4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profileproperties.go @@ -0,0 +1,13 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileProperties struct { + ExtendedProperties *map[string]string `json:"extendedProperties,omitempty"` + FrontDoorId *string `json:"frontDoorId,omitempty"` + LogScrubbing *ProfileLogScrubbing `json:"logScrubbing,omitempty"` + OriginResponseTimeoutSeconds *int64 `json:"originResponseTimeoutSeconds,omitempty"` + ProvisioningState *ProfileProvisioningState `json:"provisioningState,omitempty"` + ResourceState *ProfileResourceState `json:"resourceState,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profilepropertiesupdateparameters.go b/resource-manager/cdn/2024-09-01/profiles/model_profilepropertiesupdateparameters.go new file mode 100644 index 00000000000..01d3dc5ad0e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profilepropertiesupdateparameters.go @@ -0,0 +1,9 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfilePropertiesUpdateParameters struct { + LogScrubbing *ProfileLogScrubbing `json:"logScrubbing,omitempty"` + OriginResponseTimeoutSeconds *int64 `json:"originResponseTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profilescrubbingrules.go b/resource-manager/cdn/2024-09-01/profiles/model_profilescrubbingrules.go new file mode 100644 index 00000000000..9ed138086f8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profilescrubbingrules.go @@ -0,0 +1,11 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileScrubbingRules struct { + MatchVariable ScrubbingRuleEntryMatchVariable `json:"matchVariable"` + Selector *string `json:"selector,omitempty"` + SelectorMatchOperator ScrubbingRuleEntryMatchOperator `json:"selectorMatchOperator"` + State *ScrubbingRuleEntryState `json:"state,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_profileupdateparameters.go b/resource-manager/cdn/2024-09-01/profiles/model_profileupdateparameters.go new file mode 100644 index 00000000000..01c4b966536 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_profileupdateparameters.go @@ -0,0 +1,14 @@ +package profiles + +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 ProfileUpdateParameters struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ProfilePropertiesUpdateParameters `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_resourcereference.go b/resource-manager/cdn/2024-09-01/profiles/model_resourcereference.go new file mode 100644 index 00000000000..3e5faa3a3d7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_resourcereference.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_resourceusage.go b/resource-manager/cdn/2024-09-01/profiles/model_resourceusage.go new file mode 100644 index 00000000000..f56db4430e2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_resourceusage.go @@ -0,0 +1,11 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Unit *ResourceUsageUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_sku.go b/resource-manager/cdn/2024-09-01/profiles/model_sku.go new file mode 100644 index 00000000000..a70d546bfd6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_sku.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_ssouri.go b/resource-manager/cdn/2024-09-01/profiles/model_ssouri.go new file mode 100644 index 00000000000..ae93b0584f8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_ssouri.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SsoUri struct { + SsoUriValue *string `json:"ssoUriValue,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/model_supportedoptimizationtypeslistresult.go b/resource-manager/cdn/2024-09-01/profiles/model_supportedoptimizationtypeslistresult.go new file mode 100644 index 00000000000..1242943b3db --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/model_supportedoptimizationtypeslistresult.go @@ -0,0 +1,8 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOptimizationTypesListResult struct { + SupportedOptimizationTypes *[]OptimizationType `json:"supportedOptimizationTypes,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/profiles/predicates.go b/resource-manager/cdn/2024-09-01/profiles/predicates.go new file mode 100644 index 00000000000..f48c2803370 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/predicates.go @@ -0,0 +1,60 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ProfileOperationPredicate) Matches(input Profile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ResourceUsageOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + ResourceType *string +} + +func (p ResourceUsageOperationPredicate) Matches(input ResourceUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/profiles/version.go b/resource-manager/cdn/2024-09-01/profiles/version.go new file mode 100644 index 00000000000..40e419a6af9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/profiles/version.go @@ -0,0 +1,10 @@ +package profiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/profiles/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/routes/README.md b/resource-manager/cdn/2024-09-01/routes/README.md new file mode 100644 index 00000000000..e6311a3b9e0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/routes` Documentation + +The `routes` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/routes" +``` + + +### Client Initialization + +```go +client := routes.NewRoutesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RoutesClient.Create` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName") + +payload := routes.Route{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutesClient.Delete` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutesClient.Get` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName") + +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: `RoutesClient.ListByEndpoint` + +```go +ctx := context.TODO() +id := routes.NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + +// alternatively `client.ListByEndpoint(ctx, id)` can be used to do batched pagination +items, err := client.ListByEndpointComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RoutesClient.Update` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName") + +payload := routes.RouteUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/routes/client.go b/resource-manager/cdn/2024-09-01/routes/client.go new file mode 100644 index 00000000000..88e9f135cd1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/client.go @@ -0,0 +1,26 @@ +package routes + +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 RoutesClient struct { + Client *resourcemanager.Client +} + +func NewRoutesClientWithBaseURI(sdkApi sdkEnv.Api) (*RoutesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RoutesClient: %+v", err) + } + + return &RoutesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/routes/constants.go b/resource-manager/cdn/2024-09-01/routes/constants.go new file mode 100644 index 00000000000..86d0195a3fb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/constants.go @@ -0,0 +1,362 @@ +package routes + +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 AFDEndpointProtocols string + +const ( + AFDEndpointProtocolsHTTP AFDEndpointProtocols = "Http" + AFDEndpointProtocolsHTTPS AFDEndpointProtocols = "Https" +) + +func PossibleValuesForAFDEndpointProtocols() []string { + return []string{ + string(AFDEndpointProtocolsHTTP), + string(AFDEndpointProtocolsHTTPS), + } +} + +func (s *AFDEndpointProtocols) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAFDEndpointProtocols(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAFDEndpointProtocols(input string) (*AFDEndpointProtocols, error) { + vals := map[string]AFDEndpointProtocols{ + "http": AFDEndpointProtocolsHTTP, + "https": AFDEndpointProtocolsHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AFDEndpointProtocols(input) + return &out, nil +} + +type AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type AfdQueryStringCachingBehavior string + +const ( + AfdQueryStringCachingBehaviorIgnoreQueryString AfdQueryStringCachingBehavior = "IgnoreQueryString" + AfdQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings AfdQueryStringCachingBehavior = "IgnoreSpecifiedQueryStrings" + AfdQueryStringCachingBehaviorIncludeSpecifiedQueryStrings AfdQueryStringCachingBehavior = "IncludeSpecifiedQueryStrings" + AfdQueryStringCachingBehaviorUseQueryString AfdQueryStringCachingBehavior = "UseQueryString" +) + +func PossibleValuesForAfdQueryStringCachingBehavior() []string { + return []string{ + string(AfdQueryStringCachingBehaviorIgnoreQueryString), + string(AfdQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings), + string(AfdQueryStringCachingBehaviorIncludeSpecifiedQueryStrings), + string(AfdQueryStringCachingBehaviorUseQueryString), + } +} + +func (s *AfdQueryStringCachingBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdQueryStringCachingBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdQueryStringCachingBehavior(input string) (*AfdQueryStringCachingBehavior, error) { + vals := map[string]AfdQueryStringCachingBehavior{ + "ignorequerystring": AfdQueryStringCachingBehaviorIgnoreQueryString, + "ignorespecifiedquerystrings": AfdQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings, + "includespecifiedquerystrings": AfdQueryStringCachingBehaviorIncludeSpecifiedQueryStrings, + "usequerystring": AfdQueryStringCachingBehaviorUseQueryString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdQueryStringCachingBehavior(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type EnabledState string + +const ( + EnabledStateDisabled EnabledState = "Disabled" + EnabledStateEnabled EnabledState = "Enabled" +) + +func PossibleValuesForEnabledState() []string { + return []string{ + string(EnabledStateDisabled), + string(EnabledStateEnabled), + } +} + +func (s *EnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnabledState(input string) (*EnabledState, error) { + vals := map[string]EnabledState{ + "disabled": EnabledStateDisabled, + "enabled": EnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnabledState(input) + return &out, nil +} + +type ForwardingProtocol string + +const ( + ForwardingProtocolHTTPOnly ForwardingProtocol = "HttpOnly" + ForwardingProtocolHTTPSOnly ForwardingProtocol = "HttpsOnly" + ForwardingProtocolMatchRequest ForwardingProtocol = "MatchRequest" +) + +func PossibleValuesForForwardingProtocol() []string { + return []string{ + string(ForwardingProtocolHTTPOnly), + string(ForwardingProtocolHTTPSOnly), + string(ForwardingProtocolMatchRequest), + } +} + +func (s *ForwardingProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardingProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardingProtocol(input string) (*ForwardingProtocol, error) { + vals := map[string]ForwardingProtocol{ + "httponly": ForwardingProtocolHTTPOnly, + "httpsonly": ForwardingProtocolHTTPSOnly, + "matchrequest": ForwardingProtocolMatchRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardingProtocol(input) + return &out, nil +} + +type HTTPSRedirect string + +const ( + HTTPSRedirectDisabled HTTPSRedirect = "Disabled" + HTTPSRedirectEnabled HTTPSRedirect = "Enabled" +) + +func PossibleValuesForHTTPSRedirect() []string { + return []string{ + string(HTTPSRedirectDisabled), + string(HTTPSRedirectEnabled), + } +} + +func (s *HTTPSRedirect) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPSRedirect(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHTTPSRedirect(input string) (*HTTPSRedirect, error) { + vals := map[string]HTTPSRedirect{ + "disabled": HTTPSRedirectDisabled, + "enabled": HTTPSRedirectEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HTTPSRedirect(input) + return &out, nil +} + +type LinkToDefaultDomain string + +const ( + LinkToDefaultDomainDisabled LinkToDefaultDomain = "Disabled" + LinkToDefaultDomainEnabled LinkToDefaultDomain = "Enabled" +) + +func PossibleValuesForLinkToDefaultDomain() []string { + return []string{ + string(LinkToDefaultDomainDisabled), + string(LinkToDefaultDomainEnabled), + } +} + +func (s *LinkToDefaultDomain) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinkToDefaultDomain(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinkToDefaultDomain(input string) (*LinkToDefaultDomain, error) { + vals := map[string]LinkToDefaultDomain{ + "disabled": LinkToDefaultDomainDisabled, + "enabled": LinkToDefaultDomainEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinkToDefaultDomain(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/routes/id_afdendpoint.go b/resource-manager/cdn/2024-09-01/routes/id_afdendpoint.go new file mode 100644 index 00000000000..8308687804f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/id_afdendpoint.go @@ -0,0 +1,139 @@ +package routes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AfdEndpointId{}) +} + +var _ resourceids.ResourceId = &AfdEndpointId{} + +// AfdEndpointId is a struct representing the Resource ID for a Afd Endpoint +type AfdEndpointId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + AfdEndpointName string +} + +// NewAfdEndpointID returns a new AfdEndpointId struct +func NewAfdEndpointID(subscriptionId string, resourceGroupName string, profileName string, afdEndpointName string) AfdEndpointId { + return AfdEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + AfdEndpointName: afdEndpointName, + } +} + +// ParseAfdEndpointID parses 'input' into a AfdEndpointId +func ParseAfdEndpointID(input string) (*AfdEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&AfdEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AfdEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAfdEndpointIDInsensitively parses 'input' case-insensitively into a AfdEndpointId +// note: this method should only be used for API response data and not user input +func ParseAfdEndpointIDInsensitively(input string) (*AfdEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&AfdEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AfdEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AfdEndpointId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.AfdEndpointName, ok = input.Parsed["afdEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "afdEndpointName", input) + } + + return nil +} + +// ValidateAfdEndpointID checks that 'input' can be parsed as a Afd Endpoint ID +func ValidateAfdEndpointID(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 := ParseAfdEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Afd Endpoint ID +func (id AfdEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/afdEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.AfdEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Afd Endpoint ID +func (id AfdEndpointId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticAfdEndpoints", "afdEndpoints", "afdEndpoints"), + resourceids.UserSpecifiedSegment("afdEndpointName", "afdEndpointName"), + } +} + +// String returns a human-readable description of this Afd Endpoint ID +func (id AfdEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Afd Endpoint Name: %q", id.AfdEndpointName), + } + return fmt.Sprintf("Afd Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/routes/id_afdendpoint_test.go b/resource-manager/cdn/2024-09-01/routes/id_afdendpoint_test.go new file mode 100644 index 00000000000..15dd4eba196 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/id_afdendpoint_test.go @@ -0,0 +1,327 @@ +package routes + +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 = &AfdEndpointId{} + +func TestNewAfdEndpointID(t *testing.T) { + id := NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.AfdEndpointName != "afdEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'AfdEndpointName'", id.AfdEndpointName, "afdEndpointName") + } +} + +func TestFormatAfdEndpointID(t *testing.T) { + actual := NewAfdEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAfdEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AfdEndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAfdEndpointID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + } +} + +func TestParseAfdEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AfdEndpointId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe", + Expected: &AfdEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + AfdEndpointName: "aFdEnDpOiNtNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAfdEndpointIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + } +} + +func TestSegmentsForAfdEndpointId(t *testing.T) { + segments := AfdEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AfdEndpointId 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/cdn/2024-09-01/routes/id_route.go b/resource-manager/cdn/2024-09-01/routes/id_route.go new file mode 100644 index 00000000000..f69c574f868 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/id_route.go @@ -0,0 +1,148 @@ +package routes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RouteId{}) +} + +var _ resourceids.ResourceId = &RouteId{} + +// RouteId is a struct representing the Resource ID for a Route +type RouteId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + AfdEndpointName string + RouteName string +} + +// NewRouteID returns a new RouteId struct +func NewRouteID(subscriptionId string, resourceGroupName string, profileName string, afdEndpointName string, routeName string) RouteId { + return RouteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + AfdEndpointName: afdEndpointName, + RouteName: routeName, + } +} + +// ParseRouteID parses 'input' into a RouteId +func ParseRouteID(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteIDInsensitively parses 'input' case-insensitively into a RouteId +// note: this method should only be used for API response data and not user input +func ParseRouteIDInsensitively(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.AfdEndpointName, ok = input.Parsed["afdEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "afdEndpointName", input) + } + + if id.RouteName, ok = input.Parsed["routeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeName", input) + } + + return nil +} + +// ValidateRouteID checks that 'input' can be parsed as a Route ID +func ValidateRouteID(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 := ParseRouteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route ID +func (id RouteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/afdEndpoints/%s/routes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.AfdEndpointName, id.RouteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route ID +func (id RouteId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticAfdEndpoints", "afdEndpoints", "afdEndpoints"), + resourceids.UserSpecifiedSegment("afdEndpointName", "afdEndpointName"), + resourceids.StaticSegment("staticRoutes", "routes", "routes"), + resourceids.UserSpecifiedSegment("routeName", "routeName"), + } +} + +// String returns a human-readable description of this Route ID +func (id RouteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Afd Endpoint Name: %q", id.AfdEndpointName), + fmt.Sprintf("Route Name: %q", id.RouteName), + } + return fmt.Sprintf("Route (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/routes/id_route_test.go b/resource-manager/cdn/2024-09-01/routes/id_route_test.go new file mode 100644 index 00000000000..63a14d96932 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/id_route_test.go @@ -0,0 +1,372 @@ +package routes + +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 = &RouteId{} + +func TestNewRouteID(t *testing.T) { + id := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.AfdEndpointName != "afdEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'AfdEndpointName'", id.AfdEndpointName, "afdEndpointName") + } + + if id.RouteName != "routeName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteName'", id.RouteName, "routeName") + } +} + +func TestFormatRouteID(t *testing.T) { + actual := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "afdEndpointName", "routeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes/routeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes/routeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestParseRouteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe/rOuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + AfdEndpointName: "afdEndpointName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/afdEndpoints/afdEndpointName/routes/routeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe/rOuTeS/rOuTeNaMe", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + AfdEndpointName: "aFdEnDpOiNtNaMe", + RouteName: "rOuTeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/aFdEnDpOiNtS/aFdEnDpOiNtNaMe/rOuTeS/rOuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AfdEndpointName != v.Expected.AfdEndpointName { + t.Fatalf("Expected %q but got %q for AfdEndpointName", v.Expected.AfdEndpointName, actual.AfdEndpointName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestSegmentsForRouteId(t *testing.T) { + segments := RouteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteId 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/cdn/2024-09-01/routes/method_create.go b/resource-manager/cdn/2024-09-01/routes/method_create.go new file mode 100644 index 00000000000..a2df43fefb7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/method_create.go @@ -0,0 +1,76 @@ +package routes + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Route +} + +// Create ... +func (c RoutesClient) Create(ctx context.Context, id RouteId, input Route) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c RoutesClient) CreateThenPoll(ctx context.Context, id RouteId, input Route) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/routes/method_delete.go b/resource-manager/cdn/2024-09-01/routes/method_delete.go new file mode 100644 index 00000000000..f6cee23c133 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/method_delete.go @@ -0,0 +1,71 @@ +package routes + +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 RoutesClient) Delete(ctx context.Context, id RouteId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 RoutesClient) DeleteThenPoll(ctx context.Context, id RouteId) 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/cdn/2024-09-01/routes/method_get.go b/resource-manager/cdn/2024-09-01/routes/method_get.go new file mode 100644 index 00000000000..306c6528c39 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/method_get.go @@ -0,0 +1,53 @@ +package routes + +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 *Route +} + +// Get ... +func (c RoutesClient) Get(ctx context.Context, id RouteId) (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 + } + + var model Route + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/routes/method_listbyendpoint.go b/resource-manager/cdn/2024-09-01/routes/method_listbyendpoint.go new file mode 100644 index 00000000000..ecac0980ee1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/method_listbyendpoint.go @@ -0,0 +1,105 @@ +package routes + +import ( + "context" + "fmt" + "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 ListByEndpointOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Route +} + +type ListByEndpointCompleteResult struct { + LatestHttpResponse *http.Response + Items []Route +} + +type ListByEndpointCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByEndpointCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByEndpoint ... +func (c RoutesClient) ListByEndpoint(ctx context.Context, id AfdEndpointId) (result ListByEndpointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByEndpointCustomPager{}, + Path: fmt.Sprintf("%s/routes", 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 *[]Route `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByEndpointComplete retrieves all the results into a single object +func (c RoutesClient) ListByEndpointComplete(ctx context.Context, id AfdEndpointId) (ListByEndpointCompleteResult, error) { + return c.ListByEndpointCompleteMatchingPredicate(ctx, id, RouteOperationPredicate{}) +} + +// ListByEndpointCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RoutesClient) ListByEndpointCompleteMatchingPredicate(ctx context.Context, id AfdEndpointId, predicate RouteOperationPredicate) (result ListByEndpointCompleteResult, err error) { + items := make([]Route, 0) + + resp, err := c.ListByEndpoint(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByEndpointCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/routes/method_update.go b/resource-manager/cdn/2024-09-01/routes/method_update.go new file mode 100644 index 00000000000..675feac0920 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/method_update.go @@ -0,0 +1,75 @@ +package routes + +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 + Model *Route +} + +// Update ... +func (c RoutesClient) Update(ctx context.Context, id RouteId, input RouteUpdateParameters) (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 RoutesClient) UpdateThenPoll(ctx context.Context, id RouteId, input RouteUpdateParameters) 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/cdn/2024-09-01/routes/model_activatedresourcereference.go b/resource-manager/cdn/2024-09-01/routes/model_activatedresourcereference.go new file mode 100644 index 00000000000..d8e6755a6d5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_activatedresourcereference.go @@ -0,0 +1,9 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivatedResourceReference struct { + Id *string `json:"id,omitempty"` + IsActive *bool `json:"isActive,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_afdroutecacheconfiguration.go b/resource-manager/cdn/2024-09-01/routes/model_afdroutecacheconfiguration.go new file mode 100644 index 00000000000..958a2a2c8dc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_afdroutecacheconfiguration.go @@ -0,0 +1,10 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AfdRouteCacheConfiguration struct { + CompressionSettings *CompressionSettings `json:"compressionSettings,omitempty"` + QueryParameters *string `json:"queryParameters,omitempty"` + QueryStringCachingBehavior *AfdQueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_compressionsettings.go b/resource-manager/cdn/2024-09-01/routes/model_compressionsettings.go new file mode 100644 index 00000000000..a8bf44d6e7f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_compressionsettings.go @@ -0,0 +1,9 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompressionSettings struct { + ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` + IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_resourcereference.go b/resource-manager/cdn/2024-09-01/routes/model_resourcereference.go new file mode 100644 index 00000000000..a5bfb930279 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_resourcereference.go @@ -0,0 +1,8 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_route.go b/resource-manager/cdn/2024-09-01/routes/model_route.go new file mode 100644 index 00000000000..aa2a2d24bad --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_route.go @@ -0,0 +1,16 @@ +package routes + +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 Route struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_routeproperties.go b/resource-manager/cdn/2024-09-01/routes/model_routeproperties.go new file mode 100644 index 00000000000..12df1741806 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_routeproperties.go @@ -0,0 +1,21 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteProperties struct { + CacheConfiguration *AfdRouteCacheConfiguration `json:"cacheConfiguration,omitempty"` + CustomDomains *[]ActivatedResourceReference `json:"customDomains,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + EnabledState *EnabledState `json:"enabledState,omitempty"` + EndpointName *string `json:"endpointName,omitempty"` + ForwardingProtocol *ForwardingProtocol `json:"forwardingProtocol,omitempty"` + HTTPSRedirect *HTTPSRedirect `json:"httpsRedirect,omitempty"` + LinkToDefaultDomain *LinkToDefaultDomain `json:"linkToDefaultDomain,omitempty"` + OriginGroup *ResourceReference `json:"originGroup,omitempty"` + OriginPath *string `json:"originPath,omitempty"` + PatternsToMatch *[]string `json:"patternsToMatch,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + RuleSets *[]ResourceReference `json:"ruleSets,omitempty"` + SupportedProtocols *[]AFDEndpointProtocols `json:"supportedProtocols,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_routeupdateparameters.go b/resource-manager/cdn/2024-09-01/routes/model_routeupdateparameters.go new file mode 100644 index 00000000000..8694841b13a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_routeupdateparameters.go @@ -0,0 +1,8 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteUpdateParameters struct { + Properties *RouteUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/model_routeupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/routes/model_routeupdatepropertiesparameters.go new file mode 100644 index 00000000000..bae7745f669 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/model_routeupdatepropertiesparameters.go @@ -0,0 +1,19 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteUpdatePropertiesParameters struct { + CacheConfiguration *AfdRouteCacheConfiguration `json:"cacheConfiguration,omitempty"` + CustomDomains *[]ActivatedResourceReference `json:"customDomains,omitempty"` + EnabledState *EnabledState `json:"enabledState,omitempty"` + EndpointName *string `json:"endpointName,omitempty"` + ForwardingProtocol *ForwardingProtocol `json:"forwardingProtocol,omitempty"` + HTTPSRedirect *HTTPSRedirect `json:"httpsRedirect,omitempty"` + LinkToDefaultDomain *LinkToDefaultDomain `json:"linkToDefaultDomain,omitempty"` + OriginGroup *ResourceReference `json:"originGroup,omitempty"` + OriginPath *string `json:"originPath,omitempty"` + PatternsToMatch *[]string `json:"patternsToMatch,omitempty"` + RuleSets *[]ResourceReference `json:"ruleSets,omitempty"` + SupportedProtocols *[]AFDEndpointProtocols `json:"supportedProtocols,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/routes/predicates.go b/resource-manager/cdn/2024-09-01/routes/predicates.go new file mode 100644 index 00000000000..81b2f212359 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/predicates.go @@ -0,0 +1,27 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RouteOperationPredicate) Matches(input Route) 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/cdn/2024-09-01/routes/version.go b/resource-manager/cdn/2024-09-01/routes/version.go new file mode 100644 index 00000000000..c9ebd2eda20 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/routes/version.go @@ -0,0 +1,10 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routes/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/rules/README.md b/resource-manager/cdn/2024-09-01/rules/README.md new file mode 100644 index 00000000000..c3ceffd5f8d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/rules` Documentation + +The `rules` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/rules" +``` + + +### Client Initialization + +```go +client := rules.NewRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RulesClient.Create` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName") + +payload := rules.Rule{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RulesClient.Delete` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RulesClient.Get` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName") + +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: `RulesClient.ListByRuleSet` + +```go +ctx := context.TODO() +id := rules.NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + +// alternatively `client.ListByRuleSet(ctx, id)` can be used to do batched pagination +items, err := client.ListByRuleSetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RulesClient.Update` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName") + +payload := rules.RuleUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/rules/client.go b/resource-manager/cdn/2024-09-01/rules/client.go new file mode 100644 index 00000000000..ee5a5154cef --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/client.go @@ -0,0 +1,26 @@ +package rules + +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 RulesClient struct { + Client *resourcemanager.Client +} + +func NewRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*RulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "rules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RulesClient: %+v", err) + } + + return &RulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/constants.go b/resource-manager/cdn/2024-09-01/rules/constants.go new file mode 100644 index 00000000000..6fb915180b5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/constants.go @@ -0,0 +1,2268 @@ +package rules + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type Algorithm string + +const ( + AlgorithmSHATwoFiveSix Algorithm = "SHA256" +) + +func PossibleValuesForAlgorithm() []string { + return []string{ + string(AlgorithmSHATwoFiveSix), + } +} + +func (s *Algorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlgorithm(input string) (*Algorithm, error) { + vals := map[string]Algorithm{ + "sha256": AlgorithmSHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Algorithm(input) + return &out, nil +} + +type CacheBehavior string + +const ( + CacheBehaviorBypassCache CacheBehavior = "BypassCache" + CacheBehaviorOverride CacheBehavior = "Override" + CacheBehaviorSetIfMissing CacheBehavior = "SetIfMissing" +) + +func PossibleValuesForCacheBehavior() []string { + return []string{ + string(CacheBehaviorBypassCache), + string(CacheBehaviorOverride), + string(CacheBehaviorSetIfMissing), + } +} + +func (s *CacheBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCacheBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCacheBehavior(input string) (*CacheBehavior, error) { + vals := map[string]CacheBehavior{ + "bypasscache": CacheBehaviorBypassCache, + "override": CacheBehaviorOverride, + "setifmissing": CacheBehaviorSetIfMissing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CacheBehavior(input) + return &out, nil +} + +type CacheType string + +const ( + CacheTypeAll CacheType = "All" +) + +func PossibleValuesForCacheType() []string { + return []string{ + string(CacheTypeAll), + } +} + +func (s *CacheType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCacheType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCacheType(input string) (*CacheType, error) { + vals := map[string]CacheType{ + "all": CacheTypeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CacheType(input) + return &out, nil +} + +type ClientPortOperator string + +const ( + ClientPortOperatorAny ClientPortOperator = "Any" + ClientPortOperatorBeginsWith ClientPortOperator = "BeginsWith" + ClientPortOperatorContains ClientPortOperator = "Contains" + ClientPortOperatorEndsWith ClientPortOperator = "EndsWith" + ClientPortOperatorEqual ClientPortOperator = "Equal" + ClientPortOperatorGreaterThan ClientPortOperator = "GreaterThan" + ClientPortOperatorGreaterThanOrEqual ClientPortOperator = "GreaterThanOrEqual" + ClientPortOperatorLessThan ClientPortOperator = "LessThan" + ClientPortOperatorLessThanOrEqual ClientPortOperator = "LessThanOrEqual" + ClientPortOperatorRegEx ClientPortOperator = "RegEx" +) + +func PossibleValuesForClientPortOperator() []string { + return []string{ + string(ClientPortOperatorAny), + string(ClientPortOperatorBeginsWith), + string(ClientPortOperatorContains), + string(ClientPortOperatorEndsWith), + string(ClientPortOperatorEqual), + string(ClientPortOperatorGreaterThan), + string(ClientPortOperatorGreaterThanOrEqual), + string(ClientPortOperatorLessThan), + string(ClientPortOperatorLessThanOrEqual), + string(ClientPortOperatorRegEx), + } +} + +func (s *ClientPortOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientPortOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientPortOperator(input string) (*ClientPortOperator, error) { + vals := map[string]ClientPortOperator{ + "any": ClientPortOperatorAny, + "beginswith": ClientPortOperatorBeginsWith, + "contains": ClientPortOperatorContains, + "endswith": ClientPortOperatorEndsWith, + "equal": ClientPortOperatorEqual, + "greaterthan": ClientPortOperatorGreaterThan, + "greaterthanorequal": ClientPortOperatorGreaterThanOrEqual, + "lessthan": ClientPortOperatorLessThan, + "lessthanorequal": ClientPortOperatorLessThanOrEqual, + "regex": ClientPortOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientPortOperator(input) + return &out, nil +} + +type CookiesOperator string + +const ( + CookiesOperatorAny CookiesOperator = "Any" + CookiesOperatorBeginsWith CookiesOperator = "BeginsWith" + CookiesOperatorContains CookiesOperator = "Contains" + CookiesOperatorEndsWith CookiesOperator = "EndsWith" + CookiesOperatorEqual CookiesOperator = "Equal" + CookiesOperatorGreaterThan CookiesOperator = "GreaterThan" + CookiesOperatorGreaterThanOrEqual CookiesOperator = "GreaterThanOrEqual" + CookiesOperatorLessThan CookiesOperator = "LessThan" + CookiesOperatorLessThanOrEqual CookiesOperator = "LessThanOrEqual" + CookiesOperatorRegEx CookiesOperator = "RegEx" +) + +func PossibleValuesForCookiesOperator() []string { + return []string{ + string(CookiesOperatorAny), + string(CookiesOperatorBeginsWith), + string(CookiesOperatorContains), + string(CookiesOperatorEndsWith), + string(CookiesOperatorEqual), + string(CookiesOperatorGreaterThan), + string(CookiesOperatorGreaterThanOrEqual), + string(CookiesOperatorLessThan), + string(CookiesOperatorLessThanOrEqual), + string(CookiesOperatorRegEx), + } +} + +func (s *CookiesOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookiesOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookiesOperator(input string) (*CookiesOperator, error) { + vals := map[string]CookiesOperator{ + "any": CookiesOperatorAny, + "beginswith": CookiesOperatorBeginsWith, + "contains": CookiesOperatorContains, + "endswith": CookiesOperatorEndsWith, + "equal": CookiesOperatorEqual, + "greaterthan": CookiesOperatorGreaterThan, + "greaterthanorequal": CookiesOperatorGreaterThanOrEqual, + "lessthan": CookiesOperatorLessThan, + "lessthanorequal": CookiesOperatorLessThanOrEqual, + "regex": CookiesOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookiesOperator(input) + return &out, nil +} + +type DeliveryRuleActionName string + +const ( + DeliveryRuleActionNameCacheExpiration DeliveryRuleActionName = "CacheExpiration" + DeliveryRuleActionNameCacheKeyQueryString DeliveryRuleActionName = "CacheKeyQueryString" + DeliveryRuleActionNameModifyRequestHeader DeliveryRuleActionName = "ModifyRequestHeader" + DeliveryRuleActionNameModifyResponseHeader DeliveryRuleActionName = "ModifyResponseHeader" + DeliveryRuleActionNameOriginGroupOverride DeliveryRuleActionName = "OriginGroupOverride" + DeliveryRuleActionNameRouteConfigurationOverride DeliveryRuleActionName = "RouteConfigurationOverride" + DeliveryRuleActionNameURLRedirect DeliveryRuleActionName = "UrlRedirect" + DeliveryRuleActionNameURLRewrite DeliveryRuleActionName = "UrlRewrite" + DeliveryRuleActionNameURLSigning DeliveryRuleActionName = "UrlSigning" +) + +func PossibleValuesForDeliveryRuleActionName() []string { + return []string{ + string(DeliveryRuleActionNameCacheExpiration), + string(DeliveryRuleActionNameCacheKeyQueryString), + string(DeliveryRuleActionNameModifyRequestHeader), + string(DeliveryRuleActionNameModifyResponseHeader), + string(DeliveryRuleActionNameOriginGroupOverride), + string(DeliveryRuleActionNameRouteConfigurationOverride), + string(DeliveryRuleActionNameURLRedirect), + string(DeliveryRuleActionNameURLRewrite), + string(DeliveryRuleActionNameURLSigning), + } +} + +func (s *DeliveryRuleActionName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleActionName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleActionName(input string) (*DeliveryRuleActionName, error) { + vals := map[string]DeliveryRuleActionName{ + "cacheexpiration": DeliveryRuleActionNameCacheExpiration, + "cachekeyquerystring": DeliveryRuleActionNameCacheKeyQueryString, + "modifyrequestheader": DeliveryRuleActionNameModifyRequestHeader, + "modifyresponseheader": DeliveryRuleActionNameModifyResponseHeader, + "origingroupoverride": DeliveryRuleActionNameOriginGroupOverride, + "routeconfigurationoverride": DeliveryRuleActionNameRouteConfigurationOverride, + "urlredirect": DeliveryRuleActionNameURLRedirect, + "urlrewrite": DeliveryRuleActionNameURLRewrite, + "urlsigning": DeliveryRuleActionNameURLSigning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleActionName(input) + return &out, nil +} + +type DeliveryRuleActionParametersType string + +const ( + DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters DeliveryRuleActionParametersType = "DeliveryRuleCacheExpirationActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters DeliveryRuleActionParametersType = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters DeliveryRuleActionParametersType = "DeliveryRuleHeaderActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters DeliveryRuleActionParametersType = "DeliveryRuleOriginGroupOverrideActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters DeliveryRuleActionParametersType = "DeliveryRuleRouteConfigurationOverrideActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlRedirectActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlRewriteActionParameters" + DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters DeliveryRuleActionParametersType = "DeliveryRuleUrlSigningActionParameters" +) + +func PossibleValuesForDeliveryRuleActionParametersType() []string { + return []string{ + string(DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters), + string(DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters), + } +} + +func (s *DeliveryRuleActionParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleActionParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleActionParametersType(input string) (*DeliveryRuleActionParametersType, error) { + vals := map[string]DeliveryRuleActionParametersType{ + "deliveryrulecacheexpirationactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleCacheExpirationActionParameters, + "deliveryrulecachekeyquerystringbehavioractionparameters": DeliveryRuleActionParametersTypeDeliveryRuleCacheKeyQueryStringBehaviorActionParameters, + "deliveryruleheaderactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleHeaderActionParameters, + "deliveryruleorigingroupoverrideactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleOriginGroupOverrideActionParameters, + "deliveryrulerouteconfigurationoverrideactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleRouteConfigurationOverrideActionParameters, + "deliveryruleurlredirectactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLRedirectActionParameters, + "deliveryruleurlrewriteactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLRewriteActionParameters, + "deliveryruleurlsigningactionparameters": DeliveryRuleActionParametersTypeDeliveryRuleURLSigningActionParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleActionParametersType(input) + return &out, nil +} + +type DeliveryRuleConditionParametersType string + +const ( + DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleClientPortConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleCookiesConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleHttpVersionConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleHostNameConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleIsDeviceConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters DeliveryRuleConditionParametersType = "DeliveryRulePostArgsConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleQueryStringConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRemoteAddressConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestBodyConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestHeaderConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestMethodConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestSchemeConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleRequestUriConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleServerPortConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleSocketAddrConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleSslProtocolConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlFilenameConditionParameters" + DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters DeliveryRuleConditionParametersType = "DeliveryRuleUrlPathMatchConditionParameters" +) + +func PossibleValuesForDeliveryRuleConditionParametersType() []string { + return []string{ + string(DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters), + string(DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters), + } +} + +func (s *DeliveryRuleConditionParametersType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeliveryRuleConditionParametersType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeliveryRuleConditionParametersType(input string) (*DeliveryRuleConditionParametersType, error) { + vals := map[string]DeliveryRuleConditionParametersType{ + "deliveryruleclientportconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleClientPortConditionParameters, + "deliveryrulecookiesconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleCookiesConditionParameters, + "deliveryrulehttpversionconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleHTTPVersionConditionParameters, + "deliveryrulehostnameconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleHostNameConditionParameters, + "deliveryruleisdeviceconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleIsDeviceConditionParameters, + "deliveryrulepostargsconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRulePostArgsConditionParameters, + "deliveryrulequerystringconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleQueryStringConditionParameters, + "deliveryruleremoteaddressconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRemoteAddressConditionParameters, + "deliveryrulerequestbodyconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestBodyConditionParameters, + "deliveryrulerequestheaderconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestHeaderConditionParameters, + "deliveryrulerequestmethodconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestMethodConditionParameters, + "deliveryrulerequestschemeconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestSchemeConditionParameters, + "deliveryrulerequesturiconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleRequestUriConditionParameters, + "deliveryruleserverportconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleServerPortConditionParameters, + "deliveryrulesocketaddrconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleSocketAddrConditionParameters, + "deliveryrulesslprotocolconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleSslProtocolConditionParameters, + "deliveryruleurlfileextensionmatchconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLFileExtensionMatchConditionParameters, + "deliveryruleurlfilenameconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLFilenameConditionParameters, + "deliveryruleurlpathmatchconditionparameters": DeliveryRuleConditionParametersTypeDeliveryRuleURLPathMatchConditionParameters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeliveryRuleConditionParametersType(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type DestinationProtocol string + +const ( + DestinationProtocolHTTP DestinationProtocol = "Http" + DestinationProtocolHTTPS DestinationProtocol = "Https" + DestinationProtocolMatchRequest DestinationProtocol = "MatchRequest" +) + +func PossibleValuesForDestinationProtocol() []string { + return []string{ + string(DestinationProtocolHTTP), + string(DestinationProtocolHTTPS), + string(DestinationProtocolMatchRequest), + } +} + +func (s *DestinationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDestinationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDestinationProtocol(input string) (*DestinationProtocol, error) { + vals := map[string]DestinationProtocol{ + "http": DestinationProtocolHTTP, + "https": DestinationProtocolHTTPS, + "matchrequest": DestinationProtocolMatchRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DestinationProtocol(input) + return &out, nil +} + +type ForwardingProtocol string + +const ( + ForwardingProtocolHTTPOnly ForwardingProtocol = "HttpOnly" + ForwardingProtocolHTTPSOnly ForwardingProtocol = "HttpsOnly" + ForwardingProtocolMatchRequest ForwardingProtocol = "MatchRequest" +) + +func PossibleValuesForForwardingProtocol() []string { + return []string{ + string(ForwardingProtocolHTTPOnly), + string(ForwardingProtocolHTTPSOnly), + string(ForwardingProtocolMatchRequest), + } +} + +func (s *ForwardingProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardingProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardingProtocol(input string) (*ForwardingProtocol, error) { + vals := map[string]ForwardingProtocol{ + "httponly": ForwardingProtocolHTTPOnly, + "httpsonly": ForwardingProtocolHTTPSOnly, + "matchrequest": ForwardingProtocolMatchRequest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardingProtocol(input) + return &out, nil +} + +type HTTPVersionOperator string + +const ( + HTTPVersionOperatorEqual HTTPVersionOperator = "Equal" +) + +func PossibleValuesForHTTPVersionOperator() []string { + return []string{ + string(HTTPVersionOperatorEqual), + } +} + +func (s *HTTPVersionOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPVersionOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHTTPVersionOperator(input string) (*HTTPVersionOperator, error) { + vals := map[string]HTTPVersionOperator{ + "equal": HTTPVersionOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HTTPVersionOperator(input) + return &out, nil +} + +type HeaderAction string + +const ( + HeaderActionAppend HeaderAction = "Append" + HeaderActionDelete HeaderAction = "Delete" + HeaderActionOverwrite HeaderAction = "Overwrite" +) + +func PossibleValuesForHeaderAction() []string { + return []string{ + string(HeaderActionAppend), + string(HeaderActionDelete), + string(HeaderActionOverwrite), + } +} + +func (s *HeaderAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHeaderAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHeaderAction(input string) (*HeaderAction, error) { + vals := map[string]HeaderAction{ + "append": HeaderActionAppend, + "delete": HeaderActionDelete, + "overwrite": HeaderActionOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HeaderAction(input) + return &out, nil +} + +type HostNameOperator string + +const ( + HostNameOperatorAny HostNameOperator = "Any" + HostNameOperatorBeginsWith HostNameOperator = "BeginsWith" + HostNameOperatorContains HostNameOperator = "Contains" + HostNameOperatorEndsWith HostNameOperator = "EndsWith" + HostNameOperatorEqual HostNameOperator = "Equal" + HostNameOperatorGreaterThan HostNameOperator = "GreaterThan" + HostNameOperatorGreaterThanOrEqual HostNameOperator = "GreaterThanOrEqual" + HostNameOperatorLessThan HostNameOperator = "LessThan" + HostNameOperatorLessThanOrEqual HostNameOperator = "LessThanOrEqual" + HostNameOperatorRegEx HostNameOperator = "RegEx" +) + +func PossibleValuesForHostNameOperator() []string { + return []string{ + string(HostNameOperatorAny), + string(HostNameOperatorBeginsWith), + string(HostNameOperatorContains), + string(HostNameOperatorEndsWith), + string(HostNameOperatorEqual), + string(HostNameOperatorGreaterThan), + string(HostNameOperatorGreaterThanOrEqual), + string(HostNameOperatorLessThan), + string(HostNameOperatorLessThanOrEqual), + string(HostNameOperatorRegEx), + } +} + +func (s *HostNameOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameOperator(input string) (*HostNameOperator, error) { + vals := map[string]HostNameOperator{ + "any": HostNameOperatorAny, + "beginswith": HostNameOperatorBeginsWith, + "contains": HostNameOperatorContains, + "endswith": HostNameOperatorEndsWith, + "equal": HostNameOperatorEqual, + "greaterthan": HostNameOperatorGreaterThan, + "greaterthanorequal": HostNameOperatorGreaterThanOrEqual, + "lessthan": HostNameOperatorLessThan, + "lessthanorequal": HostNameOperatorLessThanOrEqual, + "regex": HostNameOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameOperator(input) + return &out, nil +} + +type IsDeviceMatchValue string + +const ( + IsDeviceMatchValueDesktop IsDeviceMatchValue = "Desktop" + IsDeviceMatchValueMobile IsDeviceMatchValue = "Mobile" +) + +func PossibleValuesForIsDeviceMatchValue() []string { + return []string{ + string(IsDeviceMatchValueDesktop), + string(IsDeviceMatchValueMobile), + } +} + +func (s *IsDeviceMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDeviceMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsDeviceMatchValue(input string) (*IsDeviceMatchValue, error) { + vals := map[string]IsDeviceMatchValue{ + "desktop": IsDeviceMatchValueDesktop, + "mobile": IsDeviceMatchValueMobile, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsDeviceMatchValue(input) + return &out, nil +} + +type IsDeviceOperator string + +const ( + IsDeviceOperatorEqual IsDeviceOperator = "Equal" +) + +func PossibleValuesForIsDeviceOperator() []string { + return []string{ + string(IsDeviceOperatorEqual), + } +} + +func (s *IsDeviceOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDeviceOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsDeviceOperator(input string) (*IsDeviceOperator, error) { + vals := map[string]IsDeviceOperator{ + "equal": IsDeviceOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsDeviceOperator(input) + return &out, nil +} + +type MatchProcessingBehavior string + +const ( + MatchProcessingBehaviorContinue MatchProcessingBehavior = "Continue" + MatchProcessingBehaviorStop MatchProcessingBehavior = "Stop" +) + +func PossibleValuesForMatchProcessingBehavior() []string { + return []string{ + string(MatchProcessingBehaviorContinue), + string(MatchProcessingBehaviorStop), + } +} + +func (s *MatchProcessingBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMatchProcessingBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMatchProcessingBehavior(input string) (*MatchProcessingBehavior, error) { + vals := map[string]MatchProcessingBehavior{ + "continue": MatchProcessingBehaviorContinue, + "stop": MatchProcessingBehaviorStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MatchProcessingBehavior(input) + return &out, nil +} + +type MatchVariable string + +const ( + MatchVariableClientPort MatchVariable = "ClientPort" + MatchVariableCookies MatchVariable = "Cookies" + MatchVariableHTTPVersion MatchVariable = "HttpVersion" + MatchVariableHostName MatchVariable = "HostName" + MatchVariableIsDevice MatchVariable = "IsDevice" + MatchVariablePostArgs MatchVariable = "PostArgs" + MatchVariableQueryString MatchVariable = "QueryString" + MatchVariableRemoteAddress MatchVariable = "RemoteAddress" + MatchVariableRequestBody MatchVariable = "RequestBody" + MatchVariableRequestHeader MatchVariable = "RequestHeader" + MatchVariableRequestMethod MatchVariable = "RequestMethod" + MatchVariableRequestScheme MatchVariable = "RequestScheme" + MatchVariableRequestUri MatchVariable = "RequestUri" + MatchVariableServerPort MatchVariable = "ServerPort" + MatchVariableSocketAddr MatchVariable = "SocketAddr" + MatchVariableSslProtocol MatchVariable = "SslProtocol" + MatchVariableURLFileExtension MatchVariable = "UrlFileExtension" + MatchVariableURLFileName MatchVariable = "UrlFileName" + MatchVariableURLPath MatchVariable = "UrlPath" +) + +func PossibleValuesForMatchVariable() []string { + return []string{ + string(MatchVariableClientPort), + string(MatchVariableCookies), + string(MatchVariableHTTPVersion), + string(MatchVariableHostName), + string(MatchVariableIsDevice), + string(MatchVariablePostArgs), + string(MatchVariableQueryString), + string(MatchVariableRemoteAddress), + string(MatchVariableRequestBody), + string(MatchVariableRequestHeader), + string(MatchVariableRequestMethod), + string(MatchVariableRequestScheme), + string(MatchVariableRequestUri), + string(MatchVariableServerPort), + string(MatchVariableSocketAddr), + string(MatchVariableSslProtocol), + string(MatchVariableURLFileExtension), + string(MatchVariableURLFileName), + string(MatchVariableURLPath), + } +} + +func (s *MatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMatchVariable(input string) (*MatchVariable, error) { + vals := map[string]MatchVariable{ + "clientport": MatchVariableClientPort, + "cookies": MatchVariableCookies, + "httpversion": MatchVariableHTTPVersion, + "hostname": MatchVariableHostName, + "isdevice": MatchVariableIsDevice, + "postargs": MatchVariablePostArgs, + "querystring": MatchVariableQueryString, + "remoteaddress": MatchVariableRemoteAddress, + "requestbody": MatchVariableRequestBody, + "requestheader": MatchVariableRequestHeader, + "requestmethod": MatchVariableRequestMethod, + "requestscheme": MatchVariableRequestScheme, + "requesturi": MatchVariableRequestUri, + "serverport": MatchVariableServerPort, + "socketaddr": MatchVariableSocketAddr, + "sslprotocol": MatchVariableSslProtocol, + "urlfileextension": MatchVariableURLFileExtension, + "urlfilename": MatchVariableURLFileName, + "urlpath": MatchVariableURLPath, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MatchVariable(input) + return &out, nil +} + +type Operator string + +const ( + OperatorEqual Operator = "Equal" +) + +func PossibleValuesForOperator() []string { + return []string{ + string(OperatorEqual), + } +} + +func (s *Operator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperator(input string) (*Operator, error) { + vals := map[string]Operator{ + "equal": OperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Operator(input) + return &out, nil +} + +type ParamIndicator string + +const ( + ParamIndicatorExpires ParamIndicator = "Expires" + ParamIndicatorKeyId ParamIndicator = "KeyId" + ParamIndicatorSignature ParamIndicator = "Signature" +) + +func PossibleValuesForParamIndicator() []string { + return []string{ + string(ParamIndicatorExpires), + string(ParamIndicatorKeyId), + string(ParamIndicatorSignature), + } +} + +func (s *ParamIndicator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParamIndicator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParamIndicator(input string) (*ParamIndicator, error) { + vals := map[string]ParamIndicator{ + "expires": ParamIndicatorExpires, + "keyid": ParamIndicatorKeyId, + "signature": ParamIndicatorSignature, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParamIndicator(input) + return &out, nil +} + +type PostArgsOperator string + +const ( + PostArgsOperatorAny PostArgsOperator = "Any" + PostArgsOperatorBeginsWith PostArgsOperator = "BeginsWith" + PostArgsOperatorContains PostArgsOperator = "Contains" + PostArgsOperatorEndsWith PostArgsOperator = "EndsWith" + PostArgsOperatorEqual PostArgsOperator = "Equal" + PostArgsOperatorGreaterThan PostArgsOperator = "GreaterThan" + PostArgsOperatorGreaterThanOrEqual PostArgsOperator = "GreaterThanOrEqual" + PostArgsOperatorLessThan PostArgsOperator = "LessThan" + PostArgsOperatorLessThanOrEqual PostArgsOperator = "LessThanOrEqual" + PostArgsOperatorRegEx PostArgsOperator = "RegEx" +) + +func PossibleValuesForPostArgsOperator() []string { + return []string{ + string(PostArgsOperatorAny), + string(PostArgsOperatorBeginsWith), + string(PostArgsOperatorContains), + string(PostArgsOperatorEndsWith), + string(PostArgsOperatorEqual), + string(PostArgsOperatorGreaterThan), + string(PostArgsOperatorGreaterThanOrEqual), + string(PostArgsOperatorLessThan), + string(PostArgsOperatorLessThanOrEqual), + string(PostArgsOperatorRegEx), + } +} + +func (s *PostArgsOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePostArgsOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePostArgsOperator(input string) (*PostArgsOperator, error) { + vals := map[string]PostArgsOperator{ + "any": PostArgsOperatorAny, + "beginswith": PostArgsOperatorBeginsWith, + "contains": PostArgsOperatorContains, + "endswith": PostArgsOperatorEndsWith, + "equal": PostArgsOperatorEqual, + "greaterthan": PostArgsOperatorGreaterThan, + "greaterthanorequal": PostArgsOperatorGreaterThanOrEqual, + "lessthan": PostArgsOperatorLessThan, + "lessthanorequal": PostArgsOperatorLessThanOrEqual, + "regex": PostArgsOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PostArgsOperator(input) + return &out, nil +} + +type QueryStringBehavior string + +const ( + QueryStringBehaviorExclude QueryStringBehavior = "Exclude" + QueryStringBehaviorExcludeAll QueryStringBehavior = "ExcludeAll" + QueryStringBehaviorInclude QueryStringBehavior = "Include" + QueryStringBehaviorIncludeAll QueryStringBehavior = "IncludeAll" +) + +func PossibleValuesForQueryStringBehavior() []string { + return []string{ + string(QueryStringBehaviorExclude), + string(QueryStringBehaviorExcludeAll), + string(QueryStringBehaviorInclude), + string(QueryStringBehaviorIncludeAll), + } +} + +func (s *QueryStringBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryStringBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryStringBehavior(input string) (*QueryStringBehavior, error) { + vals := map[string]QueryStringBehavior{ + "exclude": QueryStringBehaviorExclude, + "excludeall": QueryStringBehaviorExcludeAll, + "include": QueryStringBehaviorInclude, + "includeall": QueryStringBehaviorIncludeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryStringBehavior(input) + return &out, nil +} + +type QueryStringOperator string + +const ( + QueryStringOperatorAny QueryStringOperator = "Any" + QueryStringOperatorBeginsWith QueryStringOperator = "BeginsWith" + QueryStringOperatorContains QueryStringOperator = "Contains" + QueryStringOperatorEndsWith QueryStringOperator = "EndsWith" + QueryStringOperatorEqual QueryStringOperator = "Equal" + QueryStringOperatorGreaterThan QueryStringOperator = "GreaterThan" + QueryStringOperatorGreaterThanOrEqual QueryStringOperator = "GreaterThanOrEqual" + QueryStringOperatorLessThan QueryStringOperator = "LessThan" + QueryStringOperatorLessThanOrEqual QueryStringOperator = "LessThanOrEqual" + QueryStringOperatorRegEx QueryStringOperator = "RegEx" +) + +func PossibleValuesForQueryStringOperator() []string { + return []string{ + string(QueryStringOperatorAny), + string(QueryStringOperatorBeginsWith), + string(QueryStringOperatorContains), + string(QueryStringOperatorEndsWith), + string(QueryStringOperatorEqual), + string(QueryStringOperatorGreaterThan), + string(QueryStringOperatorGreaterThanOrEqual), + string(QueryStringOperatorLessThan), + string(QueryStringOperatorLessThanOrEqual), + string(QueryStringOperatorRegEx), + } +} + +func (s *QueryStringOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQueryStringOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQueryStringOperator(input string) (*QueryStringOperator, error) { + vals := map[string]QueryStringOperator{ + "any": QueryStringOperatorAny, + "beginswith": QueryStringOperatorBeginsWith, + "contains": QueryStringOperatorContains, + "endswith": QueryStringOperatorEndsWith, + "equal": QueryStringOperatorEqual, + "greaterthan": QueryStringOperatorGreaterThan, + "greaterthanorequal": QueryStringOperatorGreaterThanOrEqual, + "lessthan": QueryStringOperatorLessThan, + "lessthanorequal": QueryStringOperatorLessThanOrEqual, + "regex": QueryStringOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QueryStringOperator(input) + return &out, nil +} + +type RedirectType string + +const ( + RedirectTypeFound RedirectType = "Found" + RedirectTypeMoved RedirectType = "Moved" + RedirectTypePermanentRedirect RedirectType = "PermanentRedirect" + RedirectTypeTemporaryRedirect RedirectType = "TemporaryRedirect" +) + +func PossibleValuesForRedirectType() []string { + return []string{ + string(RedirectTypeFound), + string(RedirectTypeMoved), + string(RedirectTypePermanentRedirect), + string(RedirectTypeTemporaryRedirect), + } +} + +func (s *RedirectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedirectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedirectType(input string) (*RedirectType, error) { + vals := map[string]RedirectType{ + "found": RedirectTypeFound, + "moved": RedirectTypeMoved, + "permanentredirect": RedirectTypePermanentRedirect, + "temporaryredirect": RedirectTypeTemporaryRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedirectType(input) + return &out, nil +} + +type RemoteAddressOperator string + +const ( + RemoteAddressOperatorAny RemoteAddressOperator = "Any" + RemoteAddressOperatorGeoMatch RemoteAddressOperator = "GeoMatch" + RemoteAddressOperatorIPMatch RemoteAddressOperator = "IPMatch" +) + +func PossibleValuesForRemoteAddressOperator() []string { + return []string{ + string(RemoteAddressOperatorAny), + string(RemoteAddressOperatorGeoMatch), + string(RemoteAddressOperatorIPMatch), + } +} + +func (s *RemoteAddressOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteAddressOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteAddressOperator(input string) (*RemoteAddressOperator, error) { + vals := map[string]RemoteAddressOperator{ + "any": RemoteAddressOperatorAny, + "geomatch": RemoteAddressOperatorGeoMatch, + "ipmatch": RemoteAddressOperatorIPMatch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteAddressOperator(input) + return &out, nil +} + +type RequestBodyOperator string + +const ( + RequestBodyOperatorAny RequestBodyOperator = "Any" + RequestBodyOperatorBeginsWith RequestBodyOperator = "BeginsWith" + RequestBodyOperatorContains RequestBodyOperator = "Contains" + RequestBodyOperatorEndsWith RequestBodyOperator = "EndsWith" + RequestBodyOperatorEqual RequestBodyOperator = "Equal" + RequestBodyOperatorGreaterThan RequestBodyOperator = "GreaterThan" + RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = "GreaterThanOrEqual" + RequestBodyOperatorLessThan RequestBodyOperator = "LessThan" + RequestBodyOperatorLessThanOrEqual RequestBodyOperator = "LessThanOrEqual" + RequestBodyOperatorRegEx RequestBodyOperator = "RegEx" +) + +func PossibleValuesForRequestBodyOperator() []string { + return []string{ + string(RequestBodyOperatorAny), + string(RequestBodyOperatorBeginsWith), + string(RequestBodyOperatorContains), + string(RequestBodyOperatorEndsWith), + string(RequestBodyOperatorEqual), + string(RequestBodyOperatorGreaterThan), + string(RequestBodyOperatorGreaterThanOrEqual), + string(RequestBodyOperatorLessThan), + string(RequestBodyOperatorLessThanOrEqual), + string(RequestBodyOperatorRegEx), + } +} + +func (s *RequestBodyOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestBodyOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestBodyOperator(input string) (*RequestBodyOperator, error) { + vals := map[string]RequestBodyOperator{ + "any": RequestBodyOperatorAny, + "beginswith": RequestBodyOperatorBeginsWith, + "contains": RequestBodyOperatorContains, + "endswith": RequestBodyOperatorEndsWith, + "equal": RequestBodyOperatorEqual, + "greaterthan": RequestBodyOperatorGreaterThan, + "greaterthanorequal": RequestBodyOperatorGreaterThanOrEqual, + "lessthan": RequestBodyOperatorLessThan, + "lessthanorequal": RequestBodyOperatorLessThanOrEqual, + "regex": RequestBodyOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestBodyOperator(input) + return &out, nil +} + +type RequestHeaderOperator string + +const ( + RequestHeaderOperatorAny RequestHeaderOperator = "Any" + RequestHeaderOperatorBeginsWith RequestHeaderOperator = "BeginsWith" + RequestHeaderOperatorContains RequestHeaderOperator = "Contains" + RequestHeaderOperatorEndsWith RequestHeaderOperator = "EndsWith" + RequestHeaderOperatorEqual RequestHeaderOperator = "Equal" + RequestHeaderOperatorGreaterThan RequestHeaderOperator = "GreaterThan" + RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = "GreaterThanOrEqual" + RequestHeaderOperatorLessThan RequestHeaderOperator = "LessThan" + RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = "LessThanOrEqual" + RequestHeaderOperatorRegEx RequestHeaderOperator = "RegEx" +) + +func PossibleValuesForRequestHeaderOperator() []string { + return []string{ + string(RequestHeaderOperatorAny), + string(RequestHeaderOperatorBeginsWith), + string(RequestHeaderOperatorContains), + string(RequestHeaderOperatorEndsWith), + string(RequestHeaderOperatorEqual), + string(RequestHeaderOperatorGreaterThan), + string(RequestHeaderOperatorGreaterThanOrEqual), + string(RequestHeaderOperatorLessThan), + string(RequestHeaderOperatorLessThanOrEqual), + string(RequestHeaderOperatorRegEx), + } +} + +func (s *RequestHeaderOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestHeaderOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestHeaderOperator(input string) (*RequestHeaderOperator, error) { + vals := map[string]RequestHeaderOperator{ + "any": RequestHeaderOperatorAny, + "beginswith": RequestHeaderOperatorBeginsWith, + "contains": RequestHeaderOperatorContains, + "endswith": RequestHeaderOperatorEndsWith, + "equal": RequestHeaderOperatorEqual, + "greaterthan": RequestHeaderOperatorGreaterThan, + "greaterthanorequal": RequestHeaderOperatorGreaterThanOrEqual, + "lessthan": RequestHeaderOperatorLessThan, + "lessthanorequal": RequestHeaderOperatorLessThanOrEqual, + "regex": RequestHeaderOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestHeaderOperator(input) + return &out, nil +} + +type RequestMethodMatchValue string + +const ( + RequestMethodMatchValueDELETE RequestMethodMatchValue = "DELETE" + RequestMethodMatchValueGET RequestMethodMatchValue = "GET" + RequestMethodMatchValueHEAD RequestMethodMatchValue = "HEAD" + RequestMethodMatchValueOPTIONS RequestMethodMatchValue = "OPTIONS" + RequestMethodMatchValuePOST RequestMethodMatchValue = "POST" + RequestMethodMatchValuePUT RequestMethodMatchValue = "PUT" + RequestMethodMatchValueTRACE RequestMethodMatchValue = "TRACE" +) + +func PossibleValuesForRequestMethodMatchValue() []string { + return []string{ + string(RequestMethodMatchValueDELETE), + string(RequestMethodMatchValueGET), + string(RequestMethodMatchValueHEAD), + string(RequestMethodMatchValueOPTIONS), + string(RequestMethodMatchValuePOST), + string(RequestMethodMatchValuePUT), + string(RequestMethodMatchValueTRACE), + } +} + +func (s *RequestMethodMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestMethodMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestMethodMatchValue(input string) (*RequestMethodMatchValue, error) { + vals := map[string]RequestMethodMatchValue{ + "delete": RequestMethodMatchValueDELETE, + "get": RequestMethodMatchValueGET, + "head": RequestMethodMatchValueHEAD, + "options": RequestMethodMatchValueOPTIONS, + "post": RequestMethodMatchValuePOST, + "put": RequestMethodMatchValuePUT, + "trace": RequestMethodMatchValueTRACE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestMethodMatchValue(input) + return &out, nil +} + +type RequestMethodOperator string + +const ( + RequestMethodOperatorEqual RequestMethodOperator = "Equal" +) + +func PossibleValuesForRequestMethodOperator() []string { + return []string{ + string(RequestMethodOperatorEqual), + } +} + +func (s *RequestMethodOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestMethodOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestMethodOperator(input string) (*RequestMethodOperator, error) { + vals := map[string]RequestMethodOperator{ + "equal": RequestMethodOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestMethodOperator(input) + return &out, nil +} + +type RequestSchemeMatchValue string + +const ( + RequestSchemeMatchValueHTTP RequestSchemeMatchValue = "HTTP" + RequestSchemeMatchValueHTTPS RequestSchemeMatchValue = "HTTPS" +) + +func PossibleValuesForRequestSchemeMatchValue() []string { + return []string{ + string(RequestSchemeMatchValueHTTP), + string(RequestSchemeMatchValueHTTPS), + } +} + +func (s *RequestSchemeMatchValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestSchemeMatchValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestSchemeMatchValue(input string) (*RequestSchemeMatchValue, error) { + vals := map[string]RequestSchemeMatchValue{ + "http": RequestSchemeMatchValueHTTP, + "https": RequestSchemeMatchValueHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestSchemeMatchValue(input) + return &out, nil +} + +type RequestUriOperator string + +const ( + RequestUriOperatorAny RequestUriOperator = "Any" + RequestUriOperatorBeginsWith RequestUriOperator = "BeginsWith" + RequestUriOperatorContains RequestUriOperator = "Contains" + RequestUriOperatorEndsWith RequestUriOperator = "EndsWith" + RequestUriOperatorEqual RequestUriOperator = "Equal" + RequestUriOperatorGreaterThan RequestUriOperator = "GreaterThan" + RequestUriOperatorGreaterThanOrEqual RequestUriOperator = "GreaterThanOrEqual" + RequestUriOperatorLessThan RequestUriOperator = "LessThan" + RequestUriOperatorLessThanOrEqual RequestUriOperator = "LessThanOrEqual" + RequestUriOperatorRegEx RequestUriOperator = "RegEx" +) + +func PossibleValuesForRequestUriOperator() []string { + return []string{ + string(RequestUriOperatorAny), + string(RequestUriOperatorBeginsWith), + string(RequestUriOperatorContains), + string(RequestUriOperatorEndsWith), + string(RequestUriOperatorEqual), + string(RequestUriOperatorGreaterThan), + string(RequestUriOperatorGreaterThanOrEqual), + string(RequestUriOperatorLessThan), + string(RequestUriOperatorLessThanOrEqual), + string(RequestUriOperatorRegEx), + } +} + +func (s *RequestUriOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequestUriOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequestUriOperator(input string) (*RequestUriOperator, error) { + vals := map[string]RequestUriOperator{ + "any": RequestUriOperatorAny, + "beginswith": RequestUriOperatorBeginsWith, + "contains": RequestUriOperatorContains, + "endswith": RequestUriOperatorEndsWith, + "equal": RequestUriOperatorEqual, + "greaterthan": RequestUriOperatorGreaterThan, + "greaterthanorequal": RequestUriOperatorGreaterThanOrEqual, + "lessthan": RequestUriOperatorLessThan, + "lessthanorequal": RequestUriOperatorLessThanOrEqual, + "regex": RequestUriOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequestUriOperator(input) + return &out, nil +} + +type RuleCacheBehavior string + +const ( + RuleCacheBehaviorHonorOrigin RuleCacheBehavior = "HonorOrigin" + RuleCacheBehaviorOverrideAlways RuleCacheBehavior = "OverrideAlways" + RuleCacheBehaviorOverrideIfOriginMissing RuleCacheBehavior = "OverrideIfOriginMissing" +) + +func PossibleValuesForRuleCacheBehavior() []string { + return []string{ + string(RuleCacheBehaviorHonorOrigin), + string(RuleCacheBehaviorOverrideAlways), + string(RuleCacheBehaviorOverrideIfOriginMissing), + } +} + +func (s *RuleCacheBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleCacheBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleCacheBehavior(input string) (*RuleCacheBehavior, error) { + vals := map[string]RuleCacheBehavior{ + "honororigin": RuleCacheBehaviorHonorOrigin, + "overridealways": RuleCacheBehaviorOverrideAlways, + "overrideiforiginmissing": RuleCacheBehaviorOverrideIfOriginMissing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleCacheBehavior(input) + return &out, nil +} + +type RuleIsCompressionEnabled string + +const ( + RuleIsCompressionEnabledDisabled RuleIsCompressionEnabled = "Disabled" + RuleIsCompressionEnabledEnabled RuleIsCompressionEnabled = "Enabled" +) + +func PossibleValuesForRuleIsCompressionEnabled() []string { + return []string{ + string(RuleIsCompressionEnabledDisabled), + string(RuleIsCompressionEnabledEnabled), + } +} + +func (s *RuleIsCompressionEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleIsCompressionEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleIsCompressionEnabled(input string) (*RuleIsCompressionEnabled, error) { + vals := map[string]RuleIsCompressionEnabled{ + "disabled": RuleIsCompressionEnabledDisabled, + "enabled": RuleIsCompressionEnabledEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleIsCompressionEnabled(input) + return &out, nil +} + +type RuleQueryStringCachingBehavior string + +const ( + RuleQueryStringCachingBehaviorIgnoreQueryString RuleQueryStringCachingBehavior = "IgnoreQueryString" + RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings RuleQueryStringCachingBehavior = "IgnoreSpecifiedQueryStrings" + RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings RuleQueryStringCachingBehavior = "IncludeSpecifiedQueryStrings" + RuleQueryStringCachingBehaviorUseQueryString RuleQueryStringCachingBehavior = "UseQueryString" +) + +func PossibleValuesForRuleQueryStringCachingBehavior() []string { + return []string{ + string(RuleQueryStringCachingBehaviorIgnoreQueryString), + string(RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings), + string(RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings), + string(RuleQueryStringCachingBehaviorUseQueryString), + } +} + +func (s *RuleQueryStringCachingBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleQueryStringCachingBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleQueryStringCachingBehavior(input string) (*RuleQueryStringCachingBehavior, error) { + vals := map[string]RuleQueryStringCachingBehavior{ + "ignorequerystring": RuleQueryStringCachingBehaviorIgnoreQueryString, + "ignorespecifiedquerystrings": RuleQueryStringCachingBehaviorIgnoreSpecifiedQueryStrings, + "includespecifiedquerystrings": RuleQueryStringCachingBehaviorIncludeSpecifiedQueryStrings, + "usequerystring": RuleQueryStringCachingBehaviorUseQueryString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleQueryStringCachingBehavior(input) + return &out, nil +} + +type ServerPortOperator string + +const ( + ServerPortOperatorAny ServerPortOperator = "Any" + ServerPortOperatorBeginsWith ServerPortOperator = "BeginsWith" + ServerPortOperatorContains ServerPortOperator = "Contains" + ServerPortOperatorEndsWith ServerPortOperator = "EndsWith" + ServerPortOperatorEqual ServerPortOperator = "Equal" + ServerPortOperatorGreaterThan ServerPortOperator = "GreaterThan" + ServerPortOperatorGreaterThanOrEqual ServerPortOperator = "GreaterThanOrEqual" + ServerPortOperatorLessThan ServerPortOperator = "LessThan" + ServerPortOperatorLessThanOrEqual ServerPortOperator = "LessThanOrEqual" + ServerPortOperatorRegEx ServerPortOperator = "RegEx" +) + +func PossibleValuesForServerPortOperator() []string { + return []string{ + string(ServerPortOperatorAny), + string(ServerPortOperatorBeginsWith), + string(ServerPortOperatorContains), + string(ServerPortOperatorEndsWith), + string(ServerPortOperatorEqual), + string(ServerPortOperatorGreaterThan), + string(ServerPortOperatorGreaterThanOrEqual), + string(ServerPortOperatorLessThan), + string(ServerPortOperatorLessThanOrEqual), + string(ServerPortOperatorRegEx), + } +} + +func (s *ServerPortOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerPortOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerPortOperator(input string) (*ServerPortOperator, error) { + vals := map[string]ServerPortOperator{ + "any": ServerPortOperatorAny, + "beginswith": ServerPortOperatorBeginsWith, + "contains": ServerPortOperatorContains, + "endswith": ServerPortOperatorEndsWith, + "equal": ServerPortOperatorEqual, + "greaterthan": ServerPortOperatorGreaterThan, + "greaterthanorequal": ServerPortOperatorGreaterThanOrEqual, + "lessthan": ServerPortOperatorLessThan, + "lessthanorequal": ServerPortOperatorLessThanOrEqual, + "regex": ServerPortOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerPortOperator(input) + return &out, nil +} + +type SocketAddrOperator string + +const ( + SocketAddrOperatorAny SocketAddrOperator = "Any" + SocketAddrOperatorIPMatch SocketAddrOperator = "IPMatch" +) + +func PossibleValuesForSocketAddrOperator() []string { + return []string{ + string(SocketAddrOperatorAny), + string(SocketAddrOperatorIPMatch), + } +} + +func (s *SocketAddrOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSocketAddrOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSocketAddrOperator(input string) (*SocketAddrOperator, error) { + vals := map[string]SocketAddrOperator{ + "any": SocketAddrOperatorAny, + "ipmatch": SocketAddrOperatorIPMatch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SocketAddrOperator(input) + return &out, nil +} + +type SslProtocol string + +const ( + SslProtocolTLSvOne SslProtocol = "TLSv1" + SslProtocolTLSvOnePointOne SslProtocol = "TLSv1.1" + SslProtocolTLSvOnePointTwo SslProtocol = "TLSv1.2" +) + +func PossibleValuesForSslProtocol() []string { + return []string{ + string(SslProtocolTLSvOne), + string(SslProtocolTLSvOnePointOne), + string(SslProtocolTLSvOnePointTwo), + } +} + +func (s *SslProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslProtocol(input string) (*SslProtocol, error) { + vals := map[string]SslProtocol{ + "tlsv1": SslProtocolTLSvOne, + "tlsv1.1": SslProtocolTLSvOnePointOne, + "tlsv1.2": SslProtocolTLSvOnePointTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslProtocol(input) + return &out, nil +} + +type SslProtocolOperator string + +const ( + SslProtocolOperatorEqual SslProtocolOperator = "Equal" +) + +func PossibleValuesForSslProtocolOperator() []string { + return []string{ + string(SslProtocolOperatorEqual), + } +} + +func (s *SslProtocolOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslProtocolOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslProtocolOperator(input string) (*SslProtocolOperator, error) { + vals := map[string]SslProtocolOperator{ + "equal": SslProtocolOperatorEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslProtocolOperator(input) + return &out, nil +} + +type Transform string + +const ( + TransformLowercase Transform = "Lowercase" + TransformRemoveNulls Transform = "RemoveNulls" + TransformTrim Transform = "Trim" + TransformURLDecode Transform = "UrlDecode" + TransformURLEncode Transform = "UrlEncode" + TransformUppercase Transform = "Uppercase" +) + +func PossibleValuesForTransform() []string { + return []string{ + string(TransformLowercase), + string(TransformRemoveNulls), + string(TransformTrim), + string(TransformURLDecode), + string(TransformURLEncode), + string(TransformUppercase), + } +} + +func (s *Transform) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransform(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransform(input string) (*Transform, error) { + vals := map[string]Transform{ + "lowercase": TransformLowercase, + "removenulls": TransformRemoveNulls, + "trim": TransformTrim, + "urldecode": TransformURLDecode, + "urlencode": TransformURLEncode, + "uppercase": TransformUppercase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Transform(input) + return &out, nil +} + +type URLFileExtensionOperator string + +const ( + URLFileExtensionOperatorAny URLFileExtensionOperator = "Any" + URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = "BeginsWith" + URLFileExtensionOperatorContains URLFileExtensionOperator = "Contains" + URLFileExtensionOperatorEndsWith URLFileExtensionOperator = "EndsWith" + URLFileExtensionOperatorEqual URLFileExtensionOperator = "Equal" + URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = "GreaterThan" + URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = "GreaterThanOrEqual" + URLFileExtensionOperatorLessThan URLFileExtensionOperator = "LessThan" + URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = "LessThanOrEqual" + URLFileExtensionOperatorRegEx URLFileExtensionOperator = "RegEx" +) + +func PossibleValuesForURLFileExtensionOperator() []string { + return []string{ + string(URLFileExtensionOperatorAny), + string(URLFileExtensionOperatorBeginsWith), + string(URLFileExtensionOperatorContains), + string(URLFileExtensionOperatorEndsWith), + string(URLFileExtensionOperatorEqual), + string(URLFileExtensionOperatorGreaterThan), + string(URLFileExtensionOperatorGreaterThanOrEqual), + string(URLFileExtensionOperatorLessThan), + string(URLFileExtensionOperatorLessThanOrEqual), + string(URLFileExtensionOperatorRegEx), + } +} + +func (s *URLFileExtensionOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLFileExtensionOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLFileExtensionOperator(input string) (*URLFileExtensionOperator, error) { + vals := map[string]URLFileExtensionOperator{ + "any": URLFileExtensionOperatorAny, + "beginswith": URLFileExtensionOperatorBeginsWith, + "contains": URLFileExtensionOperatorContains, + "endswith": URLFileExtensionOperatorEndsWith, + "equal": URLFileExtensionOperatorEqual, + "greaterthan": URLFileExtensionOperatorGreaterThan, + "greaterthanorequal": URLFileExtensionOperatorGreaterThanOrEqual, + "lessthan": URLFileExtensionOperatorLessThan, + "lessthanorequal": URLFileExtensionOperatorLessThanOrEqual, + "regex": URLFileExtensionOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLFileExtensionOperator(input) + return &out, nil +} + +type URLFileNameOperator string + +const ( + URLFileNameOperatorAny URLFileNameOperator = "Any" + URLFileNameOperatorBeginsWith URLFileNameOperator = "BeginsWith" + URLFileNameOperatorContains URLFileNameOperator = "Contains" + URLFileNameOperatorEndsWith URLFileNameOperator = "EndsWith" + URLFileNameOperatorEqual URLFileNameOperator = "Equal" + URLFileNameOperatorGreaterThan URLFileNameOperator = "GreaterThan" + URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = "GreaterThanOrEqual" + URLFileNameOperatorLessThan URLFileNameOperator = "LessThan" + URLFileNameOperatorLessThanOrEqual URLFileNameOperator = "LessThanOrEqual" + URLFileNameOperatorRegEx URLFileNameOperator = "RegEx" +) + +func PossibleValuesForURLFileNameOperator() []string { + return []string{ + string(URLFileNameOperatorAny), + string(URLFileNameOperatorBeginsWith), + string(URLFileNameOperatorContains), + string(URLFileNameOperatorEndsWith), + string(URLFileNameOperatorEqual), + string(URLFileNameOperatorGreaterThan), + string(URLFileNameOperatorGreaterThanOrEqual), + string(URLFileNameOperatorLessThan), + string(URLFileNameOperatorLessThanOrEqual), + string(URLFileNameOperatorRegEx), + } +} + +func (s *URLFileNameOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLFileNameOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLFileNameOperator(input string) (*URLFileNameOperator, error) { + vals := map[string]URLFileNameOperator{ + "any": URLFileNameOperatorAny, + "beginswith": URLFileNameOperatorBeginsWith, + "contains": URLFileNameOperatorContains, + "endswith": URLFileNameOperatorEndsWith, + "equal": URLFileNameOperatorEqual, + "greaterthan": URLFileNameOperatorGreaterThan, + "greaterthanorequal": URLFileNameOperatorGreaterThanOrEqual, + "lessthan": URLFileNameOperatorLessThan, + "lessthanorequal": URLFileNameOperatorLessThanOrEqual, + "regex": URLFileNameOperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLFileNameOperator(input) + return &out, nil +} + +type URLPathOperator string + +const ( + URLPathOperatorAny URLPathOperator = "Any" + URLPathOperatorBeginsWith URLPathOperator = "BeginsWith" + URLPathOperatorContains URLPathOperator = "Contains" + URLPathOperatorEndsWith URLPathOperator = "EndsWith" + URLPathOperatorEqual URLPathOperator = "Equal" + URLPathOperatorGreaterThan URLPathOperator = "GreaterThan" + URLPathOperatorGreaterThanOrEqual URLPathOperator = "GreaterThanOrEqual" + URLPathOperatorLessThan URLPathOperator = "LessThan" + URLPathOperatorLessThanOrEqual URLPathOperator = "LessThanOrEqual" + URLPathOperatorRegEx URLPathOperator = "RegEx" + URLPathOperatorWildcard URLPathOperator = "Wildcard" +) + +func PossibleValuesForURLPathOperator() []string { + return []string{ + string(URLPathOperatorAny), + string(URLPathOperatorBeginsWith), + string(URLPathOperatorContains), + string(URLPathOperatorEndsWith), + string(URLPathOperatorEqual), + string(URLPathOperatorGreaterThan), + string(URLPathOperatorGreaterThanOrEqual), + string(URLPathOperatorLessThan), + string(URLPathOperatorLessThanOrEqual), + string(URLPathOperatorRegEx), + string(URLPathOperatorWildcard), + } +} + +func (s *URLPathOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseURLPathOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseURLPathOperator(input string) (*URLPathOperator, error) { + vals := map[string]URLPathOperator{ + "any": URLPathOperatorAny, + "beginswith": URLPathOperatorBeginsWith, + "contains": URLPathOperatorContains, + "endswith": URLPathOperatorEndsWith, + "equal": URLPathOperatorEqual, + "greaterthan": URLPathOperatorGreaterThan, + "greaterthanorequal": URLPathOperatorGreaterThanOrEqual, + "lessthan": URLPathOperatorLessThan, + "lessthanorequal": URLPathOperatorLessThanOrEqual, + "regex": URLPathOperatorRegEx, + "wildcard": URLPathOperatorWildcard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := URLPathOperator(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/id_rule.go b/resource-manager/cdn/2024-09-01/rules/id_rule.go new file mode 100644 index 00000000000..a2d51413abd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/id_rule.go @@ -0,0 +1,148 @@ +package rules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RuleId{}) +} + +var _ resourceids.ResourceId = &RuleId{} + +// RuleId is a struct representing the Resource ID for a Rule +type RuleId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + RuleSetName string + RuleName string +} + +// NewRuleID returns a new RuleId struct +func NewRuleID(subscriptionId string, resourceGroupName string, profileName string, ruleSetName string, ruleName string) RuleId { + return RuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + RuleSetName: ruleSetName, + RuleName: ruleName, + } +} + +// ParseRuleID parses 'input' into a RuleId +func ParseRuleID(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleIDInsensitively parses 'input' case-insensitively into a RuleId +// note: this method should only be used for API response data and not user input +func ParseRuleIDInsensitively(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.RuleSetName, ok = input.Parsed["ruleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleSetName", input) + } + + if id.RuleName, ok = input.Parsed["ruleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleName", input) + } + + return nil +} + +// ValidateRuleID checks that 'input' can be parsed as a Rule ID +func ValidateRuleID(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 := ParseRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule ID +func (id RuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/ruleSets/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.RuleSetName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule ID +func (id RuleId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticRuleSets", "ruleSets", "ruleSets"), + resourceids.UserSpecifiedSegment("ruleSetName", "ruleSetName"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleName"), + } +} + +// String returns a human-readable description of this Rule ID +func (id RuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Rule Set Name: %q", id.RuleSetName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/rules/id_rule_test.go b/resource-manager/cdn/2024-09-01/rules/id_rule_test.go new file mode 100644 index 00000000000..5c334f60e59 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/id_rule_test.go @@ -0,0 +1,372 @@ +package rules + +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 = &RuleId{} + +func TestNewRuleID(t *testing.T) { + id := NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.RuleSetName != "ruleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleSetName'", id.RuleSetName, "ruleSetName") + } + + if id.RuleName != "ruleName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleName'", id.RuleName, "ruleName") + } +} + +func TestFormatRuleID(t *testing.T) { + actual := NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName", "ruleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules/ruleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules/ruleName", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules/ruleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestParseRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe/rUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules/ruleName", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/rules/ruleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe/rUlEs/rUlEnAmE", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + RuleSetName: "rUlEsEtNaMe", + RuleName: "rUlEnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe/rUlEs/rUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestSegmentsForRuleId(t *testing.T) { + segments := RuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleId 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/cdn/2024-09-01/rules/id_ruleset.go b/resource-manager/cdn/2024-09-01/rules/id_ruleset.go new file mode 100644 index 00000000000..34e058197a4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/id_ruleset.go @@ -0,0 +1,139 @@ +package rules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RuleSetId{}) +} + +var _ resourceids.ResourceId = &RuleSetId{} + +// RuleSetId is a struct representing the Resource ID for a Rule Set +type RuleSetId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + RuleSetName string +} + +// NewRuleSetID returns a new RuleSetId struct +func NewRuleSetID(subscriptionId string, resourceGroupName string, profileName string, ruleSetName string) RuleSetId { + return RuleSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + RuleSetName: ruleSetName, + } +} + +// ParseRuleSetID parses 'input' into a RuleSetId +func ParseRuleSetID(input string) (*RuleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleSetIDInsensitively parses 'input' case-insensitively into a RuleSetId +// note: this method should only be used for API response data and not user input +func ParseRuleSetIDInsensitively(input string) (*RuleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleSetId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.RuleSetName, ok = input.Parsed["ruleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleSetName", input) + } + + return nil +} + +// ValidateRuleSetID checks that 'input' can be parsed as a Rule Set ID +func ValidateRuleSetID(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 := ParseRuleSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Set ID +func (id RuleSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/ruleSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.RuleSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Set ID +func (id RuleSetId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticRuleSets", "ruleSets", "ruleSets"), + resourceids.UserSpecifiedSegment("ruleSetName", "ruleSetName"), + } +} + +// String returns a human-readable description of this Rule Set ID +func (id RuleSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Rule Set Name: %q", id.RuleSetName), + } + return fmt.Sprintf("Rule Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/rules/id_ruleset_test.go b/resource-manager/cdn/2024-09-01/rules/id_ruleset_test.go new file mode 100644 index 00000000000..0eafc9c9813 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/id_ruleset_test.go @@ -0,0 +1,327 @@ +package rules + +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 = &RuleSetId{} + +func TestNewRuleSetID(t *testing.T) { + id := NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.RuleSetName != "ruleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleSetName'", id.RuleSetName, "ruleSetName") + } +} + +func TestFormatRuleSetID(t *testing.T) { + actual := NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleSetId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleSetID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + } +} + +func TestParseRuleSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleSetId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + RuleSetName: "rUlEsEtNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleSetIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + } +} + +func TestSegmentsForRuleSetId(t *testing.T) { + segments := RuleSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleSetId 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/cdn/2024-09-01/rules/method_create.go b/resource-manager/cdn/2024-09-01/rules/method_create.go new file mode 100644 index 00000000000..84a6f02dc5e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/method_create.go @@ -0,0 +1,76 @@ +package rules + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Rule +} + +// Create ... +func (c RulesClient) Create(ctx context.Context, id RuleId, input Rule) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c RulesClient) CreateThenPoll(ctx context.Context, id RuleId, input Rule) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/method_delete.go b/resource-manager/cdn/2024-09-01/rules/method_delete.go new file mode 100644 index 00000000000..beb0bc70b2e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/method_delete.go @@ -0,0 +1,71 @@ +package rules + +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 RulesClient) Delete(ctx context.Context, id RuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 RulesClient) DeleteThenPoll(ctx context.Context, id RuleId) 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/cdn/2024-09-01/rules/method_get.go b/resource-manager/cdn/2024-09-01/rules/method_get.go new file mode 100644 index 00000000000..fb626b44bac --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/method_get.go @@ -0,0 +1,53 @@ +package rules + +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 *Rule +} + +// Get ... +func (c RulesClient) Get(ctx context.Context, id RuleId) (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 + } + + var model Rule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/rules/method_listbyruleset.go b/resource-manager/cdn/2024-09-01/rules/method_listbyruleset.go new file mode 100644 index 00000000000..45074b4d014 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/method_listbyruleset.go @@ -0,0 +1,105 @@ +package rules + +import ( + "context" + "fmt" + "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 ListByRuleSetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Rule +} + +type ListByRuleSetCompleteResult struct { + LatestHttpResponse *http.Response + Items []Rule +} + +type ListByRuleSetCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByRuleSetCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByRuleSet ... +func (c RulesClient) ListByRuleSet(ctx context.Context, id RuleSetId) (result ListByRuleSetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByRuleSetCustomPager{}, + Path: fmt.Sprintf("%s/rules", 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 *[]Rule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByRuleSetComplete retrieves all the results into a single object +func (c RulesClient) ListByRuleSetComplete(ctx context.Context, id RuleSetId) (ListByRuleSetCompleteResult, error) { + return c.ListByRuleSetCompleteMatchingPredicate(ctx, id, RuleOperationPredicate{}) +} + +// ListByRuleSetCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RulesClient) ListByRuleSetCompleteMatchingPredicate(ctx context.Context, id RuleSetId, predicate RuleOperationPredicate) (result ListByRuleSetCompleteResult, err error) { + items := make([]Rule, 0) + + resp, err := c.ListByRuleSet(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByRuleSetCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/rules/method_update.go b/resource-manager/cdn/2024-09-01/rules/method_update.go new file mode 100644 index 00000000000..1d7a1bd0f41 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/method_update.go @@ -0,0 +1,75 @@ +package rules + +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 + Model *Rule +} + +// Update ... +func (c RulesClient) Update(ctx context.Context, id RuleId, input RuleUpdateParameters) (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 RulesClient) UpdateThenPoll(ctx context.Context, id RuleId, input RuleUpdateParameters) 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/cdn/2024-09-01/rules/model_cacheconfiguration.go b/resource-manager/cdn/2024-09-01/rules/model_cacheconfiguration.go new file mode 100644 index 00000000000..af68de873ac --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_cacheconfiguration.go @@ -0,0 +1,12 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheConfiguration struct { + CacheBehavior *RuleCacheBehavior `json:"cacheBehavior,omitempty"` + CacheDuration *string `json:"cacheDuration,omitempty"` + IsCompressionEnabled *RuleIsCompressionEnabled `json:"isCompressionEnabled,omitempty"` + QueryParameters *string `json:"queryParameters,omitempty"` + QueryStringCachingBehavior *RuleQueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_cacheexpirationactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_cacheexpirationactionparameters.go new file mode 100644 index 00000000000..77c5d8d3082 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_cacheexpirationactionparameters.go @@ -0,0 +1,52 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = CacheExpirationActionParameters{} + +type CacheExpirationActionParameters struct { + CacheBehavior CacheBehavior `json:"cacheBehavior"` + CacheDuration *string `json:"cacheDuration,omitempty"` + CacheType CacheType `json:"cacheType"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s CacheExpirationActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CacheExpirationActionParameters{} + +func (s CacheExpirationActionParameters) MarshalJSON() ([]byte, error) { + type wrapper CacheExpirationActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CacheExpirationActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CacheExpirationActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCacheExpirationActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CacheExpirationActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_cachekeyquerystringactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_cachekeyquerystringactionparameters.go new file mode 100644 index 00000000000..b552b31226e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_cachekeyquerystringactionparameters.go @@ -0,0 +1,51 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = CacheKeyQueryStringActionParameters{} + +type CacheKeyQueryStringActionParameters struct { + QueryParameters *string `json:"queryParameters,omitempty"` + QueryStringBehavior QueryStringBehavior `json:"queryStringBehavior"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s CacheKeyQueryStringActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CacheKeyQueryStringActionParameters{} + +func (s CacheKeyQueryStringActionParameters) MarshalJSON() ([]byte, error) { + type wrapper CacheKeyQueryStringActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CacheKeyQueryStringActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_clientportmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_clientportmatchconditionparameters.go new file mode 100644 index 00000000000..f989d7c0314 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_clientportmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = ClientPortMatchConditionParameters{} + +type ClientPortMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator ClientPortOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s ClientPortMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = ClientPortMatchConditionParameters{} + +func (s ClientPortMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper ClientPortMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClientPortMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClientPortMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleClientPortConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClientPortMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_cookiesmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_cookiesmatchconditionparameters.go new file mode 100644 index 00000000000..63296e5671a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_cookiesmatchconditionparameters.go @@ -0,0 +1,54 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = CookiesMatchConditionParameters{} + +type CookiesMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator CookiesOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s CookiesMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = CookiesMatchConditionParameters{} + +func (s CookiesMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper CookiesMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CookiesMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CookiesMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleCookiesConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CookiesMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleaction.go new file mode 100644 index 00000000000..c9742f9ceb7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleaction.go @@ -0,0 +1,139 @@ +package rules + +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 DeliveryRuleAction interface { + DeliveryRuleAction() BaseDeliveryRuleActionImpl +} + +var _ DeliveryRuleAction = BaseDeliveryRuleActionImpl{} + +type BaseDeliveryRuleActionImpl struct { + Name DeliveryRuleActionName `json:"name"` +} + +func (s BaseDeliveryRuleActionImpl) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return s +} + +var _ DeliveryRuleAction = RawDeliveryRuleActionImpl{} + +// RawDeliveryRuleActionImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleActionImpl struct { + deliveryRuleAction BaseDeliveryRuleActionImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleActionImpl) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return s.deliveryRuleAction +} + +func UnmarshalDeliveryRuleActionImplementation(input []byte) (DeliveryRuleAction, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleAction into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["name"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CacheExpiration") { + var out DeliveryRuleCacheExpirationAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCacheExpirationAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CacheKeyQueryString") { + var out DeliveryRuleCacheKeyQueryStringAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ModifyRequestHeader") { + var out DeliveryRuleRequestHeaderAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestHeaderAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ModifyResponseHeader") { + var out DeliveryRuleResponseHeaderAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleResponseHeaderAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RouteConfigurationOverride") { + var out DeliveryRuleRouteConfigurationOverrideAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "OriginGroupOverride") { + var out OriginGroupOverrideAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OriginGroupOverrideAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlRedirect") { + var out URLRedirectAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRedirectAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlRewrite") { + var out URLRewriteAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRewriteAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlSigning") { + var out URLSigningAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLSigningAction: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleActionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleActionImpl: %+v", err) + } + + return RawDeliveryRuleActionImpl{ + deliveryRuleAction: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleactionparameters.go new file mode 100644 index 00000000000..f6a9cc5b1c6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleactionparameters.go @@ -0,0 +1,131 @@ +package rules + +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 DeliveryRuleActionParameters interface { + DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl +} + +var _ DeliveryRuleActionParameters = BaseDeliveryRuleActionParametersImpl{} + +type BaseDeliveryRuleActionParametersImpl struct { + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s BaseDeliveryRuleActionParametersImpl) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return s +} + +var _ DeliveryRuleActionParameters = RawDeliveryRuleActionParametersImpl{} + +// RawDeliveryRuleActionParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleActionParametersImpl struct { + deliveryRuleActionParameters BaseDeliveryRuleActionParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleActionParametersImpl) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return s.deliveryRuleActionParameters +} + +func UnmarshalDeliveryRuleActionParametersImplementation(input []byte) (DeliveryRuleActionParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleActionParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["typeName"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DeliveryRuleCacheExpirationActionParameters") { + var out CacheExpirationActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CacheExpirationActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters") { + var out CacheKeyQueryStringActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CacheKeyQueryStringActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHeaderActionParameters") { + var out HeaderActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HeaderActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleOriginGroupOverrideActionParameters") { + var out OriginGroupOverrideActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OriginGroupOverrideActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRouteConfigurationOverrideActionParameters") { + var out RouteConfigurationOverrideActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RouteConfigurationOverrideActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlRedirectActionParameters") { + var out URLRedirectActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRedirectActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlRewriteActionParameters") { + var out URLRewriteActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLRewriteActionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlSigningActionParameters") { + var out URLSigningActionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLSigningActionParameters: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleActionParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleActionParametersImpl: %+v", err) + } + + return RawDeliveryRuleActionParametersImpl{ + deliveryRuleActionParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecacheexpirationaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecacheexpirationaction.go new file mode 100644 index 00000000000..2106d68c543 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecacheexpirationaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleCacheExpirationAction{} + +type DeliveryRuleCacheExpirationAction struct { + Parameters CacheExpirationActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleCacheExpirationAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCacheExpirationAction{} + +func (s DeliveryRuleCacheExpirationAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCacheExpirationAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + decoded["name"] = "CacheExpiration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCacheExpirationAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecachekeyquerystringaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecachekeyquerystringaction.go new file mode 100644 index 00000000000..db7fa3798f6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecachekeyquerystringaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleCacheKeyQueryStringAction{} + +type DeliveryRuleCacheKeyQueryStringAction struct { + Parameters CacheKeyQueryStringActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleCacheKeyQueryStringAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCacheKeyQueryStringAction{} + +func (s DeliveryRuleCacheKeyQueryStringAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCacheKeyQueryStringAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + decoded["name"] = "CacheKeyQueryString" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCacheKeyQueryStringAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleclientportcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleclientportcondition.go new file mode 100644 index 00000000000..c825b662091 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleclientportcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleClientPortCondition{} + +type DeliveryRuleClientPortCondition struct { + Parameters ClientPortMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleClientPortCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleClientPortCondition{} + +func (s DeliveryRuleClientPortCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleClientPortCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleClientPortCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleClientPortCondition: %+v", err) + } + + decoded["name"] = "ClientPort" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleClientPortCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecondition.go new file mode 100644 index 00000000000..f82db88bf3f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecondition.go @@ -0,0 +1,219 @@ +package rules + +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 DeliveryRuleCondition interface { + DeliveryRuleCondition() BaseDeliveryRuleConditionImpl +} + +var _ DeliveryRuleCondition = BaseDeliveryRuleConditionImpl{} + +type BaseDeliveryRuleConditionImpl struct { + Name MatchVariable `json:"name"` +} + +func (s BaseDeliveryRuleConditionImpl) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return s +} + +var _ DeliveryRuleCondition = RawDeliveryRuleConditionImpl{} + +// RawDeliveryRuleConditionImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleConditionImpl struct { + deliveryRuleCondition BaseDeliveryRuleConditionImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleConditionImpl) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return s.deliveryRuleCondition +} + +func UnmarshalDeliveryRuleConditionImplementation(input []byte) (DeliveryRuleCondition, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCondition into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["name"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ClientPort") { + var out DeliveryRuleClientPortCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleClientPortCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Cookies") { + var out DeliveryRuleCookiesCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleCookiesCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HttpVersion") { + var out DeliveryRuleHTTPVersionCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleHTTPVersionCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HostName") { + var out DeliveryRuleHostNameCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleHostNameCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IsDevice") { + var out DeliveryRuleIsDeviceCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleIsDeviceCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PostArgs") { + var out DeliveryRulePostArgsCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRulePostArgsCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "QueryString") { + var out DeliveryRuleQueryStringCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleQueryStringCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RemoteAddress") { + var out DeliveryRuleRemoteAddressCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRemoteAddressCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestBody") { + var out DeliveryRuleRequestBodyCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestBodyCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestHeader") { + var out DeliveryRuleRequestHeaderCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestHeaderCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestMethod") { + var out DeliveryRuleRequestMethodCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestMethodCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestScheme") { + var out DeliveryRuleRequestSchemeCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestSchemeCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequestUri") { + var out DeliveryRuleRequestUriCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleRequestUriCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServerPort") { + var out DeliveryRuleServerPortCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleServerPortCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SocketAddr") { + var out DeliveryRuleSocketAddrCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleSocketAddrCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SslProtocol") { + var out DeliveryRuleSslProtocolCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleSslProtocolCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlFileExtension") { + var out DeliveryRuleURLFileExtensionCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLFileExtensionCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlFileName") { + var out DeliveryRuleURLFileNameCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLFileNameCondition: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlPath") { + var out DeliveryRuleURLPathCondition + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeliveryRuleURLPathCondition: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleConditionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleConditionImpl: %+v", err) + } + + return RawDeliveryRuleConditionImpl{ + deliveryRuleCondition: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleconditionparameters.go new file mode 100644 index 00000000000..f527b6e7326 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleconditionparameters.go @@ -0,0 +1,219 @@ +package rules + +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 DeliveryRuleConditionParameters interface { + DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl +} + +var _ DeliveryRuleConditionParameters = BaseDeliveryRuleConditionParametersImpl{} + +type BaseDeliveryRuleConditionParametersImpl struct { + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s BaseDeliveryRuleConditionParametersImpl) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return s +} + +var _ DeliveryRuleConditionParameters = RawDeliveryRuleConditionParametersImpl{} + +// RawDeliveryRuleConditionParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawDeliveryRuleConditionParametersImpl struct { + deliveryRuleConditionParameters BaseDeliveryRuleConditionParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawDeliveryRuleConditionParametersImpl) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return s.deliveryRuleConditionParameters +} + +func UnmarshalDeliveryRuleConditionParametersImplementation(input []byte) (DeliveryRuleConditionParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleConditionParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["typeName"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DeliveryRuleClientPortConditionParameters") { + var out ClientPortMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClientPortMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleCookiesConditionParameters") { + var out CookiesMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CookiesMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHttpVersionConditionParameters") { + var out HTTPVersionMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HTTPVersionMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleHostNameConditionParameters") { + var out HostNameMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HostNameMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleIsDeviceConditionParameters") { + var out IsDeviceMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IsDeviceMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRulePostArgsConditionParameters") { + var out PostArgsMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PostArgsMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleQueryStringConditionParameters") { + var out QueryStringMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into QueryStringMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRemoteAddressConditionParameters") { + var out RemoteAddressMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RemoteAddressMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestBodyConditionParameters") { + var out RequestBodyMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestBodyMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestHeaderConditionParameters") { + var out RequestHeaderMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestHeaderMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestMethodConditionParameters") { + var out RequestMethodMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestMethodMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestSchemeConditionParameters") { + var out RequestSchemeMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestSchemeMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleRequestUriConditionParameters") { + var out RequestUriMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RequestUriMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleServerPortConditionParameters") { + var out ServerPortMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServerPortMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleSocketAddrConditionParameters") { + var out SocketAddrMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SocketAddrMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleSslProtocolConditionParameters") { + var out SslProtocolMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SslProtocolMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlFileExtensionMatchConditionParameters") { + var out URLFileExtensionMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLFileExtensionMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlFilenameConditionParameters") { + var out URLFileNameMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLFileNameMatchConditionParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeliveryRuleUrlPathMatchConditionParameters") { + var out URLPathMatchConditionParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLPathMatchConditionParameters: %+v", err) + } + return out, nil + } + + var parent BaseDeliveryRuleConditionParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDeliveryRuleConditionParametersImpl: %+v", err) + } + + return RawDeliveryRuleConditionParametersImpl{ + deliveryRuleConditionParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecookiescondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecookiescondition.go new file mode 100644 index 00000000000..e76520b53a2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulecookiescondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleCookiesCondition{} + +type DeliveryRuleCookiesCondition struct { + Parameters CookiesMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleCookiesCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleCookiesCondition{} + +func (s DeliveryRuleCookiesCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleCookiesCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleCookiesCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleCookiesCondition: %+v", err) + } + + decoded["name"] = "Cookies" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleCookiesCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehostnamecondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehostnamecondition.go new file mode 100644 index 00000000000..44ef6b50c1e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehostnamecondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleHostNameCondition{} + +type DeliveryRuleHostNameCondition struct { + Parameters HostNameMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleHostNameCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleHostNameCondition{} + +func (s DeliveryRuleHostNameCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleHostNameCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleHostNameCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleHostNameCondition: %+v", err) + } + + decoded["name"] = "HostName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleHostNameCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehttpversioncondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehttpversioncondition.go new file mode 100644 index 00000000000..aa27793fbf2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulehttpversioncondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleHTTPVersionCondition{} + +type DeliveryRuleHTTPVersionCondition struct { + Parameters HTTPVersionMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleHTTPVersionCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleHTTPVersionCondition{} + +func (s DeliveryRuleHTTPVersionCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleHTTPVersionCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + decoded["name"] = "HttpVersion" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleHTTPVersionCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleisdevicecondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleisdevicecondition.go new file mode 100644 index 00000000000..5ae76aaa26a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleisdevicecondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleIsDeviceCondition{} + +type DeliveryRuleIsDeviceCondition struct { + Parameters IsDeviceMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleIsDeviceCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleIsDeviceCondition{} + +func (s DeliveryRuleIsDeviceCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleIsDeviceCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + decoded["name"] = "IsDevice" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleIsDeviceCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulepostargscondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulepostargscondition.go new file mode 100644 index 00000000000..0b549f2b27b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulepostargscondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRulePostArgsCondition{} + +type DeliveryRulePostArgsCondition struct { + Parameters PostArgsMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRulePostArgsCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRulePostArgsCondition{} + +func (s DeliveryRulePostArgsCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRulePostArgsCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRulePostArgsCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRulePostArgsCondition: %+v", err) + } + + decoded["name"] = "PostArgs" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRulePostArgsCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulequerystringcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulequerystringcondition.go new file mode 100644 index 00000000000..8e147deab21 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulequerystringcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleQueryStringCondition{} + +type DeliveryRuleQueryStringCondition struct { + Parameters QueryStringMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleQueryStringCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleQueryStringCondition{} + +func (s DeliveryRuleQueryStringCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleQueryStringCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + decoded["name"] = "QueryString" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleQueryStringCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleremoteaddresscondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleremoteaddresscondition.go new file mode 100644 index 00000000000..82eb3b6165d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleremoteaddresscondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRemoteAddressCondition{} + +type DeliveryRuleRemoteAddressCondition struct { + Parameters RemoteAddressMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRemoteAddressCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRemoteAddressCondition{} + +func (s DeliveryRuleRemoteAddressCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRemoteAddressCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + decoded["name"] = "RemoteAddress" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRemoteAddressCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestbodycondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestbodycondition.go new file mode 100644 index 00000000000..4a7ed969fdc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestbodycondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestBodyCondition{} + +type DeliveryRuleRequestBodyCondition struct { + Parameters RequestBodyMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestBodyCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestBodyCondition{} + +func (s DeliveryRuleRequestBodyCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestBodyCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + decoded["name"] = "RequestBody" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestBodyCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheaderaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheaderaction.go new file mode 100644 index 00000000000..0b4b70c1c74 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheaderaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleRequestHeaderAction{} + +type DeliveryRuleRequestHeaderAction struct { + Parameters HeaderActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleRequestHeaderAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestHeaderAction{} + +func (s DeliveryRuleRequestHeaderAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestHeaderAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + decoded["name"] = "ModifyRequestHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestHeaderAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheadercondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheadercondition.go new file mode 100644 index 00000000000..f1d34dc0f76 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestheadercondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestHeaderCondition{} + +type DeliveryRuleRequestHeaderCondition struct { + Parameters RequestHeaderMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestHeaderCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestHeaderCondition{} + +func (s DeliveryRuleRequestHeaderCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestHeaderCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + decoded["name"] = "RequestHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestHeaderCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestmethodcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestmethodcondition.go new file mode 100644 index 00000000000..3ce8ced0d67 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestmethodcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestMethodCondition{} + +type DeliveryRuleRequestMethodCondition struct { + Parameters RequestMethodMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestMethodCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestMethodCondition{} + +func (s DeliveryRuleRequestMethodCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestMethodCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + decoded["name"] = "RequestMethod" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestMethodCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestschemecondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestschemecondition.go new file mode 100644 index 00000000000..1af6289b7f0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequestschemecondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestSchemeCondition{} + +type DeliveryRuleRequestSchemeCondition struct { + Parameters RequestSchemeMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestSchemeCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestSchemeCondition{} + +func (s DeliveryRuleRequestSchemeCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestSchemeCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + decoded["name"] = "RequestScheme" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestSchemeCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequesturicondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequesturicondition.go new file mode 100644 index 00000000000..63335243168 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerequesturicondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleRequestUriCondition{} + +type DeliveryRuleRequestUriCondition struct { + Parameters RequestUriMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleRequestUriCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRequestUriCondition{} + +func (s DeliveryRuleRequestUriCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRequestUriCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + decoded["name"] = "RequestUri" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRequestUriCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleresponseheaderaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleresponseheaderaction.go new file mode 100644 index 00000000000..264c599d00a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleresponseheaderaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleResponseHeaderAction{} + +type DeliveryRuleResponseHeaderAction struct { + Parameters HeaderActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleResponseHeaderAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleResponseHeaderAction{} + +func (s DeliveryRuleResponseHeaderAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleResponseHeaderAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + decoded["name"] = "ModifyResponseHeader" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleResponseHeaderAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerouteconfigurationoverrideaction.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerouteconfigurationoverrideaction.go new file mode 100644 index 00000000000..5aed6e8f9dc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulerouteconfigurationoverrideaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = DeliveryRuleRouteConfigurationOverrideAction{} + +type DeliveryRuleRouteConfigurationOverrideAction struct { + Parameters RouteConfigurationOverrideActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s DeliveryRuleRouteConfigurationOverrideAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleRouteConfigurationOverrideAction{} + +func (s DeliveryRuleRouteConfigurationOverrideAction) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleRouteConfigurationOverrideAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + decoded["name"] = "RouteConfigurationOverride" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleRouteConfigurationOverrideAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleserverportcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleserverportcondition.go new file mode 100644 index 00000000000..ce4318a26d0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleserverportcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleServerPortCondition{} + +type DeliveryRuleServerPortCondition struct { + Parameters ServerPortMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleServerPortCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleServerPortCondition{} + +func (s DeliveryRuleServerPortCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleServerPortCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleServerPortCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleServerPortCondition: %+v", err) + } + + decoded["name"] = "ServerPort" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleServerPortCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesocketaddrcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesocketaddrcondition.go new file mode 100644 index 00000000000..e7fab395f43 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesocketaddrcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleSocketAddrCondition{} + +type DeliveryRuleSocketAddrCondition struct { + Parameters SocketAddrMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleSocketAddrCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleSocketAddrCondition{} + +func (s DeliveryRuleSocketAddrCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleSocketAddrCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + decoded["name"] = "SocketAddr" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleSocketAddrCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesslprotocolcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesslprotocolcondition.go new file mode 100644 index 00000000000..7ab504fa054 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryrulesslprotocolcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleSslProtocolCondition{} + +type DeliveryRuleSslProtocolCondition struct { + Parameters SslProtocolMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleSslProtocolCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleSslProtocolCondition{} + +func (s DeliveryRuleSslProtocolCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleSslProtocolCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + decoded["name"] = "SslProtocol" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleSslProtocolCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfileextensioncondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfileextensioncondition.go new file mode 100644 index 00000000000..1654163eb0d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfileextensioncondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLFileExtensionCondition{} + +type DeliveryRuleURLFileExtensionCondition struct { + Parameters URLFileExtensionMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLFileExtensionCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLFileExtensionCondition{} + +func (s DeliveryRuleURLFileExtensionCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLFileExtensionCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + decoded["name"] = "UrlFileExtension" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLFileExtensionCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfilenamecondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfilenamecondition.go new file mode 100644 index 00000000000..c2e66c27254 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlfilenamecondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLFileNameCondition{} + +type DeliveryRuleURLFileNameCondition struct { + Parameters URLFileNameMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLFileNameCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLFileNameCondition{} + +func (s DeliveryRuleURLFileNameCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLFileNameCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + decoded["name"] = "UrlFileName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLFileNameCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlpathcondition.go b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlpathcondition.go new file mode 100644 index 00000000000..f88fc78d5b0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_deliveryruleurlpathcondition.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleCondition = DeliveryRuleURLPathCondition{} + +type DeliveryRuleURLPathCondition struct { + Parameters URLPathMatchConditionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleCondition + + Name MatchVariable `json:"name"` +} + +func (s DeliveryRuleURLPathCondition) DeliveryRuleCondition() BaseDeliveryRuleConditionImpl { + return BaseDeliveryRuleConditionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = DeliveryRuleURLPathCondition{} + +func (s DeliveryRuleURLPathCondition) MarshalJSON() ([]byte, error) { + type wrapper DeliveryRuleURLPathCondition + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeliveryRuleURLPathCondition: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeliveryRuleURLPathCondition: %+v", err) + } + + decoded["name"] = "UrlPath" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeliveryRuleURLPathCondition: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_headeractionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_headeractionparameters.go new file mode 100644 index 00000000000..6bf4a05fded --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_headeractionparameters.go @@ -0,0 +1,52 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = HeaderActionParameters{} + +type HeaderActionParameters struct { + HeaderAction HeaderAction `json:"headerAction"` + HeaderName string `json:"headerName"` + Value *string `json:"value,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s HeaderActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HeaderActionParameters{} + +func (s HeaderActionParameters) MarshalJSON() ([]byte, error) { + type wrapper HeaderActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HeaderActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HeaderActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHeaderActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HeaderActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_hostnamematchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_hostnamematchconditionparameters.go new file mode 100644 index 00000000000..9dde99c7f84 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_hostnamematchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = HostNameMatchConditionParameters{} + +type HostNameMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator HostNameOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s HostNameMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HostNameMatchConditionParameters{} + +func (s HostNameMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper HostNameMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HostNameMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HostNameMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHostNameConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HostNameMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_httpversionmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_httpversionmatchconditionparameters.go new file mode 100644 index 00000000000..4fdfdc7344d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_httpversionmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = HTTPVersionMatchConditionParameters{} + +type HTTPVersionMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator HTTPVersionOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s HTTPVersionMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = HTTPVersionMatchConditionParameters{} + +func (s HTTPVersionMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper HTTPVersionMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleHttpVersionConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HTTPVersionMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_isdevicematchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_isdevicematchconditionparameters.go new file mode 100644 index 00000000000..f3b7e28c6bc --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_isdevicematchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = IsDeviceMatchConditionParameters{} + +type IsDeviceMatchConditionParameters struct { + MatchValues *[]IsDeviceMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator IsDeviceOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s IsDeviceMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = IsDeviceMatchConditionParameters{} + +func (s IsDeviceMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper IsDeviceMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IsDeviceMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IsDeviceMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleIsDeviceConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IsDeviceMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_origingroupoverride.go b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverride.go new file mode 100644 index 00000000000..72d2e00784b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverride.go @@ -0,0 +1,9 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OriginGroupOverride struct { + ForwardingProtocol *ForwardingProtocol `json:"forwardingProtocol,omitempty"` + OriginGroup *ResourceReference `json:"originGroup,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideaction.go b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideaction.go new file mode 100644 index 00000000000..d7ed168c94c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = OriginGroupOverrideAction{} + +type OriginGroupOverrideAction struct { + Parameters OriginGroupOverrideActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s OriginGroupOverrideAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = OriginGroupOverrideAction{} + +func (s OriginGroupOverrideAction) MarshalJSON() ([]byte, error) { + type wrapper OriginGroupOverrideAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OriginGroupOverrideAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OriginGroupOverrideAction: %+v", err) + } + + decoded["name"] = "OriginGroupOverride" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OriginGroupOverrideAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideactionparameters.go new file mode 100644 index 00000000000..138ece4ddea --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_origingroupoverrideactionparameters.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = OriginGroupOverrideActionParameters{} + +type OriginGroupOverrideActionParameters struct { + OriginGroup ResourceReference `json:"originGroup"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s OriginGroupOverrideActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = OriginGroupOverrideActionParameters{} + +func (s OriginGroupOverrideActionParameters) MarshalJSON() ([]byte, error) { + type wrapper OriginGroupOverrideActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OriginGroupOverrideActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OriginGroupOverrideActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleOriginGroupOverrideActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OriginGroupOverrideActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_postargsmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_postargsmatchconditionparameters.go new file mode 100644 index 00000000000..3943de4a654 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_postargsmatchconditionparameters.go @@ -0,0 +1,54 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = PostArgsMatchConditionParameters{} + +type PostArgsMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator PostArgsOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s PostArgsMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = PostArgsMatchConditionParameters{} + +func (s PostArgsMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper PostArgsMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PostArgsMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PostArgsMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRulePostArgsConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PostArgsMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_querystringmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_querystringmatchconditionparameters.go new file mode 100644 index 00000000000..6e8d907688b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_querystringmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = QueryStringMatchConditionParameters{} + +type QueryStringMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator QueryStringOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s QueryStringMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = QueryStringMatchConditionParameters{} + +func (s QueryStringMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper QueryStringMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling QueryStringMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling QueryStringMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleQueryStringConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling QueryStringMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_remoteaddressmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_remoteaddressmatchconditionparameters.go new file mode 100644 index 00000000000..9e91456eb10 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_remoteaddressmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RemoteAddressMatchConditionParameters{} + +type RemoteAddressMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RemoteAddressOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RemoteAddressMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RemoteAddressMatchConditionParameters{} + +func (s RemoteAddressMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RemoteAddressMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRemoteAddressConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RemoteAddressMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_requestbodymatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_requestbodymatchconditionparameters.go new file mode 100644 index 00000000000..6264e1db154 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_requestbodymatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestBodyMatchConditionParameters{} + +type RequestBodyMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestBodyOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestBodyMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestBodyMatchConditionParameters{} + +func (s RequestBodyMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestBodyMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestBodyMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestBodyMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestBodyConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestBodyMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_requestheadermatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_requestheadermatchconditionparameters.go new file mode 100644 index 00000000000..8f2ca7a33d8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_requestheadermatchconditionparameters.go @@ -0,0 +1,54 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestHeaderMatchConditionParameters{} + +type RequestHeaderMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestHeaderOperator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestHeaderMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestHeaderMatchConditionParameters{} + +func (s RequestHeaderMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestHeaderMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestHeaderConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestHeaderMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_requestmethodmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_requestmethodmatchconditionparameters.go new file mode 100644 index 00000000000..ea18f9eab27 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_requestmethodmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestMethodMatchConditionParameters{} + +type RequestMethodMatchConditionParameters struct { + MatchValues *[]RequestMethodMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestMethodOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestMethodMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestMethodMatchConditionParameters{} + +func (s RequestMethodMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestMethodMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestMethodMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestMethodMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestMethodConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestMethodMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_requestschemematchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_requestschemematchconditionparameters.go new file mode 100644 index 00000000000..6e69c0badce --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_requestschemematchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestSchemeMatchConditionParameters{} + +type RequestSchemeMatchConditionParameters struct { + MatchValues *[]RequestSchemeMatchValue `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator Operator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestSchemeMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestSchemeMatchConditionParameters{} + +func (s RequestSchemeMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestSchemeMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestSchemeConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestSchemeMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_requesturimatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_requesturimatchconditionparameters.go new file mode 100644 index 00000000000..72fcf177b2d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_requesturimatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = RequestUriMatchConditionParameters{} + +type RequestUriMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator RequestUriOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s RequestUriMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RequestUriMatchConditionParameters{} + +func (s RequestUriMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper RequestUriMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RequestUriMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RequestUriMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRequestUriConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RequestUriMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_resourcereference.go b/resource-manager/cdn/2024-09-01/rules/model_resourcereference.go new file mode 100644 index 00000000000..841c18a0770 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_resourcereference.go @@ -0,0 +1,8 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_routeconfigurationoverrideactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_routeconfigurationoverrideactionparameters.go new file mode 100644 index 00000000000..39b23f835a5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_routeconfigurationoverrideactionparameters.go @@ -0,0 +1,51 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = RouteConfigurationOverrideActionParameters{} + +type RouteConfigurationOverrideActionParameters struct { + CacheConfiguration *CacheConfiguration `json:"cacheConfiguration,omitempty"` + OriginGroupOverride *OriginGroupOverride `json:"originGroupOverride,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s RouteConfigurationOverrideActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = RouteConfigurationOverrideActionParameters{} + +func (s RouteConfigurationOverrideActionParameters) MarshalJSON() ([]byte, error) { + type wrapper RouteConfigurationOverrideActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleRouteConfigurationOverrideActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RouteConfigurationOverrideActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_rule.go b/resource-manager/cdn/2024-09-01/rules/model_rule.go new file mode 100644 index 00000000000..8b9504ed600 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_rule.go @@ -0,0 +1,16 @@ +package rules + +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 Rule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_ruleproperties.go b/resource-manager/cdn/2024-09-01/rules/model_ruleproperties.go new file mode 100644 index 00000000000..f9405db82fe --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_ruleproperties.go @@ -0,0 +1,81 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleProperties struct { + Actions *[]DeliveryRuleAction `json:"actions,omitempty"` + Conditions *[]DeliveryRuleCondition `json:"conditions,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + MatchProcessingBehavior *MatchProcessingBehavior `json:"matchProcessingBehavior,omitempty"` + Order *int64 `json:"order,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + RuleSetName *string `json:"ruleSetName,omitempty"` +} + +var _ json.Unmarshaler = &RuleProperties{} + +func (s *RuleProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + MatchProcessingBehavior *MatchProcessingBehavior `json:"matchProcessingBehavior,omitempty"` + Order *int64 `json:"order,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + RuleSetName *string `json:"ruleSetName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DeploymentStatus = decoded.DeploymentStatus + s.MatchProcessingBehavior = decoded.MatchProcessingBehavior + s.Order = decoded.Order + s.ProvisioningState = decoded.ProvisioningState + s.RuleSetName = decoded.RuleSetName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RuleProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["actions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Actions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleAction, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleActionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Actions' for 'RuleProperties': %+v", i, err) + } + output = append(output, impl) + } + s.Actions = &output + } + + if v, ok := temp["conditions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Conditions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleCondition, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleConditionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Conditions' for 'RuleProperties': %+v", i, err) + } + output = append(output, impl) + } + s.Conditions = &output + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_ruleupdateparameters.go b/resource-manager/cdn/2024-09-01/rules/model_ruleupdateparameters.go new file mode 100644 index 00000000000..d5bd427fc3d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_ruleupdateparameters.go @@ -0,0 +1,8 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleUpdateParameters struct { + Properties *RuleUpdatePropertiesParameters `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_ruleupdatepropertiesparameters.go b/resource-manager/cdn/2024-09-01/rules/model_ruleupdatepropertiesparameters.go new file mode 100644 index 00000000000..3403d24408d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_ruleupdatepropertiesparameters.go @@ -0,0 +1,75 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleUpdatePropertiesParameters struct { + Actions *[]DeliveryRuleAction `json:"actions,omitempty"` + Conditions *[]DeliveryRuleCondition `json:"conditions,omitempty"` + MatchProcessingBehavior *MatchProcessingBehavior `json:"matchProcessingBehavior,omitempty"` + Order *int64 `json:"order,omitempty"` + RuleSetName *string `json:"ruleSetName,omitempty"` +} + +var _ json.Unmarshaler = &RuleUpdatePropertiesParameters{} + +func (s *RuleUpdatePropertiesParameters) UnmarshalJSON(bytes []byte) error { + var decoded struct { + MatchProcessingBehavior *MatchProcessingBehavior `json:"matchProcessingBehavior,omitempty"` + Order *int64 `json:"order,omitempty"` + RuleSetName *string `json:"ruleSetName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.MatchProcessingBehavior = decoded.MatchProcessingBehavior + s.Order = decoded.Order + s.RuleSetName = decoded.RuleSetName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RuleUpdatePropertiesParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["actions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Actions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleAction, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleActionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Actions' for 'RuleUpdatePropertiesParameters': %+v", i, err) + } + output = append(output, impl) + } + s.Actions = &output + } + + if v, ok := temp["conditions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Conditions into list []json.RawMessage: %+v", err) + } + + output := make([]DeliveryRuleCondition, 0) + for i, val := range listTemp { + impl, err := UnmarshalDeliveryRuleConditionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Conditions' for 'RuleUpdatePropertiesParameters': %+v", i, err) + } + output = append(output, impl) + } + s.Conditions = &output + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_serverportmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_serverportmatchconditionparameters.go new file mode 100644 index 00000000000..8f96177dbcb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_serverportmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = ServerPortMatchConditionParameters{} + +type ServerPortMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator ServerPortOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s ServerPortMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = ServerPortMatchConditionParameters{} + +func (s ServerPortMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper ServerPortMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServerPortMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServerPortMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleServerPortConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServerPortMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_socketaddrmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_socketaddrmatchconditionparameters.go new file mode 100644 index 00000000000..c5056b07bd9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_socketaddrmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = SocketAddrMatchConditionParameters{} + +type SocketAddrMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator SocketAddrOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s SocketAddrMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = SocketAddrMatchConditionParameters{} + +func (s SocketAddrMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper SocketAddrMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SocketAddrMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SocketAddrMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleSocketAddrConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SocketAddrMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_sslprotocolmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_sslprotocolmatchconditionparameters.go new file mode 100644 index 00000000000..e424bb27aaf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_sslprotocolmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = SslProtocolMatchConditionParameters{} + +type SslProtocolMatchConditionParameters struct { + MatchValues *[]SslProtocol `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator SslProtocolOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s SslProtocolMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = SslProtocolMatchConditionParameters{} + +func (s SslProtocolMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper SslProtocolMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SslProtocolMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SslProtocolMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleSslProtocolConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SslProtocolMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlfileextensionmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlfileextensionmatchconditionparameters.go new file mode 100644 index 00000000000..275ca468b7a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlfileextensionmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLFileExtensionMatchConditionParameters{} + +type URLFileExtensionMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLFileExtensionOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLFileExtensionMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLFileExtensionMatchConditionParameters{} + +func (s URLFileExtensionMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLFileExtensionMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLFileExtensionMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlfilenamematchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlfilenamematchconditionparameters.go new file mode 100644 index 00000000000..5d6316c6493 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlfilenamematchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLFileNameMatchConditionParameters{} + +type URLFileNameMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLFileNameOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLFileNameMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLFileNameMatchConditionParameters{} + +func (s URLFileNameMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLFileNameMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLFileNameMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLFileNameMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlFilenameConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLFileNameMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlpathmatchconditionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlpathmatchconditionparameters.go new file mode 100644 index 00000000000..e62c36d355c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlpathmatchconditionparameters.go @@ -0,0 +1,53 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleConditionParameters = URLPathMatchConditionParameters{} + +type URLPathMatchConditionParameters struct { + MatchValues *[]string `json:"matchValues,omitempty"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator URLPathOperator `json:"operator"` + Transforms *[]Transform `json:"transforms,omitempty"` + + // Fields inherited from DeliveryRuleConditionParameters + + TypeName DeliveryRuleConditionParametersType `json:"typeName"` +} + +func (s URLPathMatchConditionParameters) DeliveryRuleConditionParameters() BaseDeliveryRuleConditionParametersImpl { + return BaseDeliveryRuleConditionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLPathMatchConditionParameters{} + +func (s URLPathMatchConditionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLPathMatchConditionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLPathMatchConditionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLPathMatchConditionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlPathMatchConditionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLPathMatchConditionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlredirectaction.go b/resource-manager/cdn/2024-09-01/rules/model_urlredirectaction.go new file mode 100644 index 00000000000..578a809c159 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlredirectaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLRedirectAction{} + +type URLRedirectAction struct { + Parameters URLRedirectActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLRedirectAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLRedirectAction{} + +func (s URLRedirectAction) MarshalJSON() ([]byte, error) { + type wrapper URLRedirectAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRedirectAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRedirectAction: %+v", err) + } + + decoded["name"] = "UrlRedirect" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRedirectAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlredirectactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlredirectactionparameters.go new file mode 100644 index 00000000000..e9f8a9a7ada --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlredirectactionparameters.go @@ -0,0 +1,55 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLRedirectActionParameters{} + +type URLRedirectActionParameters struct { + CustomFragment *string `json:"customFragment,omitempty"` + CustomHostname *string `json:"customHostname,omitempty"` + CustomPath *string `json:"customPath,omitempty"` + CustomQueryString *string `json:"customQueryString,omitempty"` + DestinationProtocol *DestinationProtocol `json:"destinationProtocol,omitempty"` + RedirectType RedirectType `json:"redirectType"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLRedirectActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLRedirectActionParameters{} + +func (s URLRedirectActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLRedirectActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRedirectActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRedirectActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlRedirectActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRedirectActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlrewriteaction.go b/resource-manager/cdn/2024-09-01/rules/model_urlrewriteaction.go new file mode 100644 index 00000000000..a8b1e21014c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlrewriteaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLRewriteAction{} + +type URLRewriteAction struct { + Parameters URLRewriteActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLRewriteAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLRewriteAction{} + +func (s URLRewriteAction) MarshalJSON() ([]byte, error) { + type wrapper URLRewriteAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRewriteAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRewriteAction: %+v", err) + } + + decoded["name"] = "UrlRewrite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRewriteAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlrewriteactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlrewriteactionparameters.go new file mode 100644 index 00000000000..e142109b425 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlrewriteactionparameters.go @@ -0,0 +1,52 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLRewriteActionParameters{} + +type URLRewriteActionParameters struct { + Destination string `json:"destination"` + PreserveUnmatchedPath *bool `json:"preserveUnmatchedPath,omitempty"` + SourcePattern string `json:"sourcePattern"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLRewriteActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLRewriteActionParameters{} + +func (s URLRewriteActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLRewriteActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLRewriteActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLRewriteActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlRewriteActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLRewriteActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlsigningaction.go b/resource-manager/cdn/2024-09-01/rules/model_urlsigningaction.go new file mode 100644 index 00000000000..7d5cb1faa22 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlsigningaction.go @@ -0,0 +1,50 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleAction = URLSigningAction{} + +type URLSigningAction struct { + Parameters URLSigningActionParameters `json:"parameters"` + + // Fields inherited from DeliveryRuleAction + + Name DeliveryRuleActionName `json:"name"` +} + +func (s URLSigningAction) DeliveryRuleAction() BaseDeliveryRuleActionImpl { + return BaseDeliveryRuleActionImpl{ + Name: s.Name, + } +} + +var _ json.Marshaler = URLSigningAction{} + +func (s URLSigningAction) MarshalJSON() ([]byte, error) { + type wrapper URLSigningAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLSigningAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLSigningAction: %+v", err) + } + + decoded["name"] = "UrlSigning" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLSigningAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlsigningactionparameters.go b/resource-manager/cdn/2024-09-01/rules/model_urlsigningactionparameters.go new file mode 100644 index 00000000000..787ca3ac7c1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlsigningactionparameters.go @@ -0,0 +1,51 @@ +package rules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeliveryRuleActionParameters = URLSigningActionParameters{} + +type URLSigningActionParameters struct { + Algorithm *Algorithm `json:"algorithm,omitempty"` + ParameterNameOverride *[]URLSigningParamIdentifier `json:"parameterNameOverride,omitempty"` + + // Fields inherited from DeliveryRuleActionParameters + + TypeName DeliveryRuleActionParametersType `json:"typeName"` +} + +func (s URLSigningActionParameters) DeliveryRuleActionParameters() BaseDeliveryRuleActionParametersImpl { + return BaseDeliveryRuleActionParametersImpl{ + TypeName: s.TypeName, + } +} + +var _ json.Marshaler = URLSigningActionParameters{} + +func (s URLSigningActionParameters) MarshalJSON() ([]byte, error) { + type wrapper URLSigningActionParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLSigningActionParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLSigningActionParameters: %+v", err) + } + + decoded["typeName"] = "DeliveryRuleUrlSigningActionParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLSigningActionParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/rules/model_urlsigningparamidentifier.go b/resource-manager/cdn/2024-09-01/rules/model_urlsigningparamidentifier.go new file mode 100644 index 00000000000..6b81c77c9b8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/model_urlsigningparamidentifier.go @@ -0,0 +1,9 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type URLSigningParamIdentifier struct { + ParamIndicator ParamIndicator `json:"paramIndicator"` + ParamName string `json:"paramName"` +} diff --git a/resource-manager/cdn/2024-09-01/rules/predicates.go b/resource-manager/cdn/2024-09-01/rules/predicates.go new file mode 100644 index 00000000000..0dd99d7ba7d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/predicates.go @@ -0,0 +1,27 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RuleOperationPredicate) Matches(input Rule) 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/cdn/2024-09-01/rules/version.go b/resource-manager/cdn/2024-09-01/rules/version.go new file mode 100644 index 00000000000..92f94359d2c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rules/version.go @@ -0,0 +1,10 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/rules/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/README.md b/resource-manager/cdn/2024-09-01/rulesets/README.md new file mode 100644 index 00000000000..ce11b14739e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/README.md @@ -0,0 +1,98 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/rulesets` Documentation + +The `rulesets` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/rulesets" +``` + + +### Client Initialization + +```go +client := rulesets.NewRuleSetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RuleSetsClient.Create` + +```go +ctx := context.TODO() +id := rulesets.NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + +read, err := client.Create(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RuleSetsClient.Delete` + +```go +ctx := context.TODO() +id := rulesets.NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RuleSetsClient.Get` + +```go +ctx := context.TODO() +id := rulesets.NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + +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: `RuleSetsClient.ListByProfile` + +```go +ctx := context.TODO() +id := rulesets.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RuleSetsClient.ListResourceUsage` + +```go +ctx := context.TODO() +id := rulesets.NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + +// alternatively `client.ListResourceUsage(ctx, id)` can be used to do batched pagination +items, err := client.ListResourceUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/cdn/2024-09-01/rulesets/client.go b/resource-manager/cdn/2024-09-01/rulesets/client.go new file mode 100644 index 00000000000..957ddc082f1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/client.go @@ -0,0 +1,26 @@ +package rulesets + +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 RuleSetsClient struct { + Client *resourcemanager.Client +} + +func NewRuleSetsClientWithBaseURI(sdkApi sdkEnv.Api) (*RuleSetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "rulesets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RuleSetsClient: %+v", err) + } + + return &RuleSetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/constants.go b/resource-manager/cdn/2024-09-01/rulesets/constants.go new file mode 100644 index 00000000000..4873ab357b0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/constants.go @@ -0,0 +1,145 @@ +package rulesets + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/id_profile.go b/resource-manager/cdn/2024-09-01/rulesets/id_profile.go new file mode 100644 index 00000000000..b194e908927 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/id_profile.go @@ -0,0 +1,130 @@ +package rulesets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/id_profile_test.go b/resource-manager/cdn/2024-09-01/rulesets/id_profile_test.go new file mode 100644 index 00000000000..cf619063d9e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/id_profile_test.go @@ -0,0 +1,282 @@ +package rulesets + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/rulesets/id_ruleset.go b/resource-manager/cdn/2024-09-01/rulesets/id_ruleset.go new file mode 100644 index 00000000000..88da7bd9695 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/id_ruleset.go @@ -0,0 +1,139 @@ +package rulesets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RuleSetId{}) +} + +var _ resourceids.ResourceId = &RuleSetId{} + +// RuleSetId is a struct representing the Resource ID for a Rule Set +type RuleSetId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + RuleSetName string +} + +// NewRuleSetID returns a new RuleSetId struct +func NewRuleSetID(subscriptionId string, resourceGroupName string, profileName string, ruleSetName string) RuleSetId { + return RuleSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + RuleSetName: ruleSetName, + } +} + +// ParseRuleSetID parses 'input' into a RuleSetId +func ParseRuleSetID(input string) (*RuleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleSetIDInsensitively parses 'input' case-insensitively into a RuleSetId +// note: this method should only be used for API response data and not user input +func ParseRuleSetIDInsensitively(input string) (*RuleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleSetId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.RuleSetName, ok = input.Parsed["ruleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleSetName", input) + } + + return nil +} + +// ValidateRuleSetID checks that 'input' can be parsed as a Rule Set ID +func ValidateRuleSetID(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 := ParseRuleSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Set ID +func (id RuleSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/ruleSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.RuleSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Set ID +func (id RuleSetId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticRuleSets", "ruleSets", "ruleSets"), + resourceids.UserSpecifiedSegment("ruleSetName", "ruleSetName"), + } +} + +// String returns a human-readable description of this Rule Set ID +func (id RuleSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Rule Set Name: %q", id.RuleSetName), + } + return fmt.Sprintf("Rule Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/id_ruleset_test.go b/resource-manager/cdn/2024-09-01/rulesets/id_ruleset_test.go new file mode 100644 index 00000000000..2194f32bf41 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/id_ruleset_test.go @@ -0,0 +1,327 @@ +package rulesets + +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 = &RuleSetId{} + +func TestNewRuleSetID(t *testing.T) { + id := NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.RuleSetName != "ruleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleSetName'", id.RuleSetName, "ruleSetName") + } +} + +func TestFormatRuleSetID(t *testing.T) { + actual := NewRuleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "ruleSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleSetId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleSetID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + } +} + +func TestParseRuleSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleSetId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + RuleSetName: "ruleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/ruleSets/ruleSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe", + Expected: &RuleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + RuleSetName: "rUlEsEtNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/rUlEsEtS/rUlEsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleSetIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.RuleSetName != v.Expected.RuleSetName { + t.Fatalf("Expected %q but got %q for RuleSetName", v.Expected.RuleSetName, actual.RuleSetName) + } + + } +} + +func TestSegmentsForRuleSetId(t *testing.T) { + segments := RuleSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleSetId 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/cdn/2024-09-01/rulesets/method_create.go b/resource-manager/cdn/2024-09-01/rulesets/method_create.go new file mode 100644 index 00000000000..25e6f40f5d1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/method_create.go @@ -0,0 +1,54 @@ +package rulesets + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RuleSet +} + +// Create ... +func (c RuleSetsClient) Create(ctx context.Context, id RuleSetId) (result CreateOperationResponse, 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 + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RuleSet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/method_delete.go b/resource-manager/cdn/2024-09-01/rulesets/method_delete.go new file mode 100644 index 00000000000..e0f00268a45 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/method_delete.go @@ -0,0 +1,71 @@ +package rulesets + +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 RuleSetsClient) Delete(ctx context.Context, id RuleSetId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 RuleSetsClient) DeleteThenPoll(ctx context.Context, id RuleSetId) 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/cdn/2024-09-01/rulesets/method_get.go b/resource-manager/cdn/2024-09-01/rulesets/method_get.go new file mode 100644 index 00000000000..5ea1977123d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/method_get.go @@ -0,0 +1,53 @@ +package rulesets + +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 *RuleSet +} + +// Get ... +func (c RuleSetsClient) Get(ctx context.Context, id RuleSetId) (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 + } + + var model RuleSet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/rulesets/method_listbyprofile.go new file mode 100644 index 00000000000..3c04ee6d0a7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/method_listbyprofile.go @@ -0,0 +1,105 @@ +package rulesets + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RuleSet +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []RuleSet +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c RuleSetsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/ruleSets", 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 *[]RuleSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c RuleSetsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, RuleSetOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RuleSetsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate RuleSetOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]RuleSet, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/method_listresourceusage.go b/resource-manager/cdn/2024-09-01/rulesets/method_listresourceusage.go new file mode 100644 index 00000000000..08a467d0bf5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/method_listresourceusage.go @@ -0,0 +1,105 @@ +package rulesets + +import ( + "context" + "fmt" + "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 ListResourceUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListResourceUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListResourceUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListResourceUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListResourceUsage ... +func (c RuleSetsClient) ListResourceUsage(ctx context.Context, id RuleSetId) (result ListResourceUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListResourceUsageCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListResourceUsageComplete retrieves all the results into a single object +func (c RuleSetsClient) ListResourceUsageComplete(ctx context.Context, id RuleSetId) (ListResourceUsageCompleteResult, error) { + return c.ListResourceUsageCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListResourceUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RuleSetsClient) ListResourceUsageCompleteMatchingPredicate(ctx context.Context, id RuleSetId, predicate UsageOperationPredicate) (result ListResourceUsageCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListResourceUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListResourceUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/model_ruleset.go b/resource-manager/cdn/2024-09-01/rulesets/model_ruleset.go new file mode 100644 index 00000000000..318adf43729 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/model_ruleset.go @@ -0,0 +1,16 @@ +package rulesets + +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 RuleSet struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RuleSetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/model_rulesetproperties.go b/resource-manager/cdn/2024-09-01/rulesets/model_rulesetproperties.go new file mode 100644 index 00000000000..55b980e2c52 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/model_rulesetproperties.go @@ -0,0 +1,10 @@ +package rulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleSetProperties struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/model_usage.go b/resource-manager/cdn/2024-09-01/rulesets/model_usage.go new file mode 100644 index 00000000000..54f0c36919f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/model_usage.go @@ -0,0 +1,12 @@ +package rulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue int64 `json:"currentValue"` + Id *string `json:"id,omitempty"` + Limit int64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/model_usagename.go b/resource-manager/cdn/2024-09-01/rulesets/model_usagename.go new file mode 100644 index 00000000000..023a3d43d61 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/model_usagename.go @@ -0,0 +1,9 @@ +package rulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/predicates.go b/resource-manager/cdn/2024-09-01/rulesets/predicates.go new file mode 100644 index 00000000000..0d67bcef083 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/predicates.go @@ -0,0 +1,50 @@ +package rulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuleSetOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RuleSetOperationPredicate) Matches(input RuleSet) 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 +} + +type UsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/cdn/2024-09-01/rulesets/version.go b/resource-manager/cdn/2024-09-01/rulesets/version.go new file mode 100644 index 00000000000..f43466dad42 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/rulesets/version.go @@ -0,0 +1,10 @@ +package rulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/rulesets/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/secrets/README.md b/resource-manager/cdn/2024-09-01/secrets/README.md new file mode 100644 index 00000000000..5ba51ec267d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/secrets` Documentation + +The `secrets` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/secrets" +``` + + +### Client Initialization + +```go +client := secrets.NewSecretsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecretsClient.Create` + +```go +ctx := context.TODO() +id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "secretName") + +payload := secrets.Secret{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecretsClient.Delete` + +```go +ctx := context.TODO() +id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "secretName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecretsClient.Get` + +```go +ctx := context.TODO() +id := secrets.NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "secretName") + +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: `SecretsClient.ListByProfile` + +```go +ctx := context.TODO() +id := secrets.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/cdn/2024-09-01/secrets/client.go b/resource-manager/cdn/2024-09-01/secrets/client.go new file mode 100644 index 00000000000..07a23983c45 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/client.go @@ -0,0 +1,26 @@ +package secrets + +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 SecretsClient struct { + Client *resourcemanager.Client +} + +func NewSecretsClientWithBaseURI(sdkApi sdkEnv.Api) (*SecretsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "secrets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecretsClient: %+v", err) + } + + return &SecretsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/constants.go b/resource-manager/cdn/2024-09-01/secrets/constants.go new file mode 100644 index 00000000000..c5fd9ff587b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/constants.go @@ -0,0 +1,154 @@ +package secrets + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type SecretType string + +const ( + SecretTypeAzureFirstPartyManagedCertificate SecretType = "AzureFirstPartyManagedCertificate" + SecretTypeCustomerCertificate SecretType = "CustomerCertificate" + SecretTypeManagedCertificate SecretType = "ManagedCertificate" + SecretTypeURLSigningKey SecretType = "UrlSigningKey" +) + +func PossibleValuesForSecretType() []string { + return []string{ + string(SecretTypeAzureFirstPartyManagedCertificate), + string(SecretTypeCustomerCertificate), + string(SecretTypeManagedCertificate), + string(SecretTypeURLSigningKey), + } +} + +func (s *SecretType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretType(input string) (*SecretType, error) { + vals := map[string]SecretType{ + "azurefirstpartymanagedcertificate": SecretTypeAzureFirstPartyManagedCertificate, + "customercertificate": SecretTypeCustomerCertificate, + "managedcertificate": SecretTypeManagedCertificate, + "urlsigningkey": SecretTypeURLSigningKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretType(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/id_profile.go b/resource-manager/cdn/2024-09-01/secrets/id_profile.go new file mode 100644 index 00000000000..34ee90b9a52 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/id_profile.go @@ -0,0 +1,130 @@ +package secrets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/secrets/id_profile_test.go b/resource-manager/cdn/2024-09-01/secrets/id_profile_test.go new file mode 100644 index 00000000000..20ecf498f5c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/id_profile_test.go @@ -0,0 +1,282 @@ +package secrets + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/secrets/id_secret.go b/resource-manager/cdn/2024-09-01/secrets/id_secret.go new file mode 100644 index 00000000000..abcee592643 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/id_secret.go @@ -0,0 +1,139 @@ +package secrets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SecretId{}) +} + +var _ resourceids.ResourceId = &SecretId{} + +// SecretId is a struct representing the Resource ID for a Secret +type SecretId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + SecretName string +} + +// NewSecretID returns a new SecretId struct +func NewSecretID(subscriptionId string, resourceGroupName string, profileName string, secretName string) SecretId { + return SecretId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + SecretName: secretName, + } +} + +// ParseSecretID parses 'input' into a SecretId +func ParseSecretID(input string) (*SecretId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecretId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecretId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecretIDInsensitively parses 'input' case-insensitively into a SecretId +// note: this method should only be used for API response data and not user input +func ParseSecretIDInsensitively(input string) (*SecretId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecretId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecretId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecretId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.SecretName, ok = input.Parsed["secretName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "secretName", input) + } + + return nil +} + +// ValidateSecretID checks that 'input' can be parsed as a Secret ID +func ValidateSecretID(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 := ParseSecretID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Secret ID +func (id SecretId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/secrets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.SecretName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Secret ID +func (id SecretId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticSecrets", "secrets", "secrets"), + resourceids.UserSpecifiedSegment("secretName", "secretName"), + } +} + +// String returns a human-readable description of this Secret ID +func (id SecretId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Secret Name: %q", id.SecretName), + } + return fmt.Sprintf("Secret (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/secrets/id_secret_test.go b/resource-manager/cdn/2024-09-01/secrets/id_secret_test.go new file mode 100644 index 00000000000..1ad85a96242 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/id_secret_test.go @@ -0,0 +1,327 @@ +package secrets + +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 = &SecretId{} + +func TestNewSecretID(t *testing.T) { + id := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "secretName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.SecretName != "secretName" { + t.Fatalf("Expected %q but got %q for Segment 'SecretName'", id.SecretName, "secretName") + } +} + +func TestFormatSecretID(t *testing.T) { + actual := NewSecretID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "secretName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets/secretName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecretID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecretId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets/secretName", + Expected: &SecretId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + SecretName: "secretName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets/secretName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecretID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.SecretName != v.Expected.SecretName { + t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) + } + + } +} + +func TestParseSecretIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecretId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/sEcReTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets/secretName", + Expected: &SecretId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + SecretName: "secretName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/secrets/secretName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/sEcReTs/sEcReTnAmE", + Expected: &SecretId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + SecretName: "sEcReTnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/sEcReTs/sEcReTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecretIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.SecretName != v.Expected.SecretName { + t.Fatalf("Expected %q but got %q for SecretName", v.Expected.SecretName, actual.SecretName) + } + + } +} + +func TestSegmentsForSecretId(t *testing.T) { + segments := SecretId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecretId 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/cdn/2024-09-01/secrets/method_create.go b/resource-manager/cdn/2024-09-01/secrets/method_create.go new file mode 100644 index 00000000000..65aac40ebab --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/method_create.go @@ -0,0 +1,76 @@ +package secrets + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Secret +} + +// Create ... +func (c SecretsClient) Create(ctx context.Context, id SecretId, input Secret) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SecretsClient) CreateThenPoll(ctx context.Context, id SecretId, input Secret) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/method_delete.go b/resource-manager/cdn/2024-09-01/secrets/method_delete.go new file mode 100644 index 00000000000..7740a7a1b9f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/method_delete.go @@ -0,0 +1,71 @@ +package secrets + +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 SecretsClient) Delete(ctx context.Context, id SecretId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SecretsClient) DeleteThenPoll(ctx context.Context, id SecretId) 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/cdn/2024-09-01/secrets/method_get.go b/resource-manager/cdn/2024-09-01/secrets/method_get.go new file mode 100644 index 00000000000..dd688babed6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/method_get.go @@ -0,0 +1,53 @@ +package secrets + +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 *Secret +} + +// Get ... +func (c SecretsClient) Get(ctx context.Context, id SecretId) (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 + } + + var model Secret + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/secrets/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/secrets/method_listbyprofile.go new file mode 100644 index 00000000000..425af171780 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/method_listbyprofile.go @@ -0,0 +1,105 @@ +package secrets + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Secret +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []Secret +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c SecretsClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/secrets", 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 *[]Secret `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c SecretsClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, SecretOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecretsClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate SecretOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]Secret, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_azurefirstpartymanagedcertificateparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_azurefirstpartymanagedcertificateparameters.go new file mode 100644 index 00000000000..16b490633d6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_azurefirstpartymanagedcertificateparameters.go @@ -0,0 +1,55 @@ +package secrets + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretParameters = AzureFirstPartyManagedCertificateParameters{} + +type AzureFirstPartyManagedCertificateParameters struct { + CertificateAuthority *string `json:"certificateAuthority,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + SecretSource *ResourceReference `json:"secretSource,omitempty"` + Subject *string `json:"subject,omitempty"` + SubjectAlternativeNames *[]string `json:"subjectAlternativeNames,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + + // Fields inherited from SecretParameters + + Type SecretType `json:"type"` +} + +func (s AzureFirstPartyManagedCertificateParameters) SecretParameters() BaseSecretParametersImpl { + return BaseSecretParametersImpl{ + Type: s.Type, + } +} + +var _ json.Marshaler = AzureFirstPartyManagedCertificateParameters{} + +func (s AzureFirstPartyManagedCertificateParameters) MarshalJSON() ([]byte, error) { + type wrapper AzureFirstPartyManagedCertificateParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFirstPartyManagedCertificateParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFirstPartyManagedCertificateParameters: %+v", err) + } + + decoded["type"] = "AzureFirstPartyManagedCertificate" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFirstPartyManagedCertificateParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_customercertificateparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_customercertificateparameters.go new file mode 100644 index 00000000000..4912cb0e09c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_customercertificateparameters.go @@ -0,0 +1,57 @@ +package secrets + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretParameters = CustomerCertificateParameters{} + +type CustomerCertificateParameters struct { + CertificateAuthority *string `json:"certificateAuthority,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + SecretSource ResourceReference `json:"secretSource"` + SecretVersion *string `json:"secretVersion,omitempty"` + Subject *string `json:"subject,omitempty"` + SubjectAlternativeNames *[]string `json:"subjectAlternativeNames,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + UseLatestVersion *bool `json:"useLatestVersion,omitempty"` + + // Fields inherited from SecretParameters + + Type SecretType `json:"type"` +} + +func (s CustomerCertificateParameters) SecretParameters() BaseSecretParametersImpl { + return BaseSecretParametersImpl{ + Type: s.Type, + } +} + +var _ json.Marshaler = CustomerCertificateParameters{} + +func (s CustomerCertificateParameters) MarshalJSON() ([]byte, error) { + type wrapper CustomerCertificateParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomerCertificateParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomerCertificateParameters: %+v", err) + } + + decoded["type"] = "CustomerCertificate" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomerCertificateParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_managedcertificateparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_managedcertificateparameters.go new file mode 100644 index 00000000000..0d50cb01461 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_managedcertificateparameters.go @@ -0,0 +1,51 @@ +package secrets + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretParameters = ManagedCertificateParameters{} + +type ManagedCertificateParameters struct { + ExpirationDate *string `json:"expirationDate,omitempty"` + Subject *string `json:"subject,omitempty"` + + // Fields inherited from SecretParameters + + Type SecretType `json:"type"` +} + +func (s ManagedCertificateParameters) SecretParameters() BaseSecretParametersImpl { + return BaseSecretParametersImpl{ + Type: s.Type, + } +} + +var _ json.Marshaler = ManagedCertificateParameters{} + +func (s ManagedCertificateParameters) MarshalJSON() ([]byte, error) { + type wrapper ManagedCertificateParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedCertificateParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedCertificateParameters: %+v", err) + } + + decoded["type"] = "ManagedCertificate" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedCertificateParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_resourcereference.go b/resource-manager/cdn/2024-09-01/secrets/model_resourcereference.go new file mode 100644 index 00000000000..873436b4dd8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_resourcereference.go @@ -0,0 +1,8 @@ +package secrets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_secret.go b/resource-manager/cdn/2024-09-01/secrets/model_secret.go new file mode 100644 index 00000000000..b6dcf9bbefb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_secret.go @@ -0,0 +1,16 @@ +package secrets + +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 Secret struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecretProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_secretparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_secretparameters.go new file mode 100644 index 00000000000..29be92c985c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_secretparameters.go @@ -0,0 +1,99 @@ +package secrets + +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 SecretParameters interface { + SecretParameters() BaseSecretParametersImpl +} + +var _ SecretParameters = BaseSecretParametersImpl{} + +type BaseSecretParametersImpl struct { + Type SecretType `json:"type"` +} + +func (s BaseSecretParametersImpl) SecretParameters() BaseSecretParametersImpl { + return s +} + +var _ SecretParameters = RawSecretParametersImpl{} + +// RawSecretParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSecretParametersImpl struct { + secretParameters BaseSecretParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawSecretParametersImpl) SecretParameters() BaseSecretParametersImpl { + return s.secretParameters +} + +func UnmarshalSecretParametersImplementation(input []byte) (SecretParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SecretParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureFirstPartyManagedCertificate") { + var out AzureFirstPartyManagedCertificateParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFirstPartyManagedCertificateParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CustomerCertificate") { + var out CustomerCertificateParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomerCertificateParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManagedCertificate") { + var out ManagedCertificateParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedCertificateParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UrlSigningKey") { + var out URLSigningKeyParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into URLSigningKeyParameters: %+v", err) + } + return out, nil + } + + var parent BaseSecretParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSecretParametersImpl: %+v", err) + } + + return RawSecretParametersImpl{ + secretParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_secretproperties.go b/resource-manager/cdn/2024-09-01/secrets/model_secretproperties.go new file mode 100644 index 00000000000..6609a5d69b2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_secretproperties.go @@ -0,0 +1,48 @@ +package secrets + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretProperties struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + Parameters SecretParameters `json:"parameters"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Unmarshaler = &SecretProperties{} + +func (s *SecretProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DeploymentStatus = decoded.DeploymentStatus + s.ProfileName = decoded.ProfileName + s.ProvisioningState = decoded.ProvisioningState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SecretProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["parameters"]; ok { + impl, err := UnmarshalSecretParametersImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Parameters' for 'SecretProperties': %+v", err) + } + s.Parameters = impl + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go new file mode 100644 index 00000000000..5030e7658ac --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go @@ -0,0 +1,52 @@ +package secrets + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecretParameters = URLSigningKeyParameters{} + +type URLSigningKeyParameters struct { + KeyId string `json:"keyId"` + SecretSource ResourceReference `json:"secretSource"` + SecretVersion *string `json:"secretVersion,omitempty"` + + // Fields inherited from SecretParameters + + Type SecretType `json:"type"` +} + +func (s URLSigningKeyParameters) SecretParameters() BaseSecretParametersImpl { + return BaseSecretParametersImpl{ + Type: s.Type, + } +} + +var _ json.Marshaler = URLSigningKeyParameters{} + +func (s URLSigningKeyParameters) MarshalJSON() ([]byte, error) { + type wrapper URLSigningKeyParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling URLSigningKeyParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling URLSigningKeyParameters: %+v", err) + } + + decoded["type"] = "UrlSigningKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling URLSigningKeyParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/secrets/predicates.go b/resource-manager/cdn/2024-09-01/secrets/predicates.go new file mode 100644 index 00000000000..7bff4879b50 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/predicates.go @@ -0,0 +1,27 @@ +package secrets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SecretOperationPredicate) Matches(input Secret) 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/cdn/2024-09-01/secrets/version.go b/resource-manager/cdn/2024-09-01/secrets/version.go new file mode 100644 index 00000000000..4eea8dfff06 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/secrets/version.go @@ -0,0 +1,10 @@ +package secrets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/secrets/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/README.md b/resource-manager/cdn/2024-09-01/securitypolicies/README.md new file mode 100644 index 00000000000..a3288c2db31 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/securitypolicies` Documentation + +The `securitypolicies` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/securitypolicies" +``` + + +### Client Initialization + +```go +client := securitypolicies.NewSecurityPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityPoliciesClient.Create` + +```go +ctx := context.TODO() +id := securitypolicies.NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName") + +payload := securitypolicies.SecurityPolicy{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := securitypolicies.NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityPoliciesClient.Get` + +```go +ctx := context.TODO() +id := securitypolicies.NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName") + +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: `SecurityPoliciesClient.ListByProfile` + +```go +ctx := context.TODO() +id := securitypolicies.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +// alternatively `client.ListByProfile(ctx, id)` can be used to do batched pagination +items, err := client.ListByProfileComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SecurityPoliciesClient.Patch` + +```go +ctx := context.TODO() +id := securitypolicies.NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName") + +payload := securitypolicies.SecurityPolicyUpdateParameters{ + // ... +} + + +if err := client.PatchThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/client.go b/resource-manager/cdn/2024-09-01/securitypolicies/client.go new file mode 100644 index 00000000000..55cc8c476cb --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/client.go @@ -0,0 +1,26 @@ +package securitypolicies + +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 SecurityPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewSecurityPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securitypolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityPoliciesClient: %+v", err) + } + + return &SecurityPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/constants.go b/resource-manager/cdn/2024-09-01/securitypolicies/constants.go new file mode 100644 index 00000000000..7354c2cb326 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/constants.go @@ -0,0 +1,145 @@ +package securitypolicies + +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 AfdProvisioningState string + +const ( + AfdProvisioningStateCreating AfdProvisioningState = "Creating" + AfdProvisioningStateDeleting AfdProvisioningState = "Deleting" + AfdProvisioningStateFailed AfdProvisioningState = "Failed" + AfdProvisioningStateSucceeded AfdProvisioningState = "Succeeded" + AfdProvisioningStateUpdating AfdProvisioningState = "Updating" +) + +func PossibleValuesForAfdProvisioningState() []string { + return []string{ + string(AfdProvisioningStateCreating), + string(AfdProvisioningStateDeleting), + string(AfdProvisioningStateFailed), + string(AfdProvisioningStateSucceeded), + string(AfdProvisioningStateUpdating), + } +} + +func (s *AfdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAfdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAfdProvisioningState(input string) (*AfdProvisioningState, error) { + vals := map[string]AfdProvisioningState{ + "creating": AfdProvisioningStateCreating, + "deleting": AfdProvisioningStateDeleting, + "failed": AfdProvisioningStateFailed, + "succeeded": AfdProvisioningStateSucceeded, + "updating": AfdProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AfdProvisioningState(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusInProgress DeploymentStatus = "InProgress" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" + DeploymentStatusSucceeded DeploymentStatus = "Succeeded" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusFailed), + string(DeploymentStatusInProgress), + string(DeploymentStatusNotStarted), + string(DeploymentStatusSucceeded), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "failed": DeploymentStatusFailed, + "inprogress": DeploymentStatusInProgress, + "notstarted": DeploymentStatusNotStarted, + "succeeded": DeploymentStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type SecurityPolicyType string + +const ( + SecurityPolicyTypeWebApplicationFirewall SecurityPolicyType = "WebApplicationFirewall" +) + +func PossibleValuesForSecurityPolicyType() []string { + return []string{ + string(SecurityPolicyTypeWebApplicationFirewall), + } +} + +func (s *SecurityPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityPolicyType(input string) (*SecurityPolicyType, error) { + vals := map[string]SecurityPolicyType{ + "webapplicationfirewall": SecurityPolicyTypeWebApplicationFirewall, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityPolicyType(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/id_profile.go b/resource-manager/cdn/2024-09-01/securitypolicies/id_profile.go new file mode 100644 index 00000000000..0b3e853a586 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/id_profile.go @@ -0,0 +1,130 @@ +package securitypolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/id_profile_test.go b/resource-manager/cdn/2024-09-01/securitypolicies/id_profile_test.go new file mode 100644 index 00000000000..7b278172e70 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/id_profile_test.go @@ -0,0 +1,282 @@ +package securitypolicies + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/securitypolicies/id_securitypolicy.go b/resource-manager/cdn/2024-09-01/securitypolicies/id_securitypolicy.go new file mode 100644 index 00000000000..f1972a72955 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/id_securitypolicy.go @@ -0,0 +1,139 @@ +package securitypolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SecurityPolicyId{}) +} + +var _ resourceids.ResourceId = &SecurityPolicyId{} + +// SecurityPolicyId is a struct representing the Resource ID for a Security Policy +type SecurityPolicyId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string + SecurityPolicyName string +} + +// NewSecurityPolicyID returns a new SecurityPolicyId struct +func NewSecurityPolicyID(subscriptionId string, resourceGroupName string, profileName string, securityPolicyName string) SecurityPolicyId { + return SecurityPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + SecurityPolicyName: securityPolicyName, + } +} + +// ParseSecurityPolicyID parses 'input' into a SecurityPolicyId +func ParseSecurityPolicyID(input string) (*SecurityPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityPolicyIDInsensitively parses 'input' case-insensitively into a SecurityPolicyId +// note: this method should only be used for API response data and not user input +func ParseSecurityPolicyIDInsensitively(input string) (*SecurityPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityPolicyId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.SecurityPolicyName, ok = input.Parsed["securityPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityPolicyName", input) + } + + return nil +} + +// ValidateSecurityPolicyID checks that 'input' can be parsed as a Security Policy ID +func ValidateSecurityPolicyID(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 := ParseSecurityPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Policy ID +func (id SecurityPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s/securityPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName, id.SecurityPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Policy ID +func (id SecurityPolicyId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticSecurityPolicies", "securityPolicies", "securityPolicies"), + resourceids.UserSpecifiedSegment("securityPolicyName", "securityPolicyName"), + } +} + +// String returns a human-readable description of this Security Policy ID +func (id SecurityPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Security Policy Name: %q", id.SecurityPolicyName), + } + return fmt.Sprintf("Security Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/id_securitypolicy_test.go b/resource-manager/cdn/2024-09-01/securitypolicies/id_securitypolicy_test.go new file mode 100644 index 00000000000..6fc70b5d78a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/id_securitypolicy_test.go @@ -0,0 +1,327 @@ +package securitypolicies + +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 = &SecurityPolicyId{} + +func TestNewSecurityPolicyID(t *testing.T) { + id := NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.SecurityPolicyName != "securityPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityPolicyName'", id.SecurityPolicyName, "securityPolicyName") + } +} + +func TestFormatSecurityPolicyID(t *testing.T) { + actual := NewSecurityPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName", "securityPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies/securityPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityPolicyId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies/securityPolicyName", + Expected: &SecurityPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + SecurityPolicyName: "securityPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies/securityPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityPolicyID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.SecurityPolicyName != v.Expected.SecurityPolicyName { + t.Fatalf("Expected %q but got %q for SecurityPolicyName", v.Expected.SecurityPolicyName, actual.SecurityPolicyName) + } + + } +} + +func TestParseSecurityPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityPolicyId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/sEcUrItYpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies/securityPolicyName", + Expected: &SecurityPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + SecurityPolicyName: "securityPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/securityPolicies/securityPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe/sEcUrItYpOlIcIeS/sEcUrItYpOlIcYnAmE", + Expected: &SecurityPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + SecurityPolicyName: "sEcUrItYpOlIcYnAmE", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/sEcUrItYpOlIcIeS/sEcUrItYpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityPolicyIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.SecurityPolicyName != v.Expected.SecurityPolicyName { + t.Fatalf("Expected %q but got %q for SecurityPolicyName", v.Expected.SecurityPolicyName, actual.SecurityPolicyName) + } + + } +} + +func TestSegmentsForSecurityPolicyId(t *testing.T) { + segments := SecurityPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityPolicyId 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/cdn/2024-09-01/securitypolicies/method_create.go b/resource-manager/cdn/2024-09-01/securitypolicies/method_create.go new file mode 100644 index 00000000000..a95ec9d76fd --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/method_create.go @@ -0,0 +1,76 @@ +package securitypolicies + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SecurityPolicy +} + +// Create ... +func (c SecurityPoliciesClient) Create(ctx context.Context, id SecurityPolicyId, input SecurityPolicy) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SecurityPoliciesClient) CreateThenPoll(ctx context.Context, id SecurityPolicyId, input SecurityPolicy) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/method_delete.go b/resource-manager/cdn/2024-09-01/securitypolicies/method_delete.go new file mode 100644 index 00000000000..9367d103c07 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/method_delete.go @@ -0,0 +1,71 @@ +package securitypolicies + +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 SecurityPoliciesClient) Delete(ctx context.Context, id SecurityPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SecurityPoliciesClient) DeleteThenPoll(ctx context.Context, id SecurityPolicyId) 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/cdn/2024-09-01/securitypolicies/method_get.go b/resource-manager/cdn/2024-09-01/securitypolicies/method_get.go new file mode 100644 index 00000000000..c6e380485b2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/method_get.go @@ -0,0 +1,53 @@ +package securitypolicies + +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 *SecurityPolicy +} + +// Get ... +func (c SecurityPoliciesClient) Get(ctx context.Context, id SecurityPolicyId) (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 + } + + var model SecurityPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/method_listbyprofile.go b/resource-manager/cdn/2024-09-01/securitypolicies/method_listbyprofile.go new file mode 100644 index 00000000000..322dbf96b30 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/method_listbyprofile.go @@ -0,0 +1,105 @@ +package securitypolicies + +import ( + "context" + "fmt" + "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 ListByProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityPolicy +} + +type ListByProfileCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityPolicy +} + +type ListByProfileCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByProfileCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByProfile ... +func (c SecurityPoliciesClient) ListByProfile(ctx context.Context, id ProfileId) (result ListByProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByProfileCustomPager{}, + Path: fmt.Sprintf("%s/securityPolicies", 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 *[]SecurityPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProfileComplete retrieves all the results into a single object +func (c SecurityPoliciesClient) ListByProfileComplete(ctx context.Context, id ProfileId) (ListByProfileCompleteResult, error) { + return c.ListByProfileCompleteMatchingPredicate(ctx, id, SecurityPolicyOperationPredicate{}) +} + +// ListByProfileCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityPoliciesClient) ListByProfileCompleteMatchingPredicate(ctx context.Context, id ProfileId, predicate SecurityPolicyOperationPredicate) (result ListByProfileCompleteResult, err error) { + items := make([]SecurityPolicy, 0) + + resp, err := c.ListByProfile(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByProfileCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/method_patch.go b/resource-manager/cdn/2024-09-01/securitypolicies/method_patch.go new file mode 100644 index 00000000000..c0f9a10b203 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/method_patch.go @@ -0,0 +1,75 @@ +package securitypolicies + +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 PatchOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SecurityPolicy +} + +// Patch ... +func (c SecurityPoliciesClient) Patch(ctx context.Context, id SecurityPolicyId, input SecurityPolicyUpdateParameters) (result PatchOperationResponse, 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 +} + +// PatchThenPoll performs Patch then polls until it's completed +func (c SecurityPoliciesClient) PatchThenPoll(ctx context.Context, id SecurityPolicyId, input SecurityPolicyUpdateParameters) error { + result, err := c.Patch(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Patch: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Patch: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_activatedresourcereference.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_activatedresourcereference.go new file mode 100644 index 00000000000..98cdc9bedc9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_activatedresourcereference.go @@ -0,0 +1,9 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivatedResourceReference struct { + Id *string `json:"id,omitempty"` + IsActive *bool `json:"isActive,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_resourcereference.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_resourcereference.go new file mode 100644 index 00000000000..d5146482393 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_resourcereference.go @@ -0,0 +1,8 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicy.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicy.go new file mode 100644 index 00000000000..798a87168df --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicy.go @@ -0,0 +1,16 @@ +package securitypolicies + +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 SecurityPolicy struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityPolicyProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyproperties.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyproperties.go new file mode 100644 index 00000000000..44b1c010941 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyproperties.go @@ -0,0 +1,48 @@ +package securitypolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyProperties struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + Parameters SecurityPolicyPropertiesParameters `json:"parameters"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Unmarshaler = &SecurityPolicyProperties{} + +func (s *SecurityPolicyProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + ProfileName *string `json:"profileName,omitempty"` + ProvisioningState *AfdProvisioningState `json:"provisioningState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DeploymentStatus = decoded.DeploymentStatus + s.ProfileName = decoded.ProfileName + s.ProvisioningState = decoded.ProvisioningState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SecurityPolicyProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["parameters"]; ok { + impl, err := UnmarshalSecurityPolicyPropertiesParametersImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Parameters' for 'SecurityPolicyProperties': %+v", err) + } + s.Parameters = impl + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicypropertiesparameters.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicypropertiesparameters.go new file mode 100644 index 00000000000..05ae120b4d4 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicypropertiesparameters.go @@ -0,0 +1,75 @@ +package securitypolicies + +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 SecurityPolicyPropertiesParameters interface { + SecurityPolicyPropertiesParameters() BaseSecurityPolicyPropertiesParametersImpl +} + +var _ SecurityPolicyPropertiesParameters = BaseSecurityPolicyPropertiesParametersImpl{} + +type BaseSecurityPolicyPropertiesParametersImpl struct { + Type SecurityPolicyType `json:"type"` +} + +func (s BaseSecurityPolicyPropertiesParametersImpl) SecurityPolicyPropertiesParameters() BaseSecurityPolicyPropertiesParametersImpl { + return s +} + +var _ SecurityPolicyPropertiesParameters = RawSecurityPolicyPropertiesParametersImpl{} + +// RawSecurityPolicyPropertiesParametersImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSecurityPolicyPropertiesParametersImpl struct { + securityPolicyPropertiesParameters BaseSecurityPolicyPropertiesParametersImpl + Type string + Values map[string]interface{} +} + +func (s RawSecurityPolicyPropertiesParametersImpl) SecurityPolicyPropertiesParameters() BaseSecurityPolicyPropertiesParametersImpl { + return s.securityPolicyPropertiesParameters +} + +func UnmarshalSecurityPolicyPropertiesParametersImplementation(input []byte) (SecurityPolicyPropertiesParameters, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SecurityPolicyPropertiesParameters into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "WebApplicationFirewall") { + var out SecurityPolicyWebApplicationFirewallParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SecurityPolicyWebApplicationFirewallParameters: %+v", err) + } + return out, nil + } + + var parent BaseSecurityPolicyPropertiesParametersImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSecurityPolicyPropertiesParametersImpl: %+v", err) + } + + return RawSecurityPolicyPropertiesParametersImpl{ + securityPolicyPropertiesParameters: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateparameters.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateparameters.go new file mode 100644 index 00000000000..c9ee5951959 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateparameters.go @@ -0,0 +1,8 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyUpdateParameters struct { + Properties *SecurityPolicyUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateproperties.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateproperties.go new file mode 100644 index 00000000000..231a621fb7a --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicyupdateproperties.go @@ -0,0 +1,33 @@ +package securitypolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyUpdateProperties struct { + Parameters SecurityPolicyPropertiesParameters `json:"parameters"` +} + +var _ json.Unmarshaler = &SecurityPolicyUpdateProperties{} + +func (s *SecurityPolicyUpdateProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SecurityPolicyUpdateProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["parameters"]; ok { + impl, err := UnmarshalSecurityPolicyPropertiesParametersImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Parameters' for 'SecurityPolicyUpdateProperties': %+v", err) + } + s.Parameters = impl + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallassociation.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallassociation.go new file mode 100644 index 00000000000..78cfbe4a259 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallassociation.go @@ -0,0 +1,9 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyWebApplicationFirewallAssociation struct { + Domains *[]ActivatedResourceReference `json:"domains,omitempty"` + PatternsToMatch *[]string `json:"patternsToMatch,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallparameters.go b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallparameters.go new file mode 100644 index 00000000000..26581196cc8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/model_securitypolicywebapplicationfirewallparameters.go @@ -0,0 +1,51 @@ +package securitypolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SecurityPolicyPropertiesParameters = SecurityPolicyWebApplicationFirewallParameters{} + +type SecurityPolicyWebApplicationFirewallParameters struct { + Associations *[]SecurityPolicyWebApplicationFirewallAssociation `json:"associations,omitempty"` + WafPolicy *ResourceReference `json:"wafPolicy,omitempty"` + + // Fields inherited from SecurityPolicyPropertiesParameters + + Type SecurityPolicyType `json:"type"` +} + +func (s SecurityPolicyWebApplicationFirewallParameters) SecurityPolicyPropertiesParameters() BaseSecurityPolicyPropertiesParametersImpl { + return BaseSecurityPolicyPropertiesParametersImpl{ + Type: s.Type, + } +} + +var _ json.Marshaler = SecurityPolicyWebApplicationFirewallParameters{} + +func (s SecurityPolicyWebApplicationFirewallParameters) MarshalJSON() ([]byte, error) { + type wrapper SecurityPolicyWebApplicationFirewallParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SecurityPolicyWebApplicationFirewallParameters: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SecurityPolicyWebApplicationFirewallParameters: %+v", err) + } + + decoded["type"] = "WebApplicationFirewall" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SecurityPolicyWebApplicationFirewallParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cdn/2024-09-01/securitypolicies/predicates.go b/resource-manager/cdn/2024-09-01/securitypolicies/predicates.go new file mode 100644 index 00000000000..4b70b7eef24 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/predicates.go @@ -0,0 +1,27 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SecurityPolicyOperationPredicate) Matches(input SecurityPolicy) 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/cdn/2024-09-01/securitypolicies/version.go b/resource-manager/cdn/2024-09-01/securitypolicies/version.go new file mode 100644 index 00000000000..08be56d9959 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/securitypolicies/version.go @@ -0,0 +1,10 @@ +package securitypolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securitypolicies/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/validateprobe/README.md b/resource-manager/cdn/2024-09-01/validateprobe/README.md new file mode 100644 index 00000000000..e36f7b65eac --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/validateprobe` Documentation + +The `validateprobe` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/validateprobe" +``` + + +### Client Initialization + +```go +client := validateprobe.NewValidateProbeClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ValidateProbeClient.ValidateProbe` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := validateprobe.ValidateProbeInput{ + // ... +} + + +read, err := client.ValidateProbe(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/validateprobe/client.go b/resource-manager/cdn/2024-09-01/validateprobe/client.go new file mode 100644 index 00000000000..b3f42961472 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/client.go @@ -0,0 +1,26 @@ +package validateprobe + +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 ValidateProbeClient struct { + Client *resourcemanager.Client +} + +func NewValidateProbeClientWithBaseURI(sdkApi sdkEnv.Api) (*ValidateProbeClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "validateprobe", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ValidateProbeClient: %+v", err) + } + + return &ValidateProbeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/validateprobe/method_validateprobe.go b/resource-manager/cdn/2024-09-01/validateprobe/method_validateprobe.go new file mode 100644 index 00000000000..18904e828f2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/method_validateprobe.go @@ -0,0 +1,59 @@ +package validateprobe + +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 ValidateProbeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateProbeOutput +} + +// ValidateProbe ... +func (c ValidateProbeClient) ValidateProbe(ctx context.Context, id commonids.SubscriptionId, input ValidateProbeInput) (result ValidateProbeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/validateProbe", 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 + } + + var model ValidateProbeOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeinput.go b/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeinput.go new file mode 100644 index 00000000000..cdc3cc24a15 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeinput.go @@ -0,0 +1,8 @@ +package validateprobe + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateProbeInput struct { + ProbeURL string `json:"probeURL"` +} diff --git a/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeoutput.go b/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeoutput.go new file mode 100644 index 00000000000..a6e30c2b48e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/model_validateprobeoutput.go @@ -0,0 +1,10 @@ +package validateprobe + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateProbeOutput struct { + ErrorCode *string `json:"errorCode,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/validateprobe/version.go b/resource-manager/cdn/2024-09-01/validateprobe/version.go new file mode 100644 index 00000000000..eeb5040f741 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/validateprobe/version.go @@ -0,0 +1,10 @@ +package validateprobe + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/validateprobe/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/README.md b/resource-manager/cdn/2024-09-01/wafloganalytics/README.md new file mode 100644 index 00000000000..42e346f9412 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/wafloganalytics` Documentation + +The `wafloganalytics` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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/cdn/2024-09-01/wafloganalytics" +``` + + +### Client Initialization + +```go +client := wafloganalytics.NewWafLogAnalyticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WafLogAnalyticsClient.LogAnalyticsGetWafLogAnalyticsMetrics` + +```go +ctx := context.TODO() +id := wafloganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.LogAnalyticsGetWafLogAnalyticsMetrics(ctx, id, wafloganalytics.DefaultLogAnalyticsGetWafLogAnalyticsMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WafLogAnalyticsClient.LogAnalyticsGetWafLogAnalyticsRankings` + +```go +ctx := context.TODO() +id := wafloganalytics.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + +read, err := client.LogAnalyticsGetWafLogAnalyticsRankings(ctx, id, wafloganalytics.DefaultLogAnalyticsGetWafLogAnalyticsRankingsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/client.go b/resource-manager/cdn/2024-09-01/wafloganalytics/client.go new file mode 100644 index 00000000000..9f7f2377b6d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/client.go @@ -0,0 +1,26 @@ +package wafloganalytics + +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 WafLogAnalyticsClient struct { + Client *resourcemanager.Client +} + +func NewWafLogAnalyticsClientWithBaseURI(sdkApi sdkEnv.Api) (*WafLogAnalyticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "wafloganalytics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WafLogAnalyticsClient: %+v", err) + } + + return &WafLogAnalyticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/constants.go b/resource-manager/cdn/2024-09-01/wafloganalytics/constants.go new file mode 100644 index 00000000000..a7b76c70b96 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/constants.go @@ -0,0 +1,136 @@ +package wafloganalytics + +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 WafGranularity string + +const ( + WafGranularityPOneD WafGranularity = "P1D" + WafGranularityPTFiveM WafGranularity = "PT5M" + WafGranularityPTOneH WafGranularity = "PT1H" +) + +func PossibleValuesForWafGranularity() []string { + return []string{ + string(WafGranularityPOneD), + string(WafGranularityPTFiveM), + string(WafGranularityPTOneH), + } +} + +func (s *WafGranularity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWafGranularity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWafGranularity(input string) (*WafGranularity, error) { + vals := map[string]WafGranularity{ + "p1d": WafGranularityPOneD, + "pt5m": WafGranularityPTFiveM, + "pt1h": WafGranularityPTOneH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WafGranularity(input) + return &out, nil +} + +type WafMetricsGranularity string + +const ( + WafMetricsGranularityPOneD WafMetricsGranularity = "P1D" + WafMetricsGranularityPTFiveM WafMetricsGranularity = "PT5M" + WafMetricsGranularityPTOneH WafMetricsGranularity = "PT1H" +) + +func PossibleValuesForWafMetricsGranularity() []string { + return []string{ + string(WafMetricsGranularityPOneD), + string(WafMetricsGranularityPTFiveM), + string(WafMetricsGranularityPTOneH), + } +} + +func (s *WafMetricsGranularity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWafMetricsGranularity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWafMetricsGranularity(input string) (*WafMetricsGranularity, error) { + vals := map[string]WafMetricsGranularity{ + "p1d": WafMetricsGranularityPOneD, + "pt5m": WafMetricsGranularityPTFiveM, + "pt1h": WafMetricsGranularityPTOneH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WafMetricsGranularity(input) + return &out, nil +} + +type WafMetricsSeriesUnit string + +const ( + WafMetricsSeriesUnitCount WafMetricsSeriesUnit = "count" +) + +func PossibleValuesForWafMetricsSeriesUnit() []string { + return []string{ + string(WafMetricsSeriesUnitCount), + } +} + +func (s *WafMetricsSeriesUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWafMetricsSeriesUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWafMetricsSeriesUnit(input string) (*WafMetricsSeriesUnit, error) { + vals := map[string]WafMetricsSeriesUnit{ + "count": WafMetricsSeriesUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WafMetricsSeriesUnit(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile.go b/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile.go new file mode 100644 index 00000000000..8a04ce29a01 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile.go @@ -0,0 +1,130 @@ +package wafloganalytics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) 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.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(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 := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile_test.go b/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile_test.go new file mode 100644 index 00000000000..c5090d524a5 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/id_profile_test.go @@ -0,0 +1,282 @@ +package wafloganalytics + +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 = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName") + + 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.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // 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.cDn/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(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.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId 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/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsmetrics.go b/resource-manager/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsmetrics.go new file mode 100644 index 00000000000..c372d449024 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsmetrics.go @@ -0,0 +1,107 @@ +package wafloganalytics + +import ( + "context" + "fmt" + "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 LogAnalyticsGetWafLogAnalyticsMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WafMetricsResponse +} + +type LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions struct { + Actions *[]string + DateTimeBegin *string + DateTimeEnd *string + Granularity *WafGranularity + GroupBy *[]string + Metrics *[]string + RuleTypes *[]string +} + +func DefaultLogAnalyticsGetWafLogAnalyticsMetricsOperationOptions() LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions { + return LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions{} +} + +func (o LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Actions != nil { + out.Append("actions", fmt.Sprintf("%v", *o.Actions)) + } + if o.DateTimeBegin != nil { + out.Append("dateTimeBegin", fmt.Sprintf("%v", *o.DateTimeBegin)) + } + if o.DateTimeEnd != nil { + out.Append("dateTimeEnd", fmt.Sprintf("%v", *o.DateTimeEnd)) + } + if o.Granularity != nil { + out.Append("granularity", fmt.Sprintf("%v", *o.Granularity)) + } + if o.GroupBy != nil { + out.Append("groupBy", fmt.Sprintf("%v", *o.GroupBy)) + } + if o.Metrics != nil { + out.Append("metrics", fmt.Sprintf("%v", *o.Metrics)) + } + if o.RuleTypes != nil { + out.Append("ruleTypes", fmt.Sprintf("%v", *o.RuleTypes)) + } + return &out +} + +// LogAnalyticsGetWafLogAnalyticsMetrics ... +func (c WafLogAnalyticsClient) LogAnalyticsGetWafLogAnalyticsMetrics(ctx context.Context, id ProfileId, options LogAnalyticsGetWafLogAnalyticsMetricsOperationOptions) (result LogAnalyticsGetWafLogAnalyticsMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/getWafLogAnalyticsMetrics", 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 + } + + var model WafMetricsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsrankings.go b/resource-manager/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsrankings.go new file mode 100644 index 00000000000..0b99c21208d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/method_loganalyticsgetwafloganalyticsrankings.go @@ -0,0 +1,107 @@ +package wafloganalytics + +import ( + "context" + "fmt" + "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 LogAnalyticsGetWafLogAnalyticsRankingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WafRankingsResponse +} + +type LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions struct { + Actions *[]string + DateTimeBegin *string + DateTimeEnd *string + MaxRanking *int64 + Metrics *[]string + Rankings *[]string + RuleTypes *[]string +} + +func DefaultLogAnalyticsGetWafLogAnalyticsRankingsOperationOptions() LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions { + return LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions{} +} + +func (o LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Actions != nil { + out.Append("actions", fmt.Sprintf("%v", *o.Actions)) + } + if o.DateTimeBegin != nil { + out.Append("dateTimeBegin", fmt.Sprintf("%v", *o.DateTimeBegin)) + } + if o.DateTimeEnd != nil { + out.Append("dateTimeEnd", fmt.Sprintf("%v", *o.DateTimeEnd)) + } + if o.MaxRanking != nil { + out.Append("maxRanking", fmt.Sprintf("%v", *o.MaxRanking)) + } + if o.Metrics != nil { + out.Append("metrics", fmt.Sprintf("%v", *o.Metrics)) + } + if o.Rankings != nil { + out.Append("rankings", fmt.Sprintf("%v", *o.Rankings)) + } + if o.RuleTypes != nil { + out.Append("ruleTypes", fmt.Sprintf("%v", *o.RuleTypes)) + } + return &out +} + +// LogAnalyticsGetWafLogAnalyticsRankings ... +func (c WafLogAnalyticsClient) LogAnalyticsGetWafLogAnalyticsRankings(ctx context.Context, id ProfileId, options LogAnalyticsGetWafLogAnalyticsRankingsOperationOptions) (result LogAnalyticsGetWafLogAnalyticsRankingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/getWafLogAnalyticsRankings", 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 + } + + var model WafRankingsResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponse.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponse.go new file mode 100644 index 00000000000..290fdaacf39 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponse.go @@ -0,0 +1,41 @@ +package wafloganalytics + +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 WafMetricsResponse struct { + DateTimeBegin *string `json:"dateTimeBegin,omitempty"` + DateTimeEnd *string `json:"dateTimeEnd,omitempty"` + Granularity *WafMetricsGranularity `json:"granularity,omitempty"` + Series *[]WafMetricsResponseSeriesInlined `json:"series,omitempty"` +} + +func (o *WafMetricsResponse) GetDateTimeBeginAsTime() (*time.Time, error) { + if o.DateTimeBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *WafMetricsResponse) SetDateTimeBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeBegin = &formatted +} + +func (o *WafMetricsResponse) GetDateTimeEndAsTime() (*time.Time, error) { + if o.DateTimeEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *WafMetricsResponse) SetDateTimeEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeEnd = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlined.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlined.go new file mode 100644 index 00000000000..684ed281daf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlined.go @@ -0,0 +1,11 @@ +package wafloganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WafMetricsResponseSeriesInlined struct { + Data *[]WafMetricsResponseSeriesInlinedDataInlined `json:"data,omitempty"` + Groups *[]WafMetricsResponseSeriesInlinedGroupsInlined `json:"groups,omitempty"` + Metric *string `json:"metric,omitempty"` + Unit *WafMetricsSeriesUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlineddatainlined.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlineddatainlined.go new file mode 100644 index 00000000000..d4ed9da14f3 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlineddatainlined.go @@ -0,0 +1,27 @@ +package wafloganalytics + +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 WafMetricsResponseSeriesInlinedDataInlined struct { + DateTime *string `json:"dateTime,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +func (o *WafMetricsResponseSeriesInlinedDataInlined) GetDateTimeAsTime() (*time.Time, error) { + if o.DateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WafMetricsResponseSeriesInlinedDataInlined) SetDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTime = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlinedgroupsinlined.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlinedgroupsinlined.go new file mode 100644 index 00000000000..df00ac2df23 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafmetricsresponseseriesinlinedgroupsinlined.go @@ -0,0 +1,9 @@ +package wafloganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WafMetricsResponseSeriesInlinedGroupsInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponse.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponse.go new file mode 100644 index 00000000000..a19dd330615 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponse.go @@ -0,0 +1,41 @@ +package wafloganalytics + +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 WafRankingsResponse struct { + Data *[]WafRankingsResponseDataInlined `json:"data,omitempty"` + DateTimeBegin *string `json:"dateTimeBegin,omitempty"` + DateTimeEnd *string `json:"dateTimeEnd,omitempty"` + Groups *[]string `json:"groups,omitempty"` +} + +func (o *WafRankingsResponse) GetDateTimeBeginAsTime() (*time.Time, error) { + if o.DateTimeBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *WafRankingsResponse) SetDateTimeBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeBegin = &formatted +} + +func (o *WafRankingsResponse) GetDateTimeEndAsTime() (*time.Time, error) { + if o.DateTimeEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DateTimeEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *WafRankingsResponse) SetDateTimeEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DateTimeEnd = &formatted +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlined.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlined.go new file mode 100644 index 00000000000..920ad82073f --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlined.go @@ -0,0 +1,9 @@ +package wafloganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WafRankingsResponseDataInlined struct { + GroupValues *[]string `json:"groupValues,omitempty"` + Metrics *[]WafRankingsResponseDataInlinedMetricsInlined `json:"metrics,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlinedmetricsinlined.go b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlinedmetricsinlined.go new file mode 100644 index 00000000000..995bfd9deee --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/model_wafrankingsresponsedatainlinedmetricsinlined.go @@ -0,0 +1,10 @@ +package wafloganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WafRankingsResponseDataInlinedMetricsInlined struct { + Metric *string `json:"metric,omitempty"` + Percentage *float64 `json:"percentage,omitempty"` + Value *int64 `json:"value,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/wafloganalytics/version.go b/resource-manager/cdn/2024-09-01/wafloganalytics/version.go new file mode 100644 index 00000000000..9e2723417ad --- /dev/null +++ b/resource-manager/cdn/2024-09-01/wafloganalytics/version.go @@ -0,0 +1,10 @@ +package wafloganalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/wafloganalytics/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/README.md b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/README.md new file mode 100644 index 00000000000..d8cda793ff2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets` Documentation + +The `webapplicationfirewallmanagedrulesets` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets" +``` + + +### Client Initialization + +```go +client := webapplicationfirewallmanagedrulesets.NewWebApplicationFirewallManagedRuleSetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebApplicationFirewallManagedRuleSetsClient.ManagedRuleSetsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ManagedRuleSetsList(ctx, id)` can be used to do batched pagination +items, err := client.ManagedRuleSetsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/client.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/client.go new file mode 100644 index 00000000000..53abfa89e7e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/client.go @@ -0,0 +1,26 @@ +package webapplicationfirewallmanagedrulesets + +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 WebApplicationFirewallManagedRuleSetsClient struct { + Client *resourcemanager.Client +} + +func NewWebApplicationFirewallManagedRuleSetsClientWithBaseURI(sdkApi sdkEnv.Api) (*WebApplicationFirewallManagedRuleSetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webapplicationfirewallmanagedrulesets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebApplicationFirewallManagedRuleSetsClient: %+v", err) + } + + return &WebApplicationFirewallManagedRuleSetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/constants.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/constants.go new file mode 100644 index 00000000000..62ef54e4413 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/constants.go @@ -0,0 +1,84 @@ +package webapplicationfirewallmanagedrulesets + +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 SkuName string + +const ( + SkuNameCustomVerizon SkuName = "Custom_Verizon" + SkuNamePremiumAzureFrontDoor SkuName = "Premium_AzureFrontDoor" + SkuNamePremiumVerizon SkuName = "Premium_Verizon" + SkuNameStandardAkamai SkuName = "Standard_Akamai" + SkuNameStandardAvgBandWidthChinaCdn SkuName = "Standard_AvgBandWidth_ChinaCdn" + SkuNameStandardAzureFrontDoor SkuName = "Standard_AzureFrontDoor" + SkuNameStandardChinaCdn SkuName = "Standard_ChinaCdn" + SkuNameStandardMicrosoft SkuName = "Standard_Microsoft" + SkuNameStandardNineFiveFiveBandWidthChinaCdn SkuName = "Standard_955BandWidth_ChinaCdn" + SkuNameStandardPlusAvgBandWidthChinaCdn SkuName = "StandardPlus_AvgBandWidth_ChinaCdn" + SkuNameStandardPlusChinaCdn SkuName = "StandardPlus_ChinaCdn" + SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn SkuName = "StandardPlus_955BandWidth_ChinaCdn" + SkuNameStandardVerizon SkuName = "Standard_Verizon" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameCustomVerizon), + string(SkuNamePremiumAzureFrontDoor), + string(SkuNamePremiumVerizon), + string(SkuNameStandardAkamai), + string(SkuNameStandardAvgBandWidthChinaCdn), + string(SkuNameStandardAzureFrontDoor), + string(SkuNameStandardChinaCdn), + string(SkuNameStandardMicrosoft), + string(SkuNameStandardNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardPlusAvgBandWidthChinaCdn), + string(SkuNameStandardPlusChinaCdn), + string(SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardVerizon), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "custom_verizon": SkuNameCustomVerizon, + "premium_azurefrontdoor": SkuNamePremiumAzureFrontDoor, + "premium_verizon": SkuNamePremiumVerizon, + "standard_akamai": SkuNameStandardAkamai, + "standard_avgbandwidth_chinacdn": SkuNameStandardAvgBandWidthChinaCdn, + "standard_azurefrontdoor": SkuNameStandardAzureFrontDoor, + "standard_chinacdn": SkuNameStandardChinaCdn, + "standard_microsoft": SkuNameStandardMicrosoft, + "standard_955bandwidth_chinacdn": SkuNameStandardNineFiveFiveBandWidthChinaCdn, + "standardplus_avgbandwidth_chinacdn": SkuNameStandardPlusAvgBandWidthChinaCdn, + "standardplus_chinacdn": SkuNameStandardPlusChinaCdn, + "standardplus_955bandwidth_chinacdn": SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn, + "standard_verizon": SkuNameStandardVerizon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/method_managedrulesetslist.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/method_managedrulesetslist.go new file mode 100644 index 00000000000..ed01a1188d7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/method_managedrulesetslist.go @@ -0,0 +1,106 @@ +package webapplicationfirewallmanagedrulesets + +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 ManagedRuleSetsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedRuleSetDefinition +} + +type ManagedRuleSetsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedRuleSetDefinition +} + +type ManagedRuleSetsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ManagedRuleSetsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ManagedRuleSetsList ... +func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsList(ctx context.Context, id commonids.SubscriptionId) (result ManagedRuleSetsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ManagedRuleSetsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/cdnWebApplicationFirewallManagedRuleSets", 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 *[]ManagedRuleSetDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedRuleSetsListComplete retrieves all the results into a single object +func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsListComplete(ctx context.Context, id commonids.SubscriptionId) (ManagedRuleSetsListCompleteResult, error) { + return c.ManagedRuleSetsListCompleteMatchingPredicate(ctx, id, ManagedRuleSetDefinitionOperationPredicate{}) +} + +// ManagedRuleSetsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedRuleSetDefinitionOperationPredicate) (result ManagedRuleSetsListCompleteResult, err error) { + items := make([]ManagedRuleSetDefinition, 0) + + resp, err := c.ManagedRuleSetsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ManagedRuleSetsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedruledefinition.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedruledefinition.go new file mode 100644 index 00000000000..d0cd3de3858 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedruledefinition.go @@ -0,0 +1,9 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleDefinition struct { + Description *string `json:"description,omitempty"` + RuleId *string `json:"ruleId,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulegroupdefinition.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulegroupdefinition.go new file mode 100644 index 00000000000..f2663854eb1 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulegroupdefinition.go @@ -0,0 +1,10 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleGroupDefinition struct { + Description *string `json:"description,omitempty"` + RuleGroupName *string `json:"ruleGroupName,omitempty"` + Rules *[]ManagedRuleDefinition `json:"rules,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinition.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinition.go new file mode 100644 index 00000000000..8771892ca42 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinition.go @@ -0,0 +1,17 @@ +package webapplicationfirewallmanagedrulesets + +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 ManagedRuleSetDefinition struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedRuleSetDefinitionProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinitionproperties.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinitionproperties.go new file mode 100644 index 00000000000..ea8c773005d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_managedrulesetdefinitionproperties.go @@ -0,0 +1,11 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSetDefinitionProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + RuleGroups *[]ManagedRuleGroupDefinition `json:"ruleGroups,omitempty"` + RuleSetType *string `json:"ruleSetType,omitempty"` + RuleSetVersion *string `json:"ruleSetVersion,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_sku.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_sku.go new file mode 100644 index 00000000000..d7de1d49a26 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/model_sku.go @@ -0,0 +1,8 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/predicates.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/predicates.go new file mode 100644 index 00000000000..f600223e4ee --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/predicates.go @@ -0,0 +1,27 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSetDefinitionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedRuleSetDefinitionOperationPredicate) Matches(input ManagedRuleSetDefinition) 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/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/version.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/version.go new file mode 100644 index 00000000000..75e7cdf9dd9 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallmanagedrulesets/version.go @@ -0,0 +1,10 @@ +package webapplicationfirewallmanagedrulesets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapplicationfirewallmanagedrulesets/2024-09-01" +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/README.md b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/README.md new file mode 100644 index 00000000000..228ccd55d8b --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/README.md @@ -0,0 +1,104 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies` Documentation + +The `webapplicationfirewallpolicies` SDK allows for interaction with Azure Resource Manager `cdn` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies" +``` + + +### Client Initialization + +```go +client := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesCreateOrUpdate` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName") + +payload := webapplicationfirewallpolicies.CdnWebApplicationFirewallPolicy{ + // ... +} + + +if err := client.PoliciesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesDelete` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName") + +read, err := client.PoliciesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesGet` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName") + +read, err := client.PoliciesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesList` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.PoliciesList(ctx, id)` can be used to do batched pagination +items, err := client.PoliciesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesUpdate` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName") + +payload := webapplicationfirewallpolicies.CdnWebApplicationFirewallPolicyPatchParameters{ + // ... +} + + +if err := client.PoliciesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/client.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/client.go new file mode 100644 index 00000000000..225049a7361 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/client.go @@ -0,0 +1,26 @@ +package webapplicationfirewallpolicies + +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 WebApplicationFirewallPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewWebApplicationFirewallPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*WebApplicationFirewallPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webapplicationfirewallpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebApplicationFirewallPoliciesClient: %+v", err) + } + + return &WebApplicationFirewallPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/constants.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/constants.go new file mode 100644 index 00000000000..674e07f7495 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/constants.go @@ -0,0 +1,628 @@ +package webapplicationfirewallpolicies + +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 ActionType string + +const ( + ActionTypeAllow ActionType = "Allow" + ActionTypeBlock ActionType = "Block" + ActionTypeLog ActionType = "Log" + ActionTypeRedirect ActionType = "Redirect" +) + +func PossibleValuesForActionType() []string { + return []string{ + string(ActionTypeAllow), + string(ActionTypeBlock), + string(ActionTypeLog), + string(ActionTypeRedirect), + } +} + +func (s *ActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActionType(input string) (*ActionType, error) { + vals := map[string]ActionType{ + "allow": ActionTypeAllow, + "block": ActionTypeBlock, + "log": ActionTypeLog, + "redirect": ActionTypeRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActionType(input) + return &out, nil +} + +type CustomRuleEnabledState string + +const ( + CustomRuleEnabledStateDisabled CustomRuleEnabledState = "Disabled" + CustomRuleEnabledStateEnabled CustomRuleEnabledState = "Enabled" +) + +func PossibleValuesForCustomRuleEnabledState() []string { + return []string{ + string(CustomRuleEnabledStateDisabled), + string(CustomRuleEnabledStateEnabled), + } +} + +func (s *CustomRuleEnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomRuleEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomRuleEnabledState(input string) (*CustomRuleEnabledState, error) { + vals := map[string]CustomRuleEnabledState{ + "disabled": CustomRuleEnabledStateDisabled, + "enabled": CustomRuleEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomRuleEnabledState(input) + return &out, nil +} + +type DefaultCustomBlockResponseStatusCode string + +const ( + DefaultCustomBlockResponseStatusCodeFourTwoNine DefaultCustomBlockResponseStatusCode = "429" + DefaultCustomBlockResponseStatusCodeFourZeroFive DefaultCustomBlockResponseStatusCode = "405" + DefaultCustomBlockResponseStatusCodeFourZeroSix DefaultCustomBlockResponseStatusCode = "406" + DefaultCustomBlockResponseStatusCodeFourZeroThree DefaultCustomBlockResponseStatusCode = "403" + DefaultCustomBlockResponseStatusCodeTwoHundred DefaultCustomBlockResponseStatusCode = "200" +) + +func PossibleValuesForDefaultCustomBlockResponseStatusCode() []string { + return []string{ + string(DefaultCustomBlockResponseStatusCodeFourTwoNine), + string(DefaultCustomBlockResponseStatusCodeFourZeroFive), + string(DefaultCustomBlockResponseStatusCodeFourZeroSix), + string(DefaultCustomBlockResponseStatusCodeFourZeroThree), + string(DefaultCustomBlockResponseStatusCodeTwoHundred), + } +} + +func (s *DefaultCustomBlockResponseStatusCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultCustomBlockResponseStatusCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultCustomBlockResponseStatusCode(input string) (*DefaultCustomBlockResponseStatusCode, error) { + vals := map[string]DefaultCustomBlockResponseStatusCode{ + "429": DefaultCustomBlockResponseStatusCodeFourTwoNine, + "405": DefaultCustomBlockResponseStatusCodeFourZeroFive, + "406": DefaultCustomBlockResponseStatusCodeFourZeroSix, + "403": DefaultCustomBlockResponseStatusCodeFourZeroThree, + "200": DefaultCustomBlockResponseStatusCodeTwoHundred, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultCustomBlockResponseStatusCode(input) + return &out, nil +} + +type ManagedRuleEnabledState string + +const ( + ManagedRuleEnabledStateDisabled ManagedRuleEnabledState = "Disabled" + ManagedRuleEnabledStateEnabled ManagedRuleEnabledState = "Enabled" +) + +func PossibleValuesForManagedRuleEnabledState() []string { + return []string{ + string(ManagedRuleEnabledStateDisabled), + string(ManagedRuleEnabledStateEnabled), + } +} + +func (s *ManagedRuleEnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedRuleEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedRuleEnabledState(input string) (*ManagedRuleEnabledState, error) { + vals := map[string]ManagedRuleEnabledState{ + "disabled": ManagedRuleEnabledStateDisabled, + "enabled": ManagedRuleEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleEnabledState(input) + return &out, nil +} + +type Operator string + +const ( + OperatorAny Operator = "Any" + OperatorBeginsWith Operator = "BeginsWith" + OperatorContains Operator = "Contains" + OperatorEndsWith Operator = "EndsWith" + OperatorEqual Operator = "Equal" + OperatorGeoMatch Operator = "GeoMatch" + OperatorGreaterThan Operator = "GreaterThan" + OperatorGreaterThanOrEqual Operator = "GreaterThanOrEqual" + OperatorIPMatch Operator = "IPMatch" + OperatorLessThan Operator = "LessThan" + OperatorLessThanOrEqual Operator = "LessThanOrEqual" + OperatorRegEx Operator = "RegEx" +) + +func PossibleValuesForOperator() []string { + return []string{ + string(OperatorAny), + string(OperatorBeginsWith), + string(OperatorContains), + string(OperatorEndsWith), + string(OperatorEqual), + string(OperatorGeoMatch), + string(OperatorGreaterThan), + string(OperatorGreaterThanOrEqual), + string(OperatorIPMatch), + string(OperatorLessThan), + string(OperatorLessThanOrEqual), + string(OperatorRegEx), + } +} + +func (s *Operator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperator(input string) (*Operator, error) { + vals := map[string]Operator{ + "any": OperatorAny, + "beginswith": OperatorBeginsWith, + "contains": OperatorContains, + "endswith": OperatorEndsWith, + "equal": OperatorEqual, + "geomatch": OperatorGeoMatch, + "greaterthan": OperatorGreaterThan, + "greaterthanorequal": OperatorGreaterThanOrEqual, + "ipmatch": OperatorIPMatch, + "lessthan": OperatorLessThan, + "lessthanorequal": OperatorLessThanOrEqual, + "regex": OperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Operator(input) + return &out, nil +} + +type PolicyEnabledState string + +const ( + PolicyEnabledStateDisabled PolicyEnabledState = "Disabled" + PolicyEnabledStateEnabled PolicyEnabledState = "Enabled" +) + +func PossibleValuesForPolicyEnabledState() []string { + return []string{ + string(PolicyEnabledStateDisabled), + string(PolicyEnabledStateEnabled), + } +} + +func (s *PolicyEnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyEnabledState(input string) (*PolicyEnabledState, error) { + vals := map[string]PolicyEnabledState{ + "disabled": PolicyEnabledStateDisabled, + "enabled": PolicyEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyEnabledState(input) + return &out, nil +} + +type PolicyMode string + +const ( + PolicyModeDetection PolicyMode = "Detection" + PolicyModePrevention PolicyMode = "Prevention" +) + +func PossibleValuesForPolicyMode() []string { + return []string{ + string(PolicyModeDetection), + string(PolicyModePrevention), + } +} + +func (s *PolicyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyMode(input string) (*PolicyMode, error) { + vals := map[string]PolicyMode{ + "detection": PolicyModeDetection, + "prevention": PolicyModePrevention, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyMode(input) + return &out, nil +} + +type PolicyResourceState string + +const ( + PolicyResourceStateCreating PolicyResourceState = "Creating" + PolicyResourceStateDeleting PolicyResourceState = "Deleting" + PolicyResourceStateDisabled PolicyResourceState = "Disabled" + PolicyResourceStateDisabling PolicyResourceState = "Disabling" + PolicyResourceStateEnabled PolicyResourceState = "Enabled" + PolicyResourceStateEnabling PolicyResourceState = "Enabling" +) + +func PossibleValuesForPolicyResourceState() []string { + return []string{ + string(PolicyResourceStateCreating), + string(PolicyResourceStateDeleting), + string(PolicyResourceStateDisabled), + string(PolicyResourceStateDisabling), + string(PolicyResourceStateEnabled), + string(PolicyResourceStateEnabling), + } +} + +func (s *PolicyResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyResourceState(input string) (*PolicyResourceState, error) { + vals := map[string]PolicyResourceState{ + "creating": PolicyResourceStateCreating, + "deleting": PolicyResourceStateDeleting, + "disabled": PolicyResourceStateDisabled, + "disabling": PolicyResourceStateDisabling, + "enabled": PolicyResourceStateEnabled, + "enabling": PolicyResourceStateEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyResourceState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCreating), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "creating": ProvisioningStateCreating, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameCustomVerizon SkuName = "Custom_Verizon" + SkuNamePremiumAzureFrontDoor SkuName = "Premium_AzureFrontDoor" + SkuNamePremiumVerizon SkuName = "Premium_Verizon" + SkuNameStandardAkamai SkuName = "Standard_Akamai" + SkuNameStandardAvgBandWidthChinaCdn SkuName = "Standard_AvgBandWidth_ChinaCdn" + SkuNameStandardAzureFrontDoor SkuName = "Standard_AzureFrontDoor" + SkuNameStandardChinaCdn SkuName = "Standard_ChinaCdn" + SkuNameStandardMicrosoft SkuName = "Standard_Microsoft" + SkuNameStandardNineFiveFiveBandWidthChinaCdn SkuName = "Standard_955BandWidth_ChinaCdn" + SkuNameStandardPlusAvgBandWidthChinaCdn SkuName = "StandardPlus_AvgBandWidth_ChinaCdn" + SkuNameStandardPlusChinaCdn SkuName = "StandardPlus_ChinaCdn" + SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn SkuName = "StandardPlus_955BandWidth_ChinaCdn" + SkuNameStandardVerizon SkuName = "Standard_Verizon" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameCustomVerizon), + string(SkuNamePremiumAzureFrontDoor), + string(SkuNamePremiumVerizon), + string(SkuNameStandardAkamai), + string(SkuNameStandardAvgBandWidthChinaCdn), + string(SkuNameStandardAzureFrontDoor), + string(SkuNameStandardChinaCdn), + string(SkuNameStandardMicrosoft), + string(SkuNameStandardNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardPlusAvgBandWidthChinaCdn), + string(SkuNameStandardPlusChinaCdn), + string(SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn), + string(SkuNameStandardVerizon), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "custom_verizon": SkuNameCustomVerizon, + "premium_azurefrontdoor": SkuNamePremiumAzureFrontDoor, + "premium_verizon": SkuNamePremiumVerizon, + "standard_akamai": SkuNameStandardAkamai, + "standard_avgbandwidth_chinacdn": SkuNameStandardAvgBandWidthChinaCdn, + "standard_azurefrontdoor": SkuNameStandardAzureFrontDoor, + "standard_chinacdn": SkuNameStandardChinaCdn, + "standard_microsoft": SkuNameStandardMicrosoft, + "standard_955bandwidth_chinacdn": SkuNameStandardNineFiveFiveBandWidthChinaCdn, + "standardplus_avgbandwidth_chinacdn": SkuNameStandardPlusAvgBandWidthChinaCdn, + "standardplus_chinacdn": SkuNameStandardPlusChinaCdn, + "standardplus_955bandwidth_chinacdn": SkuNameStandardPlusNineFiveFiveBandWidthChinaCdn, + "standard_verizon": SkuNameStandardVerizon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type TransformType string + +const ( + TransformTypeLowercase TransformType = "Lowercase" + TransformTypeRemoveNulls TransformType = "RemoveNulls" + TransformTypeTrim TransformType = "Trim" + TransformTypeURLDecode TransformType = "UrlDecode" + TransformTypeURLEncode TransformType = "UrlEncode" + TransformTypeUppercase TransformType = "Uppercase" +) + +func PossibleValuesForTransformType() []string { + return []string{ + string(TransformTypeLowercase), + string(TransformTypeRemoveNulls), + string(TransformTypeTrim), + string(TransformTypeURLDecode), + string(TransformTypeURLEncode), + string(TransformTypeUppercase), + } +} + +func (s *TransformType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransformType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransformType(input string) (*TransformType, error) { + vals := map[string]TransformType{ + "lowercase": TransformTypeLowercase, + "removenulls": TransformTypeRemoveNulls, + "trim": TransformTypeTrim, + "urldecode": TransformTypeURLDecode, + "urlencode": TransformTypeURLEncode, + "uppercase": TransformTypeUppercase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransformType(input) + return &out, nil +} + +type WafMatchVariable string + +const ( + WafMatchVariableCookies WafMatchVariable = "Cookies" + WafMatchVariablePostArgs WafMatchVariable = "PostArgs" + WafMatchVariableQueryString WafMatchVariable = "QueryString" + WafMatchVariableRemoteAddr WafMatchVariable = "RemoteAddr" + WafMatchVariableRequestBody WafMatchVariable = "RequestBody" + WafMatchVariableRequestHeader WafMatchVariable = "RequestHeader" + WafMatchVariableRequestMethod WafMatchVariable = "RequestMethod" + WafMatchVariableRequestUri WafMatchVariable = "RequestUri" + WafMatchVariableSocketAddr WafMatchVariable = "SocketAddr" +) + +func PossibleValuesForWafMatchVariable() []string { + return []string{ + string(WafMatchVariableCookies), + string(WafMatchVariablePostArgs), + string(WafMatchVariableQueryString), + string(WafMatchVariableRemoteAddr), + string(WafMatchVariableRequestBody), + string(WafMatchVariableRequestHeader), + string(WafMatchVariableRequestMethod), + string(WafMatchVariableRequestUri), + string(WafMatchVariableSocketAddr), + } +} + +func (s *WafMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWafMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWafMatchVariable(input string) (*WafMatchVariable, error) { + vals := map[string]WafMatchVariable{ + "cookies": WafMatchVariableCookies, + "postargs": WafMatchVariablePostArgs, + "querystring": WafMatchVariableQueryString, + "remoteaddr": WafMatchVariableRemoteAddr, + "requestbody": WafMatchVariableRequestBody, + "requestheader": WafMatchVariableRequestHeader, + "requestmethod": WafMatchVariableRequestMethod, + "requesturi": WafMatchVariableRequestUri, + "socketaddr": WafMatchVariableSocketAddr, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WafMatchVariable(input) + return &out, nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy.go new file mode 100644 index 00000000000..6153eee68ae --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy.go @@ -0,0 +1,130 @@ +package webapplicationfirewallpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CdnWebApplicationFirewallPolicyId{}) +} + +var _ resourceids.ResourceId = &CdnWebApplicationFirewallPolicyId{} + +// CdnWebApplicationFirewallPolicyId is a struct representing the Resource ID for a Cdn Web Application Firewall Policy +type CdnWebApplicationFirewallPolicyId struct { + SubscriptionId string + ResourceGroupName string + CdnWebApplicationFirewallPolicyName string +} + +// NewCdnWebApplicationFirewallPolicyID returns a new CdnWebApplicationFirewallPolicyId struct +func NewCdnWebApplicationFirewallPolicyID(subscriptionId string, resourceGroupName string, cdnWebApplicationFirewallPolicyName string) CdnWebApplicationFirewallPolicyId { + return CdnWebApplicationFirewallPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CdnWebApplicationFirewallPolicyName: cdnWebApplicationFirewallPolicyName, + } +} + +// ParseCdnWebApplicationFirewallPolicyID parses 'input' into a CdnWebApplicationFirewallPolicyId +func ParseCdnWebApplicationFirewallPolicyID(input string) (*CdnWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CdnWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CdnWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCdnWebApplicationFirewallPolicyIDInsensitively parses 'input' case-insensitively into a CdnWebApplicationFirewallPolicyId +// note: this method should only be used for API response data and not user input +func ParseCdnWebApplicationFirewallPolicyIDInsensitively(input string) (*CdnWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CdnWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CdnWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CdnWebApplicationFirewallPolicyId) 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.CdnWebApplicationFirewallPolicyName, ok = input.Parsed["cdnWebApplicationFirewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cdnWebApplicationFirewallPolicyName", input) + } + + return nil +} + +// ValidateCdnWebApplicationFirewallPolicyID checks that 'input' can be parsed as a Cdn Web Application Firewall Policy ID +func ValidateCdnWebApplicationFirewallPolicyID(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 := ParseCdnWebApplicationFirewallPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cdn Web Application Firewall Policy ID +func (id CdnWebApplicationFirewallPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CdnWebApplicationFirewallPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cdn Web Application Firewall Policy ID +func (id CdnWebApplicationFirewallPolicyId) 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("staticMicrosoftCDN", "Microsoft.CDN", "Microsoft.CDN"), + resourceids.StaticSegment("staticCdnWebApplicationFirewallPolicies", "cdnWebApplicationFirewallPolicies", "cdnWebApplicationFirewallPolicies"), + resourceids.UserSpecifiedSegment("cdnWebApplicationFirewallPolicyName", "cdnWebApplicationFirewallPolicyName"), + } +} + +// String returns a human-readable description of this Cdn Web Application Firewall Policy ID +func (id CdnWebApplicationFirewallPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cdn Web Application Firewall Policy Name: %q", id.CdnWebApplicationFirewallPolicyName), + } + return fmt.Sprintf("Cdn Web Application Firewall Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy_test.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy_test.go new file mode 100644 index 00000000000..87fd6a25f66 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/id_cdnwebapplicationfirewallpolicy_test.go @@ -0,0 +1,282 @@ +package webapplicationfirewallpolicies + +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 = &CdnWebApplicationFirewallPolicyId{} + +func TestNewCdnWebApplicationFirewallPolicyID(t *testing.T) { + id := NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName") + + 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.CdnWebApplicationFirewallPolicyName != "cdnWebApplicationFirewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'CdnWebApplicationFirewallPolicyName'", id.CdnWebApplicationFirewallPolicyName, "cdnWebApplicationFirewallPolicyName") + } +} + +func TestFormatCdnWebApplicationFirewallPolicyID(t *testing.T) { + actual := NewCdnWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cdnWebApplicationFirewallPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/cdnWebApplicationFirewallPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCdnWebApplicationFirewallPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CdnWebApplicationFirewallPolicyId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/cdnWebApplicationFirewallPolicyName", + Expected: &CdnWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CdnWebApplicationFirewallPolicyName: "cdnWebApplicationFirewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/cdnWebApplicationFirewallPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCdnWebApplicationFirewallPolicyID(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.CdnWebApplicationFirewallPolicyName != v.Expected.CdnWebApplicationFirewallPolicyName { + t.Fatalf("Expected %q but got %q for CdnWebApplicationFirewallPolicyName", v.Expected.CdnWebApplicationFirewallPolicyName, actual.CdnWebApplicationFirewallPolicyName) + } + + } +} + +func TestParseCdnWebApplicationFirewallPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CdnWebApplicationFirewallPolicyId + }{ + { + // 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.CDN", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/cDnWeBaPpLiCaTiOnFiReWaLlPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/cdnWebApplicationFirewallPolicyName", + Expected: &CdnWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CdnWebApplicationFirewallPolicyName: "cdnWebApplicationFirewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies/cdnWebApplicationFirewallPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cDn/cDnWeBaPpLiCaTiOnFiReWaLlPoLiCiEs/cDnWeBaPpLiCaTiOnFiReWaLlPoLiCyNaMe", + Expected: &CdnWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CdnWebApplicationFirewallPolicyName: "cDnWeBaPpLiCaTiOnFiReWaLlPoLiCyNaMe", + }, + }, + { + // 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.cDn/cDnWeBaPpLiCaTiOnFiReWaLlPoLiCiEs/cDnWeBaPpLiCaTiOnFiReWaLlPoLiCyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCdnWebApplicationFirewallPolicyIDInsensitively(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.CdnWebApplicationFirewallPolicyName != v.Expected.CdnWebApplicationFirewallPolicyName { + t.Fatalf("Expected %q but got %q for CdnWebApplicationFirewallPolicyName", v.Expected.CdnWebApplicationFirewallPolicyName, actual.CdnWebApplicationFirewallPolicyName) + } + + } +} + +func TestSegmentsForCdnWebApplicationFirewallPolicyId(t *testing.T) { + segments := CdnWebApplicationFirewallPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CdnWebApplicationFirewallPolicyId 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/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiescreateorupdate.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiescreateorupdate.go new file mode 100644 index 00000000000..38ad5015c89 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiescreateorupdate.go @@ -0,0 +1,76 @@ +package webapplicationfirewallpolicies + +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 PoliciesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CdnWebApplicationFirewallPolicy +} + +// PoliciesCreateOrUpdate ... +func (c WebApplicationFirewallPoliciesClient) PoliciesCreateOrUpdate(ctx context.Context, id CdnWebApplicationFirewallPolicyId, input CdnWebApplicationFirewallPolicy) (result PoliciesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// PoliciesCreateOrUpdateThenPoll performs PoliciesCreateOrUpdate then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) PoliciesCreateOrUpdateThenPoll(ctx context.Context, id CdnWebApplicationFirewallPolicyId, input CdnWebApplicationFirewallPolicy) error { + result, err := c.PoliciesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoliciesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PoliciesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesdelete.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesdelete.go new file mode 100644 index 00000000000..6de9740fac2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesdelete.go @@ -0,0 +1,47 @@ +package webapplicationfirewallpolicies + +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 PoliciesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PoliciesDelete ... +func (c WebApplicationFirewallPoliciesClient) PoliciesDelete(ctx context.Context, id CdnWebApplicationFirewallPolicyId) (result PoliciesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesget.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesget.go new file mode 100644 index 00000000000..9323fcfa2f2 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesget.go @@ -0,0 +1,53 @@ +package webapplicationfirewallpolicies + +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 PoliciesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CdnWebApplicationFirewallPolicy +} + +// PoliciesGet ... +func (c WebApplicationFirewallPoliciesClient) PoliciesGet(ctx context.Context, id CdnWebApplicationFirewallPolicyId) (result PoliciesGetOperationResponse, 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 + } + + var model CdnWebApplicationFirewallPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policieslist.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policieslist.go new file mode 100644 index 00000000000..308944ddafe --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policieslist.go @@ -0,0 +1,106 @@ +package webapplicationfirewallpolicies + +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 PoliciesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CdnWebApplicationFirewallPolicy +} + +type PoliciesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CdnWebApplicationFirewallPolicy +} + +type PoliciesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PoliciesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PoliciesList ... +func (c WebApplicationFirewallPoliciesClient) PoliciesList(ctx context.Context, id commonids.ResourceGroupId) (result PoliciesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PoliciesListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CDN/cdnWebApplicationFirewallPolicies", 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 *[]CdnWebApplicationFirewallPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PoliciesListComplete retrieves all the results into a single object +func (c WebApplicationFirewallPoliciesClient) PoliciesListComplete(ctx context.Context, id commonids.ResourceGroupId) (PoliciesListCompleteResult, error) { + return c.PoliciesListCompleteMatchingPredicate(ctx, id, CdnWebApplicationFirewallPolicyOperationPredicate{}) +} + +// PoliciesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebApplicationFirewallPoliciesClient) PoliciesListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CdnWebApplicationFirewallPolicyOperationPredicate) (result PoliciesListCompleteResult, err error) { + items := make([]CdnWebApplicationFirewallPolicy, 0) + + resp, err := c.PoliciesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = PoliciesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesupdate.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesupdate.go new file mode 100644 index 00000000000..1eb13e013e7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/method_policiesupdate.go @@ -0,0 +1,75 @@ +package webapplicationfirewallpolicies + +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 PoliciesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CdnWebApplicationFirewallPolicy +} + +// PoliciesUpdate ... +func (c WebApplicationFirewallPoliciesClient) PoliciesUpdate(ctx context.Context, id CdnWebApplicationFirewallPolicyId, input CdnWebApplicationFirewallPolicyPatchParameters) (result PoliciesUpdateOperationResponse, 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 +} + +// PoliciesUpdateThenPoll performs PoliciesUpdate then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) PoliciesUpdateThenPoll(ctx context.Context, id CdnWebApplicationFirewallPolicyId, input CdnWebApplicationFirewallPolicyPatchParameters) error { + result, err := c.PoliciesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoliciesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PoliciesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnendpoint.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnendpoint.go new file mode 100644 index 00000000000..7c542c2a5f7 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnendpoint.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CdnEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicy.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicy.go new file mode 100644 index 00000000000..f156b758d77 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicy.go @@ -0,0 +1,20 @@ +package webapplicationfirewallpolicies + +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 CdnWebApplicationFirewallPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CdnWebApplicationFirewallPolicyProperties `json:"properties,omitempty"` + Sku Sku `json:"sku"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicypatchparameters.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicypatchparameters.go new file mode 100644 index 00000000000..54afad300f6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicypatchparameters.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CdnWebApplicationFirewallPolicyPatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicyproperties.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicyproperties.go new file mode 100644 index 00000000000..76344cc38c0 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_cdnwebapplicationfirewallpolicyproperties.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CdnWebApplicationFirewallPolicyProperties struct { + CustomRules *CustomRuleList `json:"customRules,omitempty"` + EndpointLinks *[]CdnEndpoint `json:"endpointLinks,omitempty"` + ExtendedProperties *map[string]string `json:"extendedProperties,omitempty"` + ManagedRules *ManagedRuleSetList `json:"managedRules,omitempty"` + PolicySettings *PolicySettings `json:"policySettings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RateLimitRules *RateLimitRuleList `json:"rateLimitRules,omitempty"` + ResourceState *PolicyResourceState `json:"resourceState,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrule.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrule.go new file mode 100644 index 00000000000..12ff090b028 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomRule struct { + Action ActionType `json:"action"` + EnabledState *CustomRuleEnabledState `json:"enabledState,omitempty"` + MatchConditions []MatchCondition `json:"matchConditions"` + Name string `json:"name"` + Priority int64 `json:"priority"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrulelist.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrulelist.go new file mode 100644 index 00000000000..4af1175aedf --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_customrulelist.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomRuleList struct { + Rules *[]CustomRule `json:"rules,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go new file mode 100644 index 00000000000..2810e8e0e4d --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleGroupOverride struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]ManagedRuleOverride `json:"rules,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleoverride.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleoverride.go new file mode 100644 index 00000000000..595df8bc503 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleoverride.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleOverride struct { + Action *ActionType `json:"action,omitempty"` + EnabledState *ManagedRuleEnabledState `json:"enabledState,omitempty"` + RuleId string `json:"ruleId"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleset.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleset.go new file mode 100644 index 00000000000..b3a1388f11e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedruleset.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSet struct { + AnomalyScore *int64 `json:"anomalyScore,omitempty"` + RuleGroupOverrides *[]ManagedRuleGroupOverride `json:"ruleGroupOverrides,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulesetlist.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulesetlist.go new file mode 100644 index 00000000000..f15de67cc0c --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_managedrulesetlist.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSetList struct { + ManagedRuleSets *[]ManagedRuleSet `json:"managedRuleSets,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_matchcondition.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_matchcondition.go new file mode 100644 index 00000000000..52283db218e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_matchcondition.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MatchCondition struct { + MatchValue []string `json:"matchValue"` + MatchVariable WafMatchVariable `json:"matchVariable"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator Operator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]TransformType `json:"transforms,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_policysettings.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_policysettings.go new file mode 100644 index 00000000000..c9c6b06dcc8 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_policysettings.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySettings struct { + DefaultCustomBlockResponseBody *string `json:"defaultCustomBlockResponseBody,omitempty"` + DefaultCustomBlockResponseStatusCode *DefaultCustomBlockResponseStatusCode `json:"defaultCustomBlockResponseStatusCode,omitempty"` + DefaultRedirectURL *string `json:"defaultRedirectUrl,omitempty"` + EnabledState *PolicyEnabledState `json:"enabledState,omitempty"` + Mode *PolicyMode `json:"mode,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrule.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrule.go new file mode 100644 index 00000000000..591db9da11e --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrule.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RateLimitRule struct { + Action ActionType `json:"action"` + EnabledState *CustomRuleEnabledState `json:"enabledState,omitempty"` + MatchConditions []MatchCondition `json:"matchConditions"` + Name string `json:"name"` + Priority int64 `json:"priority"` + RateLimitDurationInMinutes int64 `json:"rateLimitDurationInMinutes"` + RateLimitThreshold int64 `json:"rateLimitThreshold"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrulelist.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrulelist.go new file mode 100644 index 00000000000..b7180c9f619 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_ratelimitrulelist.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RateLimitRuleList struct { + Rules *[]RateLimitRule `json:"rules,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_sku.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_sku.go new file mode 100644 index 00000000000..2a73ceadea6 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/model_sku.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/predicates.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/predicates.go new file mode 100644 index 00000000000..efe55879414 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/predicates.go @@ -0,0 +1,37 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CdnWebApplicationFirewallPolicyOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p CdnWebApplicationFirewallPolicyOperationPredicate) Matches(input CdnWebApplicationFirewallPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/cdn/2024-09-01/webapplicationfirewallpolicies/version.go b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/version.go new file mode 100644 index 00000000000..4e845295630 --- /dev/null +++ b/resource-manager/cdn/2024-09-01/webapplicationfirewallpolicies/version.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapplicationfirewallpolicies/2024-09-01" +} diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go index b0a6f866bbf..8e782d61b0d 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_postgresqlv2linkedservicetypeproperties.go @@ -4,6 +4,7 @@ package dataflowdebugsession // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PostgreSqlV2LinkedServiceTypeProperties struct { + AuthenticationType string `json:"authenticationType"` CommandTimeout *int64 `json:"commandTimeout,omitempty"` ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` Database string `json:"database"` diff --git a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go index 2f7976d6f56..f4cd2249456 100644 --- a/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_snowflakelinkedv2servicetypeproperties.go @@ -15,6 +15,7 @@ type SnowflakeLinkedV2ServiceTypeProperties struct { ClientSecret SecretBase `json:"clientSecret"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Password SecretBase `json:"password"` PrivateKey SecretBase `json:"privateKey"` PrivateKeyPassphrase SecretBase `json:"privateKeyPassphrase"` @@ -33,6 +34,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err ClientId *string `json:"clientId,omitempty"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Scope *string `json:"scope,omitempty"` TenantId *string `json:"tenantId,omitempty"` User *string `json:"user,omitempty"` @@ -47,6 +49,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err s.ClientId = decoded.ClientId s.Database = decoded.Database s.EncryptedCredential = decoded.EncryptedCredential + s.Host = decoded.Host s.Scope = decoded.Scope s.TenantId = decoded.TenantId s.User = decoded.User diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go index d78ad7eff5d..5d7c9ab96bf 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_postgresqlv2linkedservicetypeproperties.go @@ -4,6 +4,7 @@ package linkedservices // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PostgreSqlV2LinkedServiceTypeProperties struct { + AuthenticationType string `json:"authenticationType"` CommandTimeout *int64 `json:"commandTimeout,omitempty"` ConnectionTimeout *int64 `json:"connectionTimeout,omitempty"` Database string `json:"database"` diff --git a/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go b/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go index 3933e98ec9a..e0f50bd2152 100644 --- a/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go +++ b/resource-manager/datafactory/2018-06-01/linkedservices/model_snowflakelinkedv2servicetypeproperties.go @@ -15,6 +15,7 @@ type SnowflakeLinkedV2ServiceTypeProperties struct { ClientSecret SecretBase `json:"clientSecret"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Password SecretBase `json:"password"` PrivateKey SecretBase `json:"privateKey"` PrivateKeyPassphrase SecretBase `json:"privateKeyPassphrase"` @@ -33,6 +34,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err ClientId *string `json:"clientId,omitempty"` Database string `json:"database"` EncryptedCredential *string `json:"encryptedCredential,omitempty"` + Host *string `json:"host,omitempty"` Scope *string `json:"scope,omitempty"` TenantId *string `json:"tenantId,omitempty"` User *string `json:"user,omitempty"` @@ -47,6 +49,7 @@ func (s *SnowflakeLinkedV2ServiceTypeProperties) UnmarshalJSON(bytes []byte) err s.ClientId = decoded.ClientId s.Database = decoded.Database s.EncryptedCredential = decoded.EncryptedCredential + s.Host = decoded.Host s.Scope = decoded.Scope s.TenantId = decoded.TenantId s.User = decoded.User diff --git a/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go b/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go index a51c87a91ab..696635d8308 100644 --- a/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go +++ b/resource-manager/datafactory/2018-06-01/pipelines/model_salesforcev2source.go @@ -13,6 +13,7 @@ var _ CopySource = SalesforceV2Source{} type SalesforceV2Source struct { AdditionalColumns *interface{} `json:"additionalColumns,omitempty"` IncludeDeletedObjects *bool `json:"includeDeletedObjects,omitempty"` + PageSize *int64 `json:"pageSize,omitempty"` Query *string `json:"query,omitempty"` QueryTimeout *string `json:"queryTimeout,omitempty"` SOQLQuery *string `json:"SOQLQuery,omitempty"` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md new file mode 100644 index 00000000000..798cd7a9f29 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles` Documentation + +The `assetendpointprofiles` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles" +``` + + +### Client Initialization + +```go +client := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetEndpointProfilesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfile{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Delete` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Get` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +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: `AssetEndpointProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Update` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfileUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go new file mode 100644 index 00000000000..099374a758a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/client.go @@ -0,0 +1,26 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient struct { + Client *resourcemanager.Client +} + +func NewAssetEndpointProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetEndpointProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assetendpointprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetEndpointProfilesClient: %+v", err) + } + + return &AssetEndpointProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go new file mode 100644 index 00000000000..3d109615ec0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/constants.go @@ -0,0 +1,104 @@ +package assetendpointprofiles + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous" + AuthenticationMethodCertificate AuthenticationMethod = "Certificate" + AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAnonymous), + string(AuthenticationMethodCertificate), + string(AuthenticationMethodUsernamePassword), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "anonymous": AuthenticationMethodAnonymous, + "certificate": AuthenticationMethodCertificate, + "usernamepassword": AuthenticationMethodUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go new file mode 100644 index 00000000000..e372455f8ff --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile.go @@ -0,0 +1,130 @@ +package assetendpointprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AssetEndpointProfileId{}) +} + +var _ resourceids.ResourceId = &AssetEndpointProfileId{} + +// AssetEndpointProfileId is a struct representing the Resource ID for a Asset Endpoint Profile +type AssetEndpointProfileId struct { + SubscriptionId string + ResourceGroupName string + AssetEndpointProfileName string +} + +// NewAssetEndpointProfileID returns a new AssetEndpointProfileId struct +func NewAssetEndpointProfileID(subscriptionId string, resourceGroupName string, assetEndpointProfileName string) AssetEndpointProfileId { + return AssetEndpointProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetEndpointProfileName: assetEndpointProfileName, + } +} + +// ParseAssetEndpointProfileID parses 'input' into a AssetEndpointProfileId +func ParseAssetEndpointProfileID(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetEndpointProfileIDInsensitively parses 'input' case-insensitively into a AssetEndpointProfileId +// note: this method should only be used for API response data and not user input +func ParseAssetEndpointProfileIDInsensitively(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetEndpointProfileId) 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.AssetEndpointProfileName, ok = input.Parsed["assetEndpointProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetEndpointProfileName", input) + } + + return nil +} + +// ValidateAssetEndpointProfileID checks that 'input' can be parsed as a Asset Endpoint Profile ID +func ValidateAssetEndpointProfileID(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 := ParseAssetEndpointProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset Endpoint Profile ID +func (id AssetEndpointProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetEndpointProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssetEndpointProfiles", "assetEndpointProfiles", "assetEndpointProfiles"), + resourceids.UserSpecifiedSegment("assetEndpointProfileName", "assetEndpointProfileName"), + } +} + +// String returns a human-readable description of this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Endpoint Profile Name: %q", id.AssetEndpointProfileName), + } + return fmt.Sprintf("Asset Endpoint Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go new file mode 100644 index 00000000000..59928f613b1 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/id_assetendpointprofile_test.go @@ -0,0 +1,282 @@ +package assetendpointprofiles + +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 = &AssetEndpointProfileId{} + +func TestNewAssetEndpointProfileID(t *testing.T) { + id := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + + 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.AssetEndpointProfileName != "assetEndpointProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetEndpointProfileName'", id.AssetEndpointProfileName, "assetEndpointProfileName") + } +} + +func TestFormatAssetEndpointProfileID(t *testing.T) { + actual := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetEndpointProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileID(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.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestParseAssetEndpointProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetEndpointProfileName: "aSsEtEnDpOiNtPrOfIlEnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileIDInsensitively(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.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestSegmentsForAssetEndpointProfileId(t *testing.T) { + segments := AssetEndpointProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetEndpointProfileId 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/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go new file mode 100644 index 00000000000..1dd13be906d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_createorreplace.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AssetEndpointProfile +} + +// CreateOrReplace ... +func (c AssetEndpointProfilesClient) CreateOrReplace(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetEndpointProfilesClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go new file mode 100644 index 00000000000..b24134a6027 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_delete.go @@ -0,0 +1,70 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient) Delete(ctx context.Context, id AssetEndpointProfileId) (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 AssetEndpointProfilesClient) DeleteThenPoll(ctx context.Context, id AssetEndpointProfileId) 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/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go new file mode 100644 index 00000000000..2a5f882cc3c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_get.go @@ -0,0 +1,53 @@ +package assetendpointprofiles + +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 *AssetEndpointProfile +} + +// Get ... +func (c AssetEndpointProfilesClient) Get(ctx context.Context, id AssetEndpointProfileId) (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 + } + + var model AssetEndpointProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..dba6b469adb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AssetEndpointProfile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AssetEndpointProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AssetEndpointProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetEndpointProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go new file mode 100644 index 00000000000..13b32409dc6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AssetEndpointProfile +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetEndpointProfilesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetEndpointProfilesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetEndpointProfileOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go new file mode 100644 index 00000000000..2af77249a09 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/method_update.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 + Model *AssetEndpointProfile +} + +// Update ... +func (c AssetEndpointProfilesClient) Update(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) (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 AssetEndpointProfilesClient) UpdateThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) 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/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go new file mode 100644 index 00000000000..8968e9fd724 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofile.go @@ -0,0 +1,19 @@ +package assetendpointprofiles + +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 AssetEndpointProfile struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetEndpointProfileProperties `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/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go new file mode 100644 index 00000000000..f4ca0e2ffc3 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileproperties.go @@ -0,0 +1,15 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *Authentication `json:"authentication,omitempty"` + DiscoveredAssetEndpointProfileRef *string `json:"discoveredAssetEndpointProfileRef,omitempty"` + EndpointProfileType string `json:"endpointProfileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *AssetEndpointProfileStatus `json:"status,omitempty"` + TargetAddress string `json:"targetAddress"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go new file mode 100644 index 00000000000..b9352a519b4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatus.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatus struct { + Errors *[]AssetEndpointProfileStatusError `json:"errors,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go new file mode 100644 index 00000000000..43ef3ee7188 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofilestatuserror.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go new file mode 100644 index 00000000000..0bfe7125133 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdate struct { + Properties *AssetEndpointProfileUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go new file mode 100644 index 00000000000..a05bb6eefb0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_assetendpointprofileupdateproperties.go @@ -0,0 +1,11 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdateProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *AuthenticationUpdate `json:"authentication,omitempty"` + EndpointProfileType *string `json:"endpointProfileType,omitempty"` + TargetAddress *string `json:"targetAddress,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go new file mode 100644 index 00000000000..67a43dfa2cd --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authentication.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Authentication struct { + Method AuthenticationMethod `json:"method"` + UsernamePasswordCredentials *UsernamePasswordCredentials `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509Credentials `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go new file mode 100644 index 00000000000..b0f0d7ef0f6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_authenticationupdate.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationUpdate struct { + Method *AuthenticationMethod `json:"method,omitempty"` + UsernamePasswordCredentials *UsernamePasswordCredentialsUpdate `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509CredentialsUpdate `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go new file mode 100644 index 00000000000..0fb2e13abac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go new file mode 100644 index 00000000000..b108ab27db6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentials.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentials struct { + PasswordSecretName string `json:"passwordSecretName"` + UsernameSecretName string `json:"usernameSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go new file mode 100644 index 00000000000..cf842482565 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentialsUpdate struct { + PasswordSecretName *string `json:"passwordSecretName,omitempty"` + UsernameSecretName *string `json:"usernameSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go new file mode 100644 index 00000000000..5b3cd78827c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentials.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509Credentials struct { + CertificateSecretName string `json:"certificateSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go new file mode 100644 index 00000000000..920bb4fb03b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/model_x509credentialsupdate.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509CredentialsUpdate struct { + CertificateSecretName *string `json:"certificateSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go new file mode 100644 index 00000000000..fb0fb8f73eb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/predicates.go @@ -0,0 +1,32 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetEndpointProfileOperationPredicate) Matches(input AssetEndpointProfile) 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/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go new file mode 100644 index 00000000000..2e71fa681b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles/version.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assetendpointprofiles/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md b/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md new file mode 100644 index 00000000000..1a6d4c6a145 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assets` Documentation + +The `assets` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assets" +``` + + +### Client Initialization + +```go +client := assets.NewAssetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.Asset{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Delete` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Get` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +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: `AssetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.Update` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.AssetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go new file mode 100644 index 00000000000..a72f6492047 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/client.go @@ -0,0 +1,26 @@ +package assets + +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 AssetsClient struct { + Client *resourcemanager.Client +} + +func NewAssetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetsClient: %+v", err) + } + + return &AssetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go new file mode 100644 index 00000000000..ac288b94567 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/constants.go @@ -0,0 +1,192 @@ +package assets + +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 DataPointObservabilityMode string + +const ( + DataPointObservabilityModeCounter DataPointObservabilityMode = "Counter" + DataPointObservabilityModeGauge DataPointObservabilityMode = "Gauge" + DataPointObservabilityModeHistogram DataPointObservabilityMode = "Histogram" + DataPointObservabilityModeLog DataPointObservabilityMode = "Log" + DataPointObservabilityModeNone DataPointObservabilityMode = "None" +) + +func PossibleValuesForDataPointObservabilityMode() []string { + return []string{ + string(DataPointObservabilityModeCounter), + string(DataPointObservabilityModeGauge), + string(DataPointObservabilityModeHistogram), + string(DataPointObservabilityModeLog), + string(DataPointObservabilityModeNone), + } +} + +func (s *DataPointObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataPointObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataPointObservabilityMode(input string) (*DataPointObservabilityMode, error) { + vals := map[string]DataPointObservabilityMode{ + "counter": DataPointObservabilityModeCounter, + "gauge": DataPointObservabilityModeGauge, + "histogram": DataPointObservabilityModeHistogram, + "log": DataPointObservabilityModeLog, + "none": DataPointObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataPointObservabilityMode(input) + return &out, nil +} + +type EventObservabilityMode string + +const ( + EventObservabilityModeLog EventObservabilityMode = "Log" + EventObservabilityModeNone EventObservabilityMode = "None" +) + +func PossibleValuesForEventObservabilityMode() []string { + return []string{ + string(EventObservabilityModeLog), + string(EventObservabilityModeNone), + } +} + +func (s *EventObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventObservabilityMode(input string) (*EventObservabilityMode, error) { + vals := map[string]EventObservabilityMode{ + "log": EventObservabilityModeLog, + "none": EventObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventObservabilityMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type TopicRetainType string + +const ( + TopicRetainTypeKeep TopicRetainType = "Keep" + TopicRetainTypeNever TopicRetainType = "Never" +) + +func PossibleValuesForTopicRetainType() []string { + return []string{ + string(TopicRetainTypeKeep), + string(TopicRetainTypeNever), + } +} + +func (s *TopicRetainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTopicRetainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTopicRetainType(input string) (*TopicRetainType, error) { + vals := map[string]TopicRetainType{ + "keep": TopicRetainTypeKeep, + "never": TopicRetainTypeNever, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TopicRetainType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go new file mode 100644 index 00000000000..bb7b45f0c33 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset.go @@ -0,0 +1,130 @@ +package assets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AssetId{}) +} + +var _ resourceids.ResourceId = &AssetId{} + +// AssetId is a struct representing the Resource ID for a Asset +type AssetId struct { + SubscriptionId string + ResourceGroupName string + AssetName string +} + +// NewAssetID returns a new AssetId struct +func NewAssetID(subscriptionId string, resourceGroupName string, assetName string) AssetId { + return AssetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetName: assetName, + } +} + +// ParseAssetID parses 'input' into a AssetId +func ParseAssetID(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetIDInsensitively parses 'input' case-insensitively into a AssetId +// note: this method should only be used for API response data and not user input +func ParseAssetIDInsensitively(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetId) 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.AssetName, ok = input.Parsed["assetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetName", input) + } + + return nil +} + +// ValidateAssetID checks that 'input' can be parsed as a Asset ID +func ValidateAssetID(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 := ParseAssetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset ID +func (id AssetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset ID +func (id AssetId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssets", "assets", "assets"), + resourceids.UserSpecifiedSegment("assetName", "assetName"), + } +} + +// String returns a human-readable description of this Asset ID +func (id AssetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Name: %q", id.AssetName), + } + return fmt.Sprintf("Asset (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go new file mode 100644 index 00000000000..533809babad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/id_asset_test.go @@ -0,0 +1,282 @@ +package assets + +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 = &AssetId{} + +func TestNewAssetID(t *testing.T) { + id := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + + 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.AssetName != "assetName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetName'", id.AssetName, "assetName") + } +} + +func TestFormatAssetID(t *testing.T) { + actual := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetID(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.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestParseAssetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetName: "aSsEtNaMe", + }, + }, + { + // 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.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetIDInsensitively(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.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestSegmentsForAssetId(t *testing.T) { + segments := AssetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetId 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/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go new file mode 100644 index 00000000000..b6a7798f315 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_createorreplace.go @@ -0,0 +1,75 @@ +package assets + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Asset +} + +// CreateOrReplace ... +func (c AssetsClient) CreateOrReplace(ctx context.Context, id AssetId, input Asset) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetsClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetId, input Asset) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go new file mode 100644 index 00000000000..34b6146a5f2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_delete.go @@ -0,0 +1,70 @@ +package assets + +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 AssetsClient) Delete(ctx context.Context, id AssetId) (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 AssetsClient) DeleteThenPoll(ctx context.Context, id AssetId) 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/deviceregistry/2024-09-01-preview/assets/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go new file mode 100644 index 00000000000..8eabe4d065a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_get.go @@ -0,0 +1,53 @@ +package assets + +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 *Asset +} + +// Get ... +func (c AssetsClient) Get(ctx context.Context, id AssetId) (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 + } + + var model Asset + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..c063d4d77db --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assets + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Asset +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AssetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AssetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go new file mode 100644 index 00000000000..fe6c812e1cb --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Asset +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go new file mode 100644 index 00000000000..42754ffb942 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/method_update.go @@ -0,0 +1,75 @@ +package assets + +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 + Model *Asset +} + +// Update ... +func (c AssetsClient) Update(ctx context.Context, id AssetId, input AssetUpdate) (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 AssetsClient) UpdateThenPoll(ctx context.Context, id AssetId, input AssetUpdate) 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/deviceregistry/2024-09-01-preview/assets/model_asset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go new file mode 100644 index 00000000000..24857b429fa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_asset.go @@ -0,0 +1,19 @@ +package assets + +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 Asset struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetProperties `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/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go new file mode 100644 index 00000000000..73ce93da09b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetproperties.go @@ -0,0 +1,31 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetProperties struct { + AssetEndpointProfileRef string `json:"assetEndpointProfileRef"` + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *Topic `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DiscoveredAssetRefs *[]string `json:"discoveredAssetRefs,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + ExternalAssetId *string `json:"externalAssetId,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Status *AssetStatus `json:"status,omitempty"` + Uuid *string `json:"uuid,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go new file mode 100644 index 00000000000..59adc5ba1c8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatus.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatus struct { + Datasets *[]AssetStatusDataset `json:"datasets,omitempty"` + Errors *[]AssetStatusError `json:"errors,omitempty"` + Events *[]AssetStatusEvent `json:"events,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go new file mode 100644 index 00000000000..511593b5e8f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusdataset.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusDataset struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go new file mode 100644 index 00000000000..c87108ecc08 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatuserror.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go new file mode 100644 index 00000000000..2438f4620ca --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetstatusevent.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusEvent struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go new file mode 100644 index 00000000000..6ff6aa0a80b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdate struct { + Properties *AssetUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go new file mode 100644 index 00000000000..e18024904a9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_assetupdateproperties.go @@ -0,0 +1,24 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdateProperties struct { + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *TopicUpdate `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go new file mode 100644 index 00000000000..45563621600 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_datapoint.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPoint struct { + DataPointConfiguration *string `json:"dataPointConfiguration,omitempty"` + DataSource string `json:"dataSource"` + Name string `json:"name"` + ObservabilityMode *DataPointObservabilityMode `json:"observabilityMode,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go new file mode 100644 index 00000000000..6bd5a412380 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_dataset.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dataset struct { + DataPoints *[]DataPoint `json:"dataPoints,omitempty"` + DatasetConfiguration *string `json:"datasetConfiguration,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go new file mode 100644 index 00000000000..0586fe3f37b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_event.go @@ -0,0 +1,12 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Event struct { + EventConfiguration *string `json:"eventConfiguration,omitempty"` + EventNotifier string `json:"eventNotifier"` + Name string `json:"name"` + ObservabilityMode *EventObservabilityMode `json:"observabilityMode,omitempty"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go new file mode 100644 index 00000000000..1ab2aa85f80 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assets + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go new file mode 100644 index 00000000000..098722031b9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_messageschemareference.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageSchemaReference struct { + SchemaName string `json:"schemaName"` + SchemaRegistryNamespace string `json:"schemaRegistryNamespace"` + SchemaVersion string `json:"schemaVersion"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go new file mode 100644 index 00000000000..83d513322ab --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topic.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topic struct { + Path string `json:"path"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go new file mode 100644 index 00000000000..d43a63c0c8e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/model_topicupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicUpdate struct { + Path *string `json:"path,omitempty"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go new file mode 100644 index 00000000000..cedd4ebc101 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/predicates.go @@ -0,0 +1,32 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetOperationPredicate) Matches(input Asset) 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/deviceregistry/2024-09-01-preview/assets/version.go b/resource-manager/deviceregistry/2024-09-01-preview/assets/version.go new file mode 100644 index 00000000000..fcc427b2641 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/assets/version.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assets/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md new file mode 100644 index 00000000000..0bb950ad436 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers` Documentation + +The `billingcontainers` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers" +``` + + +### Client Initialization + +```go +client := billingcontainers.NewBillingContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BillingContainersClient.Get` + +```go +ctx := context.TODO() +id := billingcontainers.NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + +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: `BillingContainersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go new file mode 100644 index 00000000000..3361e18593c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/client.go @@ -0,0 +1,26 @@ +package billingcontainers + +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 BillingContainersClient struct { + Client *resourcemanager.Client +} + +func NewBillingContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*BillingContainersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "billingcontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BillingContainersClient: %+v", err) + } + + return &BillingContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go new file mode 100644 index 00000000000..b98bfe20660 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/constants.go @@ -0,0 +1,60 @@ +package billingcontainers + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go new file mode 100644 index 00000000000..38f08f9926f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer.go @@ -0,0 +1,121 @@ +package billingcontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BillingContainerId{}) +} + +var _ resourceids.ResourceId = &BillingContainerId{} + +// BillingContainerId is a struct representing the Resource ID for a Billing Container +type BillingContainerId struct { + SubscriptionId string + BillingContainerName string +} + +// NewBillingContainerID returns a new BillingContainerId struct +func NewBillingContainerID(subscriptionId string, billingContainerName string) BillingContainerId { + return BillingContainerId{ + SubscriptionId: subscriptionId, + BillingContainerName: billingContainerName, + } +} + +// ParseBillingContainerID parses 'input' into a BillingContainerId +func ParseBillingContainerID(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBillingContainerIDInsensitively parses 'input' case-insensitively into a BillingContainerId +// note: this method should only be used for API response data and not user input +func ParseBillingContainerIDInsensitively(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BillingContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.BillingContainerName, ok = input.Parsed["billingContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "billingContainerName", input) + } + + return nil +} + +// ValidateBillingContainerID checks that 'input' can be parsed as a Billing Container ID +func ValidateBillingContainerID(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 := ParseBillingContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Billing Container ID +func (id BillingContainerId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DeviceRegistry/billingContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.BillingContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Billing Container ID +func (id BillingContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticBillingContainers", "billingContainers", "billingContainers"), + resourceids.UserSpecifiedSegment("billingContainerName", "billingContainerName"), + } +} + +// String returns a human-readable description of this Billing Container ID +func (id BillingContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Billing Container Name: %q", id.BillingContainerName), + } + return fmt.Sprintf("Billing Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go new file mode 100644 index 00000000000..3f44a3afbf9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/id_billingcontainer_test.go @@ -0,0 +1,237 @@ +package billingcontainers + +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 = &BillingContainerId{} + +func TestNewBillingContainerID(t *testing.T) { + id := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + + 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.BillingContainerName != "billingContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'BillingContainerName'", id.BillingContainerName, "billingContainerName") + } +} + +func TestFormatBillingContainerID(t *testing.T) { + actual := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBillingContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerID(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.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestParseBillingContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "bIlLiNgCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerIDInsensitively(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.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestSegmentsForBillingContainerId(t *testing.T) { + segments := BillingContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BillingContainerId 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/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go new file mode 100644 index 00000000000..564089fc3d8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_get.go @@ -0,0 +1,53 @@ +package billingcontainers + +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 *BillingContainer +} + +// Get ... +func (c BillingContainersClient) Get(ctx context.Context, id BillingContainerId) (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 + } + + var model BillingContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go new file mode 100644 index 00000000000..4f6fa1d21b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/method_listbysubscription.go @@ -0,0 +1,106 @@ +package billingcontainers + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingContainer +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingContainer +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c BillingContainersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/billingContainers", 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 *[]BillingContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c BillingContainersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, BillingContainerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BillingContainersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BillingContainerOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]BillingContainer, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go new file mode 100644 index 00000000000..d897ec1b71d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainer.go @@ -0,0 +1,17 @@ +package billingcontainers + +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 BillingContainer struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingContainerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go new file mode 100644 index 00000000000..ad3f625d084 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/model_billingcontainerproperties.go @@ -0,0 +1,8 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go new file mode 100644 index 00000000000..8e61fac37ac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/predicates.go @@ -0,0 +1,32 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p BillingContainerOperationPredicate) Matches(input BillingContainer) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/deviceregistry/2024-09-01-preview/billingcontainers/version.go b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go new file mode 100644 index 00000000000..2cee2f9ebbc --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers/version.go @@ -0,0 +1,10 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/billingcontainers/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/client.go b/resource-manager/deviceregistry/2024-09-01-preview/client.go new file mode 100644 index 00000000000..549e5299243 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/client.go @@ -0,0 +1,91 @@ +package v2024_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/deviceregistry/2024-09-01-preview/assetendpointprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assets" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/billingcontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemas" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AssetEndpointProfiles *assetendpointprofiles.AssetEndpointProfilesClient + Assets *assets.AssetsClient + BillingContainers *billingcontainers.BillingContainersClient + DiscoveredAssetEndpointProfiles *discoveredassetendpointprofiles.DiscoveredAssetEndpointProfilesClient + DiscoveredAssets *discoveredassets.DiscoveredAssetsClient + SchemaRegistries *schemaregistries.SchemaRegistriesClient + SchemaVersions *schemaversions.SchemaVersionsClient + Schemas *schemas.SchemasClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + assetEndpointProfilesClient, err := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AssetEndpointProfiles client: %+v", err) + } + configureFunc(assetEndpointProfilesClient.Client) + + assetsClient, err := assets.NewAssetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Assets client: %+v", err) + } + configureFunc(assetsClient.Client) + + billingContainersClient, err := billingcontainers.NewBillingContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BillingContainers client: %+v", err) + } + configureFunc(billingContainersClient.Client) + + discoveredAssetEndpointProfilesClient, err := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DiscoveredAssetEndpointProfiles client: %+v", err) + } + configureFunc(discoveredAssetEndpointProfilesClient.Client) + + discoveredAssetsClient, err := discoveredassets.NewDiscoveredAssetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DiscoveredAssets client: %+v", err) + } + configureFunc(discoveredAssetsClient.Client) + + schemaRegistriesClient, err := schemaregistries.NewSchemaRegistriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SchemaRegistries client: %+v", err) + } + configureFunc(schemaRegistriesClient.Client) + + schemaVersionsClient, err := schemaversions.NewSchemaVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SchemaVersions client: %+v", err) + } + configureFunc(schemaVersionsClient.Client) + + schemasClient, err := schemas.NewSchemasClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Schemas client: %+v", err) + } + configureFunc(schemasClient.Client) + + return &Client{ + AssetEndpointProfiles: assetEndpointProfilesClient, + Assets: assetsClient, + BillingContainers: billingContainersClient, + DiscoveredAssetEndpointProfiles: discoveredAssetEndpointProfilesClient, + DiscoveredAssets: discoveredAssetsClient, + SchemaRegistries: schemaRegistriesClient, + SchemaVersions: schemaVersionsClient, + Schemas: schemasClient, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md new file mode 100644 index 00000000000..99ad1ff8944 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles` Documentation + +The `discoveredassetendpointprofiles` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles" +``` + + +### Client Initialization + +```go +client := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +payload := discoveredassetendpointprofiles.DiscoveredAssetEndpointProfile{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Delete` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Get` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +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: `DiscoveredAssetEndpointProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetEndpointProfilesClient.Update` + +```go +ctx := context.TODO() +id := discoveredassetendpointprofiles.NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + +payload := discoveredassetendpointprofiles.DiscoveredAssetEndpointProfileUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go new file mode 100644 index 00000000000..9f4c2c24574 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/client.go @@ -0,0 +1,26 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfilesClient struct { + Client *resourcemanager.Client +} + +func NewDiscoveredAssetEndpointProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*DiscoveredAssetEndpointProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "discoveredassetendpointprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiscoveredAssetEndpointProfilesClient: %+v", err) + } + + return &DiscoveredAssetEndpointProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go new file mode 100644 index 00000000000..a024f11de50 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/constants.go @@ -0,0 +1,104 @@ +package discoveredassetendpointprofiles + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous" + AuthenticationMethodCertificate AuthenticationMethod = "Certificate" + AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAnonymous), + string(AuthenticationMethodCertificate), + string(AuthenticationMethodUsernamePassword), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "anonymous": AuthenticationMethodAnonymous, + "certificate": AuthenticationMethodCertificate, + "usernamepassword": AuthenticationMethodUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go new file mode 100644 index 00000000000..9efa4cfcdba --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile.go @@ -0,0 +1,130 @@ +package discoveredassetendpointprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DiscoveredAssetEndpointProfileId{}) +} + +var _ resourceids.ResourceId = &DiscoveredAssetEndpointProfileId{} + +// DiscoveredAssetEndpointProfileId is a struct representing the Resource ID for a Discovered Asset Endpoint Profile +type DiscoveredAssetEndpointProfileId struct { + SubscriptionId string + ResourceGroupName string + DiscoveredAssetEndpointProfileName string +} + +// NewDiscoveredAssetEndpointProfileID returns a new DiscoveredAssetEndpointProfileId struct +func NewDiscoveredAssetEndpointProfileID(subscriptionId string, resourceGroupName string, discoveredAssetEndpointProfileName string) DiscoveredAssetEndpointProfileId { + return DiscoveredAssetEndpointProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DiscoveredAssetEndpointProfileName: discoveredAssetEndpointProfileName, + } +} + +// ParseDiscoveredAssetEndpointProfileID parses 'input' into a DiscoveredAssetEndpointProfileId +func ParseDiscoveredAssetEndpointProfileID(input string) (*DiscoveredAssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetEndpointProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiscoveredAssetEndpointProfileIDInsensitively parses 'input' case-insensitively into a DiscoveredAssetEndpointProfileId +// note: this method should only be used for API response data and not user input +func ParseDiscoveredAssetEndpointProfileIDInsensitively(input string) (*DiscoveredAssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetEndpointProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiscoveredAssetEndpointProfileId) 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.DiscoveredAssetEndpointProfileName, ok = input.Parsed["discoveredAssetEndpointProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "discoveredAssetEndpointProfileName", input) + } + + return nil +} + +// ValidateDiscoveredAssetEndpointProfileID checks that 'input' can be parsed as a Discovered Asset Endpoint Profile ID +func ValidateDiscoveredAssetEndpointProfileID(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 := ParseDiscoveredAssetEndpointProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DiscoveredAssetEndpointProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticDiscoveredAssetEndpointProfiles", "discoveredAssetEndpointProfiles", "discoveredAssetEndpointProfiles"), + resourceids.UserSpecifiedSegment("discoveredAssetEndpointProfileName", "discoveredAssetEndpointProfileName"), + } +} + +// String returns a human-readable description of this Discovered Asset Endpoint Profile ID +func (id DiscoveredAssetEndpointProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Discovered Asset Endpoint Profile Name: %q", id.DiscoveredAssetEndpointProfileName), + } + return fmt.Sprintf("Discovered Asset Endpoint Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go new file mode 100644 index 00000000000..8d95d40c742 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/id_discoveredassetendpointprofile_test.go @@ -0,0 +1,282 @@ +package discoveredassetendpointprofiles + +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 = &DiscoveredAssetEndpointProfileId{} + +func TestNewDiscoveredAssetEndpointProfileID(t *testing.T) { + id := NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName") + + 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.DiscoveredAssetEndpointProfileName != "discoveredAssetEndpointProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'DiscoveredAssetEndpointProfileName'", id.DiscoveredAssetEndpointProfileName, "discoveredAssetEndpointProfileName") + } +} + +func TestFormatDiscoveredAssetEndpointProfileID(t *testing.T) { + actual := NewDiscoveredAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetEndpointProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiscoveredAssetEndpointProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetEndpointProfileName: "discoveredAssetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetEndpointProfileID(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.DiscoveredAssetEndpointProfileName != v.Expected.DiscoveredAssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetEndpointProfileName", v.Expected.DiscoveredAssetEndpointProfileName, actual.DiscoveredAssetEndpointProfileName) + } + + } +} + +func TestParseDiscoveredAssetEndpointProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetEndpointProfileName: "discoveredAssetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles/discoveredAssetEndpointProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE", + Expected: &DiscoveredAssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DiscoveredAssetEndpointProfileName: "dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEs/dIsCoVeReDaSsEtEnDpOiNtPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetEndpointProfileIDInsensitively(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.DiscoveredAssetEndpointProfileName != v.Expected.DiscoveredAssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetEndpointProfileName", v.Expected.DiscoveredAssetEndpointProfileName, actual.DiscoveredAssetEndpointProfileName) + } + + } +} + +func TestSegmentsForDiscoveredAssetEndpointProfileId(t *testing.T) { + segments := DiscoveredAssetEndpointProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiscoveredAssetEndpointProfileId 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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go new file mode 100644 index 00000000000..5aa061769a4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_createorreplace.go @@ -0,0 +1,75 @@ +package discoveredassetendpointprofiles + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAssetEndpointProfile +} + +// CreateOrReplace ... +func (c DiscoveredAssetEndpointProfilesClient) CreateOrReplace(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfile) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c DiscoveredAssetEndpointProfilesClient) CreateOrReplaceThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfile) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go new file mode 100644 index 00000000000..e4d5a59d350 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_delete.go @@ -0,0 +1,70 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfilesClient) Delete(ctx context.Context, id DiscoveredAssetEndpointProfileId) (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 DiscoveredAssetEndpointProfilesClient) DeleteThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId) 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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go new file mode 100644 index 00000000000..3a2e3e19817 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_get.go @@ -0,0 +1,53 @@ +package discoveredassetendpointprofiles + +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 *DiscoveredAssetEndpointProfile +} + +// Get ... +func (c DiscoveredAssetEndpointProfilesClient) Get(ctx context.Context, id DiscoveredAssetEndpointProfileId) (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 + } + + var model DiscoveredAssetEndpointProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ef9d06d005a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package discoveredassetendpointprofiles + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAssetEndpointProfile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAssetEndpointProfile +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c DiscoveredAssetEndpointProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", 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 *[]DiscoveredAssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DiscoveredAssetEndpointProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DiscoveredAssetEndpointProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetEndpointProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DiscoveredAssetEndpointProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DiscoveredAssetEndpointProfile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go new file mode 100644 index 00000000000..d371020d2d0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_listbysubscription.go @@ -0,0 +1,106 @@ +package discoveredassetendpointprofiles + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAssetEndpointProfile +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAssetEndpointProfile +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssetEndpointProfiles", 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 *[]DiscoveredAssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DiscoveredAssetEndpointProfileOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetEndpointProfilesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DiscoveredAssetEndpointProfileOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DiscoveredAssetEndpointProfile, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go new file mode 100644 index 00000000000..cf5a777ed45 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/method_update.go @@ -0,0 +1,75 @@ +package discoveredassetendpointprofiles + +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 + Model *DiscoveredAssetEndpointProfile +} + +// Update ... +func (c DiscoveredAssetEndpointProfilesClient) Update(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfileUpdate) (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 DiscoveredAssetEndpointProfilesClient) UpdateThenPoll(ctx context.Context, id DiscoveredAssetEndpointProfileId, input DiscoveredAssetEndpointProfileUpdate) 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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go new file mode 100644 index 00000000000..1fe91b9b8a0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofile.go @@ -0,0 +1,19 @@ +package discoveredassetendpointprofiles + +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 DiscoveredAssetEndpointProfile struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DiscoveredAssetEndpointProfileProperties `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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go new file mode 100644 index 00000000000..1b5dcc4b19f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileproperties.go @@ -0,0 +1,14 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + DiscoveryId string `json:"discoveryId"` + EndpointProfileType string `json:"endpointProfileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SupportedAuthenticationMethods *[]AuthenticationMethod `json:"supportedAuthenticationMethods,omitempty"` + TargetAddress string `json:"targetAddress"` + Version int64 `json:"version"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go new file mode 100644 index 00000000000..8ed369c6eab --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdate.go @@ -0,0 +1,9 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileUpdate struct { + Properties *DiscoveredAssetEndpointProfileUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go new file mode 100644 index 00000000000..93a56715a2a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_discoveredassetendpointprofileupdateproperties.go @@ -0,0 +1,13 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileUpdateProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + DiscoveryId *string `json:"discoveryId,omitempty"` + EndpointProfileType *string `json:"endpointProfileType,omitempty"` + SupportedAuthenticationMethods *[]AuthenticationMethod `json:"supportedAuthenticationMethods,omitempty"` + TargetAddress *string `json:"targetAddress,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go new file mode 100644 index 00000000000..35b60166210 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/model_extendedlocation.go @@ -0,0 +1,9 @@ +package discoveredassetendpointprofiles + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go new file mode 100644 index 00000000000..db898423dae --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/predicates.go @@ -0,0 +1,32 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetEndpointProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DiscoveredAssetEndpointProfileOperationPredicate) Matches(input DiscoveredAssetEndpointProfile) 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/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go new file mode 100644 index 00000000000..1fc73986e73 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassetendpointprofiles/version.go @@ -0,0 +1,10 @@ +package discoveredassetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/discoveredassetendpointprofiles/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md new file mode 100644 index 00000000000..e863d64112b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets` Documentation + +The `discoveredassets` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets" +``` + + +### Client Initialization + +```go +client := discoveredassets.NewDiscoveredAssetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiscoveredAssetsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +payload := discoveredassets.DiscoveredAsset{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Delete` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Get` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +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: `DiscoveredAssetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiscoveredAssetsClient.Update` + +```go +ctx := context.TODO() +id := discoveredassets.NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + +payload := discoveredassets.DiscoveredAssetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go new file mode 100644 index 00000000000..452f44d72e8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/client.go @@ -0,0 +1,26 @@ +package discoveredassets + +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 DiscoveredAssetsClient struct { + Client *resourcemanager.Client +} + +func NewDiscoveredAssetsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiscoveredAssetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "discoveredassets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiscoveredAssetsClient: %+v", err) + } + + return &DiscoveredAssetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go new file mode 100644 index 00000000000..29ea51464da --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/constants.go @@ -0,0 +1,101 @@ +package discoveredassets + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type TopicRetainType string + +const ( + TopicRetainTypeKeep TopicRetainType = "Keep" + TopicRetainTypeNever TopicRetainType = "Never" +) + +func PossibleValuesForTopicRetainType() []string { + return []string{ + string(TopicRetainTypeKeep), + string(TopicRetainTypeNever), + } +} + +func (s *TopicRetainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTopicRetainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTopicRetainType(input string) (*TopicRetainType, error) { + vals := map[string]TopicRetainType{ + "keep": TopicRetainTypeKeep, + "never": TopicRetainTypeNever, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TopicRetainType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go new file mode 100644 index 00000000000..330575dca73 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset.go @@ -0,0 +1,130 @@ +package discoveredassets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DiscoveredAssetId{}) +} + +var _ resourceids.ResourceId = &DiscoveredAssetId{} + +// DiscoveredAssetId is a struct representing the Resource ID for a Discovered Asset +type DiscoveredAssetId struct { + SubscriptionId string + ResourceGroupName string + DiscoveredAssetName string +} + +// NewDiscoveredAssetID returns a new DiscoveredAssetId struct +func NewDiscoveredAssetID(subscriptionId string, resourceGroupName string, discoveredAssetName string) DiscoveredAssetId { + return DiscoveredAssetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DiscoveredAssetName: discoveredAssetName, + } +} + +// ParseDiscoveredAssetID parses 'input' into a DiscoveredAssetId +func ParseDiscoveredAssetID(input string) (*DiscoveredAssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiscoveredAssetIDInsensitively parses 'input' case-insensitively into a DiscoveredAssetId +// note: this method should only be used for API response data and not user input +func ParseDiscoveredAssetIDInsensitively(input string) (*DiscoveredAssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiscoveredAssetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiscoveredAssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiscoveredAssetId) 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.DiscoveredAssetName, ok = input.Parsed["discoveredAssetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "discoveredAssetName", input) + } + + return nil +} + +// ValidateDiscoveredAssetID checks that 'input' can be parsed as a Discovered Asset ID +func ValidateDiscoveredAssetID(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 := ParseDiscoveredAssetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Discovered Asset ID +func (id DiscoveredAssetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/discoveredAssets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DiscoveredAssetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Discovered Asset ID +func (id DiscoveredAssetId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticDiscoveredAssets", "discoveredAssets", "discoveredAssets"), + resourceids.UserSpecifiedSegment("discoveredAssetName", "discoveredAssetName"), + } +} + +// String returns a human-readable description of this Discovered Asset ID +func (id DiscoveredAssetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Discovered Asset Name: %q", id.DiscoveredAssetName), + } + return fmt.Sprintf("Discovered Asset (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go new file mode 100644 index 00000000000..7c935a1f3b5 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/id_discoveredasset_test.go @@ -0,0 +1,282 @@ +package discoveredassets + +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 = &DiscoveredAssetId{} + +func TestNewDiscoveredAssetID(t *testing.T) { + id := NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName") + + 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.DiscoveredAssetName != "discoveredAssetName" { + t.Fatalf("Expected %q but got %q for Segment 'DiscoveredAssetName'", id.DiscoveredAssetName, "discoveredAssetName") + } +} + +func TestFormatDiscoveredAssetID(t *testing.T) { + actual := NewDiscoveredAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "discoveredAssetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiscoveredAssetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetName: "discoveredAssetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetID(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.DiscoveredAssetName != v.Expected.DiscoveredAssetName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetName", v.Expected.DiscoveredAssetName, actual.DiscoveredAssetName) + } + + } +} + +func TestParseDiscoveredAssetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiscoveredAssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DiscoveredAssetName: "discoveredAssetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/discoveredAssets/discoveredAssetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS/dIsCoVeReDaSsEtNaMe", + Expected: &DiscoveredAssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DiscoveredAssetName: "dIsCoVeReDaSsEtNaMe", + }, + }, + { + // 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.dEvIcErEgIsTrY/dIsCoVeReDaSsEtS/dIsCoVeReDaSsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiscoveredAssetIDInsensitively(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.DiscoveredAssetName != v.Expected.DiscoveredAssetName { + t.Fatalf("Expected %q but got %q for DiscoveredAssetName", v.Expected.DiscoveredAssetName, actual.DiscoveredAssetName) + } + + } +} + +func TestSegmentsForDiscoveredAssetId(t *testing.T) { + segments := DiscoveredAssetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiscoveredAssetId 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/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go new file mode 100644 index 00000000000..9d7294be792 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_createorreplace.go @@ -0,0 +1,75 @@ +package discoveredassets + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiscoveredAsset +} + +// CreateOrReplace ... +func (c DiscoveredAssetsClient) CreateOrReplace(ctx context.Context, id DiscoveredAssetId, input DiscoveredAsset) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c DiscoveredAssetsClient) CreateOrReplaceThenPoll(ctx context.Context, id DiscoveredAssetId, input DiscoveredAsset) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go new file mode 100644 index 00000000000..5b61cbae495 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_delete.go @@ -0,0 +1,70 @@ +package discoveredassets + +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 DiscoveredAssetsClient) Delete(ctx context.Context, id DiscoveredAssetId) (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 DiscoveredAssetsClient) DeleteThenPoll(ctx context.Context, id DiscoveredAssetId) 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/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go new file mode 100644 index 00000000000..967affec5ad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_get.go @@ -0,0 +1,53 @@ +package discoveredassets + +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 *DiscoveredAsset +} + +// Get ... +func (c DiscoveredAssetsClient) Get(ctx context.Context, id DiscoveredAssetId) (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 + } + + var model DiscoveredAsset + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..4c50cb450af --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package discoveredassets + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAsset +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAsset +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c DiscoveredAssetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssets", 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 *[]DiscoveredAsset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DiscoveredAssetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DiscoveredAssetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DiscoveredAssetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DiscoveredAsset, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go new file mode 100644 index 00000000000..467fe3e3b7e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package discoveredassets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiscoveredAsset +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiscoveredAsset +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c DiscoveredAssetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/discoveredAssets", 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 *[]DiscoveredAsset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DiscoveredAssetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DiscoveredAssetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiscoveredAssetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DiscoveredAssetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DiscoveredAsset, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go new file mode 100644 index 00000000000..34dafc0b83a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/method_update.go @@ -0,0 +1,75 @@ +package discoveredassets + +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 + Model *DiscoveredAsset +} + +// Update ... +func (c DiscoveredAssetsClient) Update(ctx context.Context, id DiscoveredAssetId, input DiscoveredAssetUpdate) (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 DiscoveredAssetsClient) UpdateThenPoll(ctx context.Context, id DiscoveredAssetId, input DiscoveredAssetUpdate) 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/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go new file mode 100644 index 00000000000..c2115751f9a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredasset.go @@ -0,0 +1,19 @@ +package discoveredassets + +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 DiscoveredAsset struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DiscoveredAssetProperties `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/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go new file mode 100644 index 00000000000..5dd4c43534f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetproperties.go @@ -0,0 +1,24 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetProperties struct { + AssetEndpointProfileRef string `json:"assetEndpointProfileRef"` + Datasets *[]DiscoveredDataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *Topic `json:"defaultTopic,omitempty"` + DiscoveryId string `json:"discoveryId"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Events *[]DiscoveredEvent `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Version int64 `json:"version"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go new file mode 100644 index 00000000000..cde7515625f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdate.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetUpdate struct { + Properties *DiscoveredAssetUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go new file mode 100644 index 00000000000..f1730c339e2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredassetupdateproperties.go @@ -0,0 +1,22 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetUpdateProperties struct { + Datasets *[]DiscoveredDataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *TopicUpdate `json:"defaultTopic,omitempty"` + DiscoveryId *string `json:"discoveryId,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Events *[]DiscoveredEvent `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go new file mode 100644 index 00000000000..7f85a50a982 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddatapoint.go @@ -0,0 +1,29 @@ +package discoveredassets + +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 DiscoveredDataPoint struct { + DataPointConfiguration *string `json:"dataPointConfiguration,omitempty"` + DataSource string `json:"dataSource"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + Name string `json:"name"` +} + +func (o *DiscoveredDataPoint) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiscoveredDataPoint) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go new file mode 100644 index 00000000000..3fa178e5f19 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discovereddataset.go @@ -0,0 +1,11 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredDataset struct { + DataPoints *[]DiscoveredDataPoint `json:"dataPoints,omitempty"` + DatasetConfiguration *string `json:"datasetConfiguration,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go new file mode 100644 index 00000000000..b2f4650a037 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_discoveredevent.go @@ -0,0 +1,30 @@ +package discoveredassets + +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 DiscoveredEvent struct { + EventConfiguration *string `json:"eventConfiguration,omitempty"` + EventNotifier string `json:"eventNotifier"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} + +func (o *DiscoveredEvent) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiscoveredEvent) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go new file mode 100644 index 00000000000..819a06a5083 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_extendedlocation.go @@ -0,0 +1,9 @@ +package discoveredassets + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go new file mode 100644 index 00000000000..66f0a946718 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topic.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topic struct { + Path string `json:"path"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go new file mode 100644 index 00000000000..c5fc8fab903 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/model_topicupdate.go @@ -0,0 +1,9 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicUpdate struct { + Path *string `json:"path,omitempty"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go new file mode 100644 index 00000000000..dd1b7e7a45a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/predicates.go @@ -0,0 +1,32 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoveredAssetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DiscoveredAssetOperationPredicate) Matches(input DiscoveredAsset) 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/deviceregistry/2024-09-01-preview/discoveredassets/version.go b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go new file mode 100644 index 00000000000..02957409f9e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/discoveredassets/version.go @@ -0,0 +1,10 @@ +package discoveredassets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/discoveredassets/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md new file mode 100644 index 00000000000..8db970cf90e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries` Documentation + +The `schemaregistries` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries" +``` + + +### Client Initialization + +```go +client := schemaregistries.NewSchemaRegistriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemaRegistriesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +payload := schemaregistries.SchemaRegistry{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SchemaRegistriesClient.Delete` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SchemaRegistriesClient.Get` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +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: `SchemaRegistriesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SchemaRegistriesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SchemaRegistriesClient.Update` + +```go +ctx := context.TODO() +id := schemaregistries.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +payload := schemaregistries.SchemaRegistryUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go new file mode 100644 index 00000000000..26d52a1bee7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/client.go @@ -0,0 +1,26 @@ +package schemaregistries + +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 SchemaRegistriesClient struct { + Client *resourcemanager.Client +} + +func NewSchemaRegistriesClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemaRegistriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemaregistries", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaRegistriesClient: %+v", err) + } + + return &SchemaRegistriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go new file mode 100644 index 00000000000..784b072f900 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/constants.go @@ -0,0 +1,60 @@ +package schemaregistries + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go new file mode 100644 index 00000000000..257760f1220 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry.go @@ -0,0 +1,130 @@ +package schemaregistries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SchemaRegistryId{}) +} + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +// SchemaRegistryId is a struct representing the Resource ID for a Schema Registry +type SchemaRegistryId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string +} + +// NewSchemaRegistryID returns a new SchemaRegistryId struct +func NewSchemaRegistryID(subscriptionId string, resourceGroupName string, schemaRegistryName string) SchemaRegistryId { + return SchemaRegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + } +} + +// ParseSchemaRegistryID parses 'input' into a SchemaRegistryId +func ParseSchemaRegistryID(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaRegistryIDInsensitively parses 'input' case-insensitively into a SchemaRegistryId +// note: this method should only be used for API response data and not user input +func ParseSchemaRegistryIDInsensitively(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaRegistryId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + return nil +} + +// ValidateSchemaRegistryID checks that 'input' can be parsed as a Schema Registry ID +func ValidateSchemaRegistryID(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 := ParseSchemaRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Registry ID +func (id SchemaRegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Registry ID +func (id SchemaRegistryId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + } +} + +// String returns a human-readable description of this Schema Registry ID +func (id SchemaRegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + } + return fmt.Sprintf("Schema Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go new file mode 100644 index 00000000000..8513e452a58 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/id_schemaregistry_test.go @@ -0,0 +1,282 @@ +package schemaregistries + +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 = &SchemaRegistryId{} + +func TestNewSchemaRegistryID(t *testing.T) { + id := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + + 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.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } +} + +func TestFormatSchemaRegistryID(t *testing.T) { + actual := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryID(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestParseSchemaRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryIDInsensitively(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestSegmentsForSchemaRegistryId(t *testing.T) { + segments := SchemaRegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaRegistryId 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/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go new file mode 100644 index 00000000000..3e45cf4a1ad --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_createorreplace.go @@ -0,0 +1,75 @@ +package schemaregistries + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SchemaRegistry +} + +// CreateOrReplace ... +func (c SchemaRegistriesClient) CreateOrReplace(ctx context.Context, id SchemaRegistryId, input SchemaRegistry) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c SchemaRegistriesClient) CreateOrReplaceThenPoll(ctx context.Context, id SchemaRegistryId, input SchemaRegistry) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go new file mode 100644 index 00000000000..c2f7ca96918 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_delete.go @@ -0,0 +1,70 @@ +package schemaregistries + +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 SchemaRegistriesClient) Delete(ctx context.Context, id SchemaRegistryId) (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 SchemaRegistriesClient) DeleteThenPoll(ctx context.Context, id SchemaRegistryId) 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/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go new file mode 100644 index 00000000000..e11b4e0ea4f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_get.go @@ -0,0 +1,53 @@ +package schemaregistries + +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 *SchemaRegistry +} + +// Get ... +func (c SchemaRegistriesClient) Get(ctx context.Context, id SchemaRegistryId) (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 + } + + var model SchemaRegistry + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0af59292908 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package schemaregistries + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaRegistry +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaRegistry +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c SchemaRegistriesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/schemaRegistries", 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 *[]SchemaRegistry `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SchemaRegistriesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SchemaRegistryOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaRegistriesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SchemaRegistryOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SchemaRegistry, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go new file mode 100644 index 00000000000..9e8f9a647ca --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_listbysubscription.go @@ -0,0 +1,106 @@ +package schemaregistries + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaRegistry +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaRegistry +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c SchemaRegistriesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/schemaRegistries", 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 *[]SchemaRegistry `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SchemaRegistriesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SchemaRegistryOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaRegistriesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SchemaRegistryOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SchemaRegistry, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go new file mode 100644 index 00000000000..8d6b780e207 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/method_update.go @@ -0,0 +1,75 @@ +package schemaregistries + +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 + Model *SchemaRegistry +} + +// Update ... +func (c SchemaRegistriesClient) Update(ctx context.Context, id SchemaRegistryId, input SchemaRegistryUpdate) (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 SchemaRegistriesClient) UpdateThenPoll(ctx context.Context, id SchemaRegistryId, input SchemaRegistryUpdate) 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/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go new file mode 100644 index 00000000000..f52295b1227 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistry.go @@ -0,0 +1,20 @@ +package schemaregistries + +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 SchemaRegistry struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SchemaRegistryProperties `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/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go new file mode 100644 index 00000000000..5a2bda1274c --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryproperties.go @@ -0,0 +1,13 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Namespace string `json:"namespace"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + StorageAccountContainerURL string `json:"storageAccountContainerUrl"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go new file mode 100644 index 00000000000..b231bfe45df --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdate.go @@ -0,0 +1,14 @@ +package schemaregistries + +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 SchemaRegistryUpdate struct { + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Properties *SchemaRegistryUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go new file mode 100644 index 00000000000..704cf26ef7f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/model_schemaregistryupdateproperties.go @@ -0,0 +1,9 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryUpdateProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go new file mode 100644 index 00000000000..a6f3b796925 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/predicates.go @@ -0,0 +1,32 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaRegistryOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SchemaRegistryOperationPredicate) Matches(input SchemaRegistry) 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/deviceregistry/2024-09-01-preview/schemaregistries/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go new file mode 100644 index 00000000000..def85801165 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaregistries/version.go @@ -0,0 +1,10 @@ +package schemaregistries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemaregistries/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md new file mode 100644 index 00000000000..391e9da6e77 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemas` Documentation + +The `schemas` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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/deviceregistry/2024-09-01-preview/schemas" +``` + + +### Client Initialization + +```go +client := schemas.NewSchemasClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemasClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +payload := schemas.Schema{ + // ... +} + + +read, err := client.CreateOrReplace(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemasClient.Delete` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemasClient.Get` + +```go +ctx := context.TODO() +id := schemas.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +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: `SchemasClient.ListBySchemaRegistry` + +```go +ctx := context.TODO() +id := schemas.NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + +// alternatively `client.ListBySchemaRegistry(ctx, id)` can be used to do batched pagination +items, err := client.ListBySchemaRegistryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go new file mode 100644 index 00000000000..7929738b90e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/client.go @@ -0,0 +1,26 @@ +package schemas + +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 SchemasClient struct { + Client *resourcemanager.Client +} + +func NewSchemasClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemasClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemas", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemasClient: %+v", err) + } + + return &SchemasClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go new file mode 100644 index 00000000000..7be0b1f5a0f --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/constants.go @@ -0,0 +1,139 @@ +package schemas + +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 Format string + +const ( + FormatDeltaOnePointZero Format = "Delta/1.0" + FormatJsonSchemaDraftNegativeZeroSeven Format = "JsonSchema/draft-07" +) + +func PossibleValuesForFormat() []string { + return []string{ + string(FormatDeltaOnePointZero), + string(FormatJsonSchemaDraftNegativeZeroSeven), + } +} + +func (s *Format) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFormat(input string) (*Format, error) { + vals := map[string]Format{ + "delta/1.0": FormatDeltaOnePointZero, + "jsonschema/draft-07": FormatJsonSchemaDraftNegativeZeroSeven, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Format(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SchemaType string + +const ( + SchemaTypeMessageSchema SchemaType = "MessageSchema" +) + +func PossibleValuesForSchemaType() []string { + return []string{ + string(SchemaTypeMessageSchema), + } +} + +func (s *SchemaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSchemaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSchemaType(input string) (*SchemaType, error) { + vals := map[string]SchemaType{ + "messageschema": SchemaTypeMessageSchema, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SchemaType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go new file mode 100644 index 00000000000..8b43dc42f96 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema.go @@ -0,0 +1,139 @@ +package schemas + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SchemaId{}) +} + +var _ resourceids.ResourceId = &SchemaId{} + +// SchemaId is a struct representing the Resource ID for a Schema +type SchemaId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string +} + +// NewSchemaID returns a new SchemaId struct +func NewSchemaID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string) SchemaId { + return SchemaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + } +} + +// ParseSchemaID parses 'input' into a SchemaId +func ParseSchemaID(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaIDInsensitively parses 'input' case-insensitively into a SchemaId +// note: this method should only be used for API response data and not user input +func ParseSchemaIDInsensitively(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + return nil +} + +// ValidateSchemaID checks that 'input' can be parsed as a Schema ID +func ValidateSchemaID(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 := ParseSchemaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema ID +func (id SchemaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema ID +func (id SchemaId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + } +} + +// String returns a human-readable description of this Schema ID +func (id SchemaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + } + return fmt.Sprintf("Schema (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go new file mode 100644 index 00000000000..de76ffc1112 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schema_test.go @@ -0,0 +1,327 @@ +package schemas + +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 = &SchemaId{} + +func TestNewSchemaID(t *testing.T) { + id := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + + 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.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } +} + +func TestFormatSchemaID(t *testing.T) { + actual := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaID(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestParseSchemaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaIDInsensitively(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestSegmentsForSchemaId(t *testing.T) { + segments := SchemaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaId 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/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go new file mode 100644 index 00000000000..ec782d4769d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry.go @@ -0,0 +1,130 @@ +package schemas + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SchemaRegistryId{}) +} + +var _ resourceids.ResourceId = &SchemaRegistryId{} + +// SchemaRegistryId is a struct representing the Resource ID for a Schema Registry +type SchemaRegistryId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string +} + +// NewSchemaRegistryID returns a new SchemaRegistryId struct +func NewSchemaRegistryID(subscriptionId string, resourceGroupName string, schemaRegistryName string) SchemaRegistryId { + return SchemaRegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + } +} + +// ParseSchemaRegistryID parses 'input' into a SchemaRegistryId +func ParseSchemaRegistryID(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaRegistryIDInsensitively parses 'input' case-insensitively into a SchemaRegistryId +// note: this method should only be used for API response data and not user input +func ParseSchemaRegistryIDInsensitively(input string) (*SchemaRegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaRegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaRegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaRegistryId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + return nil +} + +// ValidateSchemaRegistryID checks that 'input' can be parsed as a Schema Registry ID +func ValidateSchemaRegistryID(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 := ParseSchemaRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Registry ID +func (id SchemaRegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Registry ID +func (id SchemaRegistryId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + } +} + +// String returns a human-readable description of this Schema Registry ID +func (id SchemaRegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + } + return fmt.Sprintf("Schema Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go new file mode 100644 index 00000000000..95a6c551695 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/id_schemaregistry_test.go @@ -0,0 +1,282 @@ +package schemas + +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 = &SchemaRegistryId{} + +func TestNewSchemaRegistryID(t *testing.T) { + id := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName") + + 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.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } +} + +func TestFormatSchemaRegistryID(t *testing.T) { + actual := NewSchemaRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryID(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestParseSchemaRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaRegistryId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Expected: &SchemaRegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaRegistryIDInsensitively(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + } +} + +func TestSegmentsForSchemaRegistryId(t *testing.T) { + segments := SchemaRegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaRegistryId 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/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go new file mode 100644 index 00000000000..6ee3b995452 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_createorreplace.go @@ -0,0 +1,58 @@ +package schemas + +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 CreateOrReplaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Schema +} + +// CreateOrReplace ... +func (c SchemasClient) CreateOrReplace(ctx context.Context, id SchemaId, input Schema) (result CreateOrReplaceOperationResponse, 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 + } + + var model Schema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go new file mode 100644 index 00000000000..c9ad7d176ba --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_delete.go @@ -0,0 +1,47 @@ +package schemas + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SchemasClient) Delete(ctx context.Context, id SchemaId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go new file mode 100644 index 00000000000..6b039364518 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_get.go @@ -0,0 +1,53 @@ +package schemas + +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 *Schema +} + +// Get ... +func (c SchemasClient) Get(ctx context.Context, id SchemaId) (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 + } + + var model Schema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go new file mode 100644 index 00000000000..cffb76c6865 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/method_listbyschemaregistry.go @@ -0,0 +1,105 @@ +package schemas + +import ( + "context" + "fmt" + "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 ListBySchemaRegistryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Schema +} + +type ListBySchemaRegistryCompleteResult struct { + LatestHttpResponse *http.Response + Items []Schema +} + +type ListBySchemaRegistryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySchemaRegistryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySchemaRegistry ... +func (c SchemasClient) ListBySchemaRegistry(ctx context.Context, id SchemaRegistryId) (result ListBySchemaRegistryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySchemaRegistryCustomPager{}, + Path: fmt.Sprintf("%s/schemas", 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 *[]Schema `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySchemaRegistryComplete retrieves all the results into a single object +func (c SchemasClient) ListBySchemaRegistryComplete(ctx context.Context, id SchemaRegistryId) (ListBySchemaRegistryCompleteResult, error) { + return c.ListBySchemaRegistryCompleteMatchingPredicate(ctx, id, SchemaOperationPredicate{}) +} + +// ListBySchemaRegistryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemasClient) ListBySchemaRegistryCompleteMatchingPredicate(ctx context.Context, id SchemaRegistryId, predicate SchemaOperationPredicate) (result ListBySchemaRegistryCompleteResult, err error) { + items := make([]Schema, 0) + + resp, err := c.ListBySchemaRegistry(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySchemaRegistryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go new file mode 100644 index 00000000000..3ddea4bb519 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schema.go @@ -0,0 +1,16 @@ +package schemas + +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 Schema struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SchemaProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go new file mode 100644 index 00000000000..2e330ea6c87 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/model_schemaproperties.go @@ -0,0 +1,14 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Format Format `json:"format"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SchemaType SchemaType `json:"schemaType"` + Tags *map[string]string `json:"tags,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go new file mode 100644 index 00000000000..4c9a2d16acc --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/predicates.go @@ -0,0 +1,27 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SchemaOperationPredicate) Matches(input Schema) 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/deviceregistry/2024-09-01-preview/schemas/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go new file mode 100644 index 00000000000..a2008ffb20e --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemas/version.go @@ -0,0 +1,10 @@ +package schemas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemas/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md new file mode 100644 index 00000000000..84c56207b78 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/schemaversions` Documentation + +The `schemaversions` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-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/deviceregistry/2024-09-01-preview/schemaversions" +``` + + +### Client Initialization + +```go +client := schemaversions.NewSchemaVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SchemaVersionsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +payload := schemaversions.SchemaVersion{ + // ... +} + + +read, err := client.CreateOrReplace(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemaVersionsClient.Delete` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SchemaVersionsClient.Get` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + +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: `SchemaVersionsClient.ListBySchema` + +```go +ctx := context.TODO() +id := schemaversions.NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + +// alternatively `client.ListBySchema(ctx, id)` can be used to do batched pagination +items, err := client.ListBySchemaComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go new file mode 100644 index 00000000000..7a4ed03f49d --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/client.go @@ -0,0 +1,26 @@ +package schemaversions + +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 SchemaVersionsClient struct { + Client *resourcemanager.Client +} + +func NewSchemaVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*SchemaVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schemaversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaVersionsClient: %+v", err) + } + + return &SchemaVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go new file mode 100644 index 00000000000..830af71bdac --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/constants.go @@ -0,0 +1,60 @@ +package schemaversions + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go new file mode 100644 index 00000000000..4f7df69aba7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema.go @@ -0,0 +1,139 @@ +package schemaversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SchemaId{}) +} + +var _ resourceids.ResourceId = &SchemaId{} + +// SchemaId is a struct representing the Resource ID for a Schema +type SchemaId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string +} + +// NewSchemaID returns a new SchemaId struct +func NewSchemaID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string) SchemaId { + return SchemaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + } +} + +// ParseSchemaID parses 'input' into a SchemaId +func ParseSchemaID(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaIDInsensitively parses 'input' case-insensitively into a SchemaId +// note: this method should only be used for API response data and not user input +func ParseSchemaIDInsensitively(input string) (*SchemaId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + return nil +} + +// ValidateSchemaID checks that 'input' can be parsed as a Schema ID +func ValidateSchemaID(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 := ParseSchemaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema ID +func (id SchemaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema ID +func (id SchemaId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + } +} + +// String returns a human-readable description of this Schema ID +func (id SchemaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + } + return fmt.Sprintf("Schema (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go new file mode 100644 index 00000000000..9572716c2fa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schema_test.go @@ -0,0 +1,327 @@ +package schemaversions + +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 = &SchemaId{} + +func TestNewSchemaID(t *testing.T) { + id := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName") + + 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.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } +} + +func TestFormatSchemaID(t *testing.T) { + actual := NewSchemaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaID(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestParseSchemaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Expected: &SchemaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaIDInsensitively(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + } +} + +func TestSegmentsForSchemaId(t *testing.T) { + segments := SchemaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaId 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/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go new file mode 100644 index 00000000000..70eade4e0b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion.go @@ -0,0 +1,148 @@ +package schemaversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SchemaVersionId{}) +} + +var _ resourceids.ResourceId = &SchemaVersionId{} + +// SchemaVersionId is a struct representing the Resource ID for a Schema Version +type SchemaVersionId struct { + SubscriptionId string + ResourceGroupName string + SchemaRegistryName string + SchemaName string + SchemaVersionName string +} + +// NewSchemaVersionID returns a new SchemaVersionId struct +func NewSchemaVersionID(subscriptionId string, resourceGroupName string, schemaRegistryName string, schemaName string, schemaVersionName string) SchemaVersionId { + return SchemaVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SchemaRegistryName: schemaRegistryName, + SchemaName: schemaName, + SchemaVersionName: schemaVersionName, + } +} + +// ParseSchemaVersionID parses 'input' into a SchemaVersionId +func ParseSchemaVersionID(input string) (*SchemaVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSchemaVersionIDInsensitively parses 'input' case-insensitively into a SchemaVersionId +// note: this method should only be used for API response data and not user input +func ParseSchemaVersionIDInsensitively(input string) (*SchemaVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SchemaVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SchemaVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SchemaVersionId) 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.SchemaRegistryName, ok = input.Parsed["schemaRegistryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaRegistryName", input) + } + + if id.SchemaName, ok = input.Parsed["schemaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaName", input) + } + + if id.SchemaVersionName, ok = input.Parsed["schemaVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "schemaVersionName", input) + } + + return nil +} + +// ValidateSchemaVersionID checks that 'input' can be parsed as a Schema Version ID +func ValidateSchemaVersionID(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 := ParseSchemaVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schema Version ID +func (id SchemaVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/schemaRegistries/%s/schemas/%s/schemaVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SchemaRegistryName, id.SchemaName, id.SchemaVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schema Version ID +func (id SchemaVersionId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticSchemaRegistries", "schemaRegistries", "schemaRegistries"), + resourceids.UserSpecifiedSegment("schemaRegistryName", "schemaRegistryName"), + resourceids.StaticSegment("staticSchemas", "schemas", "schemas"), + resourceids.UserSpecifiedSegment("schemaName", "schemaName"), + resourceids.StaticSegment("staticSchemaVersions", "schemaVersions", "schemaVersions"), + resourceids.UserSpecifiedSegment("schemaVersionName", "schemaVersionName"), + } +} + +// String returns a human-readable description of this Schema Version ID +func (id SchemaVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Schema Registry Name: %q", id.SchemaRegistryName), + fmt.Sprintf("Schema Name: %q", id.SchemaName), + fmt.Sprintf("Schema Version Name: %q", id.SchemaVersionName), + } + return fmt.Sprintf("Schema Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go new file mode 100644 index 00000000000..ad48686ff03 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/id_schemaversion_test.go @@ -0,0 +1,372 @@ +package schemaversions + +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 = &SchemaVersionId{} + +func TestNewSchemaVersionID(t *testing.T) { + id := NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName") + + 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.SchemaRegistryName != "schemaRegistryName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaRegistryName'", id.SchemaRegistryName, "schemaRegistryName") + } + + if id.SchemaName != "schemaName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaName'", id.SchemaName, "schemaName") + } + + if id.SchemaVersionName != "schemaVersionName" { + t.Fatalf("Expected %q but got %q for Segment 'SchemaVersionName'", id.SchemaVersionName, "schemaVersionName") + } +} + +func TestFormatSchemaVersionID(t *testing.T) { + actual := NewSchemaVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "schemaRegistryName", "schemaName", "schemaVersionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSchemaVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaVersionId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + SchemaVersionName: "schemaVersionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaVersionID(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + if actual.SchemaVersionName != v.Expected.SchemaVersionName { + t.Fatalf("Expected %q but got %q for SchemaVersionName", v.Expected.SchemaVersionName, actual.SchemaVersionName) + } + + } +} + +func TestParseSchemaVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SchemaVersionId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SchemaRegistryName: "schemaRegistryName", + SchemaName: "schemaName", + SchemaVersionName: "schemaVersionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/schemaRegistries/schemaRegistryName/schemas/schemaName/schemaVersions/schemaVersionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS/sChEmAvErSiOnNaMe", + Expected: &SchemaVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SchemaRegistryName: "sChEmArEgIsTrYnAmE", + SchemaName: "sChEmAnAmE", + SchemaVersionName: "sChEmAvErSiOnNaMe", + }, + }, + { + // 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.dEvIcErEgIsTrY/sChEmArEgIsTrIeS/sChEmArEgIsTrYnAmE/sChEmAs/sChEmAnAmE/sChEmAvErSiOnS/sChEmAvErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSchemaVersionIDInsensitively(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.SchemaRegistryName != v.Expected.SchemaRegistryName { + t.Fatalf("Expected %q but got %q for SchemaRegistryName", v.Expected.SchemaRegistryName, actual.SchemaRegistryName) + } + + if actual.SchemaName != v.Expected.SchemaName { + t.Fatalf("Expected %q but got %q for SchemaName", v.Expected.SchemaName, actual.SchemaName) + } + + if actual.SchemaVersionName != v.Expected.SchemaVersionName { + t.Fatalf("Expected %q but got %q for SchemaVersionName", v.Expected.SchemaVersionName, actual.SchemaVersionName) + } + + } +} + +func TestSegmentsForSchemaVersionId(t *testing.T) { + segments := SchemaVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SchemaVersionId 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/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go new file mode 100644 index 00000000000..b8602a9a5e7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_createorreplace.go @@ -0,0 +1,58 @@ +package schemaversions + +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 CreateOrReplaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SchemaVersion +} + +// CreateOrReplace ... +func (c SchemaVersionsClient) CreateOrReplace(ctx context.Context, id SchemaVersionId, input SchemaVersion) (result CreateOrReplaceOperationResponse, 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 + } + + var model SchemaVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go new file mode 100644 index 00000000000..370ff70ebaa --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_delete.go @@ -0,0 +1,47 @@ +package schemaversions + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SchemaVersionsClient) Delete(ctx context.Context, id SchemaVersionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go new file mode 100644 index 00000000000..7ca9e62d750 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_get.go @@ -0,0 +1,53 @@ +package schemaversions + +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 *SchemaVersion +} + +// Get ... +func (c SchemaVersionsClient) Get(ctx context.Context, id SchemaVersionId) (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 + } + + var model SchemaVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go new file mode 100644 index 00000000000..5ec1fac8903 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/method_listbyschema.go @@ -0,0 +1,105 @@ +package schemaversions + +import ( + "context" + "fmt" + "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 ListBySchemaOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaVersion +} + +type ListBySchemaCompleteResult struct { + LatestHttpResponse *http.Response + Items []SchemaVersion +} + +type ListBySchemaCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySchemaCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySchema ... +func (c SchemaVersionsClient) ListBySchema(ctx context.Context, id SchemaId) (result ListBySchemaOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySchemaCustomPager{}, + Path: fmt.Sprintf("%s/schemaVersions", 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 *[]SchemaVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySchemaComplete retrieves all the results into a single object +func (c SchemaVersionsClient) ListBySchemaComplete(ctx context.Context, id SchemaId) (ListBySchemaCompleteResult, error) { + return c.ListBySchemaCompleteMatchingPredicate(ctx, id, SchemaVersionOperationPredicate{}) +} + +// ListBySchemaCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaVersionsClient) ListBySchemaCompleteMatchingPredicate(ctx context.Context, id SchemaId, predicate SchemaVersionOperationPredicate) (result ListBySchemaCompleteResult, err error) { + items := make([]SchemaVersion, 0) + + resp, err := c.ListBySchema(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySchemaCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go new file mode 100644 index 00000000000..ec1400fe34b --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversion.go @@ -0,0 +1,16 @@ +package schemaversions + +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 SchemaVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SchemaVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go new file mode 100644 index 00000000000..62cc1c3b58a --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/model_schemaversionproperties.go @@ -0,0 +1,12 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaVersionProperties struct { + Description *string `json:"description,omitempty"` + Hash *string `json:"hash,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SchemaContent string `json:"schemaContent"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go new file mode 100644 index 00000000000..7d1db6450f9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/predicates.go @@ -0,0 +1,27 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchemaVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SchemaVersionOperationPredicate) Matches(input SchemaVersion) 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/deviceregistry/2024-09-01-preview/schemaversions/version.go b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go new file mode 100644 index 00000000000..900ebe05bc4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-09-01-preview/schemaversions/version.go @@ -0,0 +1,10 @@ +package schemaversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schemaversions/2024-09-01-preview" +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/README.md b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/README.md new file mode 100644 index 00000000000..833988a0fe2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles` Documentation + +The `assetendpointprofiles` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-11-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles" +``` + + +### Client Initialization + +```go +client := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetEndpointProfilesClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfile{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Delete` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Get` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +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: `AssetEndpointProfilesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetEndpointProfilesClient.Update` + +```go +ctx := context.TODO() +id := assetendpointprofiles.NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + +payload := assetendpointprofiles.AssetEndpointProfileUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/client.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/client.go new file mode 100644 index 00000000000..099374a758a --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/client.go @@ -0,0 +1,26 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient struct { + Client *resourcemanager.Client +} + +func NewAssetEndpointProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetEndpointProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assetendpointprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetEndpointProfilesClient: %+v", err) + } + + return &AssetEndpointProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/constants.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/constants.go new file mode 100644 index 00000000000..3d109615ec0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/constants.go @@ -0,0 +1,104 @@ +package assetendpointprofiles + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous" + AuthenticationMethodCertificate AuthenticationMethod = "Certificate" + AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAnonymous), + string(AuthenticationMethodCertificate), + string(AuthenticationMethodUsernamePassword), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "anonymous": AuthenticationMethodAnonymous, + "certificate": AuthenticationMethodCertificate, + "usernamepassword": AuthenticationMethodUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile.go new file mode 100644 index 00000000000..e372455f8ff --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile.go @@ -0,0 +1,130 @@ +package assetendpointprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AssetEndpointProfileId{}) +} + +var _ resourceids.ResourceId = &AssetEndpointProfileId{} + +// AssetEndpointProfileId is a struct representing the Resource ID for a Asset Endpoint Profile +type AssetEndpointProfileId struct { + SubscriptionId string + ResourceGroupName string + AssetEndpointProfileName string +} + +// NewAssetEndpointProfileID returns a new AssetEndpointProfileId struct +func NewAssetEndpointProfileID(subscriptionId string, resourceGroupName string, assetEndpointProfileName string) AssetEndpointProfileId { + return AssetEndpointProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetEndpointProfileName: assetEndpointProfileName, + } +} + +// ParseAssetEndpointProfileID parses 'input' into a AssetEndpointProfileId +func ParseAssetEndpointProfileID(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetEndpointProfileIDInsensitively parses 'input' case-insensitively into a AssetEndpointProfileId +// note: this method should only be used for API response data and not user input +func ParseAssetEndpointProfileIDInsensitively(input string) (*AssetEndpointProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetEndpointProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetEndpointProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetEndpointProfileId) 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.AssetEndpointProfileName, ok = input.Parsed["assetEndpointProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetEndpointProfileName", input) + } + + return nil +} + +// ValidateAssetEndpointProfileID checks that 'input' can be parsed as a Asset Endpoint Profile ID +func ValidateAssetEndpointProfileID(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 := ParseAssetEndpointProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset Endpoint Profile ID +func (id AssetEndpointProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetEndpointProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssetEndpointProfiles", "assetEndpointProfiles", "assetEndpointProfiles"), + resourceids.UserSpecifiedSegment("assetEndpointProfileName", "assetEndpointProfileName"), + } +} + +// String returns a human-readable description of this Asset Endpoint Profile ID +func (id AssetEndpointProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Endpoint Profile Name: %q", id.AssetEndpointProfileName), + } + return fmt.Sprintf("Asset Endpoint Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile_test.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile_test.go new file mode 100644 index 00000000000..59928f613b1 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/id_assetendpointprofile_test.go @@ -0,0 +1,282 @@ +package assetendpointprofiles + +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 = &AssetEndpointProfileId{} + +func TestNewAssetEndpointProfileID(t *testing.T) { + id := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName") + + 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.AssetEndpointProfileName != "assetEndpointProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetEndpointProfileName'", id.AssetEndpointProfileName, "assetEndpointProfileName") + } +} + +func TestFormatAssetEndpointProfileID(t *testing.T) { + actual := NewAssetEndpointProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetEndpointProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetEndpointProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileID(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.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestParseAssetEndpointProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetEndpointProfileId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetEndpointProfileName: "assetEndpointProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/assetEndpointProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE", + Expected: &AssetEndpointProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetEndpointProfileName: "aSsEtEnDpOiNtPrOfIlEnAmE", + }, + }, + { + // 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.dEvIcErEgIsTrY/aSsEtEnDpOiNtPrOfIlEs/aSsEtEnDpOiNtPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetEndpointProfileIDInsensitively(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.AssetEndpointProfileName != v.Expected.AssetEndpointProfileName { + t.Fatalf("Expected %q but got %q for AssetEndpointProfileName", v.Expected.AssetEndpointProfileName, actual.AssetEndpointProfileName) + } + + } +} + +func TestSegmentsForAssetEndpointProfileId(t *testing.T) { + segments := AssetEndpointProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetEndpointProfileId 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/deviceregistry/2024-11-01/assetendpointprofiles/method_createorreplace.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_createorreplace.go new file mode 100644 index 00000000000..1dd13be906d --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_createorreplace.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AssetEndpointProfile +} + +// CreateOrReplace ... +func (c AssetEndpointProfilesClient) CreateOrReplace(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetEndpointProfilesClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfile) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_delete.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_delete.go new file mode 100644 index 00000000000..b24134a6027 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_delete.go @@ -0,0 +1,70 @@ +package assetendpointprofiles + +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 AssetEndpointProfilesClient) Delete(ctx context.Context, id AssetEndpointProfileId) (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 AssetEndpointProfilesClient) DeleteThenPoll(ctx context.Context, id AssetEndpointProfileId) 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/deviceregistry/2024-11-01/assetendpointprofiles/method_get.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_get.go new file mode 100644 index 00000000000..2a5f882cc3c --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_get.go @@ -0,0 +1,53 @@ +package assetendpointprofiles + +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 *AssetEndpointProfile +} + +// Get ... +func (c AssetEndpointProfilesClient) Get(ctx context.Context, id AssetEndpointProfileId) (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 + } + + var model AssetEndpointProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbyresourcegroup.go new file mode 100644 index 00000000000..dba6b469adb --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AssetEndpointProfile +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AssetEndpointProfilesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AssetEndpointProfilesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetEndpointProfileOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbysubscription.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbysubscription.go new file mode 100644 index 00000000000..13b32409dc6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assetendpointprofiles + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AssetEndpointProfile +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AssetEndpointProfile +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetEndpointProfilesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", 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 *[]AssetEndpointProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetEndpointProfilesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetEndpointProfileOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetEndpointProfilesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetEndpointProfileOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AssetEndpointProfile, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_update.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_update.go new file mode 100644 index 00000000000..2af77249a09 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/method_update.go @@ -0,0 +1,75 @@ +package assetendpointprofiles + +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 + Model *AssetEndpointProfile +} + +// Update ... +func (c AssetEndpointProfilesClient) Update(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) (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 AssetEndpointProfilesClient) UpdateThenPoll(ctx context.Context, id AssetEndpointProfileId, input AssetEndpointProfileUpdate) 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/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofile.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofile.go new file mode 100644 index 00000000000..8968e9fd724 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofile.go @@ -0,0 +1,19 @@ +package assetendpointprofiles + +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 AssetEndpointProfile struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetEndpointProfileProperties `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/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileproperties.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileproperties.go new file mode 100644 index 00000000000..f4ca0e2ffc3 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileproperties.go @@ -0,0 +1,15 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *Authentication `json:"authentication,omitempty"` + DiscoveredAssetEndpointProfileRef *string `json:"discoveredAssetEndpointProfileRef,omitempty"` + EndpointProfileType string `json:"endpointProfileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *AssetEndpointProfileStatus `json:"status,omitempty"` + TargetAddress string `json:"targetAddress"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatus.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatus.go new file mode 100644 index 00000000000..b9352a519b4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatus.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatus struct { + Errors *[]AssetEndpointProfileStatusError `json:"errors,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatuserror.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatuserror.go new file mode 100644 index 00000000000..43ef3ee7188 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofilestatuserror.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdate.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdate.go new file mode 100644 index 00000000000..0bfe7125133 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdate struct { + Properties *AssetEndpointProfileUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdateproperties.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdateproperties.go new file mode 100644 index 00000000000..a05bb6eefb0 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_assetendpointprofileupdateproperties.go @@ -0,0 +1,11 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileUpdateProperties struct { + AdditionalConfiguration *string `json:"additionalConfiguration,omitempty"` + Authentication *AuthenticationUpdate `json:"authentication,omitempty"` + EndpointProfileType *string `json:"endpointProfileType,omitempty"` + TargetAddress *string `json:"targetAddress,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authentication.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authentication.go new file mode 100644 index 00000000000..67a43dfa2cd --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authentication.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Authentication struct { + Method AuthenticationMethod `json:"method"` + UsernamePasswordCredentials *UsernamePasswordCredentials `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509Credentials `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authenticationupdate.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authenticationupdate.go new file mode 100644 index 00000000000..b0f0d7ef0f6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_authenticationupdate.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationUpdate struct { + Method *AuthenticationMethod `json:"method,omitempty"` + UsernamePasswordCredentials *UsernamePasswordCredentialsUpdate `json:"usernamePasswordCredentials,omitempty"` + X509Credentials *X509CredentialsUpdate `json:"x509Credentials,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_extendedlocation.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_extendedlocation.go new file mode 100644 index 00000000000..0fb2e13abac --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentials.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentials.go new file mode 100644 index 00000000000..b108ab27db6 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentials.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentials struct { + PasswordSecretName string `json:"passwordSecretName"` + UsernameSecretName string `json:"usernameSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go new file mode 100644 index 00000000000..cf842482565 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_usernamepasswordcredentialsupdate.go @@ -0,0 +1,9 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsernamePasswordCredentialsUpdate struct { + PasswordSecretName *string `json:"passwordSecretName,omitempty"` + UsernameSecretName *string `json:"usernameSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentials.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentials.go new file mode 100644 index 00000000000..5b3cd78827c --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentials.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509Credentials struct { + CertificateSecretName string `json:"certificateSecretName"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentialsupdate.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentialsupdate.go new file mode 100644 index 00000000000..920bb4fb03b --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/model_x509credentialsupdate.go @@ -0,0 +1,8 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type X509CredentialsUpdate struct { + CertificateSecretName *string `json:"certificateSecretName,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/predicates.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/predicates.go new file mode 100644 index 00000000000..fb0fb8f73eb --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/predicates.go @@ -0,0 +1,32 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetEndpointProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetEndpointProfileOperationPredicate) Matches(input AssetEndpointProfile) 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/deviceregistry/2024-11-01/assetendpointprofiles/version.go b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/version.go new file mode 100644 index 00000000000..b100815e9e4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assetendpointprofiles/version.go @@ -0,0 +1,10 @@ +package assetendpointprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assetendpointprofiles/2024-11-01" +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/README.md b/resource-manager/deviceregistry/2024-11-01/assets/README.md new file mode 100644 index 00000000000..74b768e7d48 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/assets` Documentation + +The `assets` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-11-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/assets" +``` + + +### Client Initialization + +```go +client := assets.NewAssetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AssetsClient.CreateOrReplace` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.Asset{ + // ... +} + + +if err := client.CreateOrReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Delete` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AssetsClient.Get` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +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: `AssetsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AssetsClient.Update` + +```go +ctx := context.TODO() +id := assets.NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + +payload := assets.AssetUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/deviceregistry/2024-11-01/assets/client.go b/resource-manager/deviceregistry/2024-11-01/assets/client.go new file mode 100644 index 00000000000..a72f6492047 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/client.go @@ -0,0 +1,26 @@ +package assets + +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 AssetsClient struct { + Client *resourcemanager.Client +} + +func NewAssetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AssetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "assets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AssetsClient: %+v", err) + } + + return &AssetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/constants.go b/resource-manager/deviceregistry/2024-11-01/assets/constants.go new file mode 100644 index 00000000000..ac288b94567 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/constants.go @@ -0,0 +1,192 @@ +package assets + +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 DataPointObservabilityMode string + +const ( + DataPointObservabilityModeCounter DataPointObservabilityMode = "Counter" + DataPointObservabilityModeGauge DataPointObservabilityMode = "Gauge" + DataPointObservabilityModeHistogram DataPointObservabilityMode = "Histogram" + DataPointObservabilityModeLog DataPointObservabilityMode = "Log" + DataPointObservabilityModeNone DataPointObservabilityMode = "None" +) + +func PossibleValuesForDataPointObservabilityMode() []string { + return []string{ + string(DataPointObservabilityModeCounter), + string(DataPointObservabilityModeGauge), + string(DataPointObservabilityModeHistogram), + string(DataPointObservabilityModeLog), + string(DataPointObservabilityModeNone), + } +} + +func (s *DataPointObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataPointObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataPointObservabilityMode(input string) (*DataPointObservabilityMode, error) { + vals := map[string]DataPointObservabilityMode{ + "counter": DataPointObservabilityModeCounter, + "gauge": DataPointObservabilityModeGauge, + "histogram": DataPointObservabilityModeHistogram, + "log": DataPointObservabilityModeLog, + "none": DataPointObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataPointObservabilityMode(input) + return &out, nil +} + +type EventObservabilityMode string + +const ( + EventObservabilityModeLog EventObservabilityMode = "Log" + EventObservabilityModeNone EventObservabilityMode = "None" +) + +func PossibleValuesForEventObservabilityMode() []string { + return []string{ + string(EventObservabilityModeLog), + string(EventObservabilityModeNone), + } +} + +func (s *EventObservabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventObservabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventObservabilityMode(input string) (*EventObservabilityMode, error) { + vals := map[string]EventObservabilityMode{ + "log": EventObservabilityModeLog, + "none": EventObservabilityModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventObservabilityMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type TopicRetainType string + +const ( + TopicRetainTypeKeep TopicRetainType = "Keep" + TopicRetainTypeNever TopicRetainType = "Never" +) + +func PossibleValuesForTopicRetainType() []string { + return []string{ + string(TopicRetainTypeKeep), + string(TopicRetainTypeNever), + } +} + +func (s *TopicRetainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTopicRetainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTopicRetainType(input string) (*TopicRetainType, error) { + vals := map[string]TopicRetainType{ + "keep": TopicRetainTypeKeep, + "never": TopicRetainTypeNever, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TopicRetainType(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/id_asset.go b/resource-manager/deviceregistry/2024-11-01/assets/id_asset.go new file mode 100644 index 00000000000..bb7b45f0c33 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/id_asset.go @@ -0,0 +1,130 @@ +package assets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AssetId{}) +} + +var _ resourceids.ResourceId = &AssetId{} + +// AssetId is a struct representing the Resource ID for a Asset +type AssetId struct { + SubscriptionId string + ResourceGroupName string + AssetName string +} + +// NewAssetID returns a new AssetId struct +func NewAssetID(subscriptionId string, resourceGroupName string, assetName string) AssetId { + return AssetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AssetName: assetName, + } +} + +// ParseAssetID parses 'input' into a AssetId +func ParseAssetID(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAssetIDInsensitively parses 'input' case-insensitively into a AssetId +// note: this method should only be used for API response data and not user input +func ParseAssetIDInsensitively(input string) (*AssetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AssetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AssetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AssetId) 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.AssetName, ok = input.Parsed["assetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "assetName", input) + } + + return nil +} + +// ValidateAssetID checks that 'input' can be parsed as a Asset ID +func ValidateAssetID(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 := ParseAssetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Asset ID +func (id AssetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Asset ID +func (id AssetId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticAssets", "assets", "assets"), + resourceids.UserSpecifiedSegment("assetName", "assetName"), + } +} + +// String returns a human-readable description of this Asset ID +func (id AssetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Asset Name: %q", id.AssetName), + } + return fmt.Sprintf("Asset (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/id_asset_test.go b/resource-manager/deviceregistry/2024-11-01/assets/id_asset_test.go new file mode 100644 index 00000000000..533809babad --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/id_asset_test.go @@ -0,0 +1,282 @@ +package assets + +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 = &AssetId{} + +func TestNewAssetID(t *testing.T) { + id := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName") + + 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.AssetName != "assetName" { + t.Fatalf("Expected %q but got %q for Segment 'AssetName'", id.AssetName, "assetName") + } +} + +func TestFormatAssetID(t *testing.T) { + actual := NewAssetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "assetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAssetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetID(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.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestParseAssetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AssetId + }{ + { + // 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.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AssetName: "assetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DeviceRegistry/assets/assetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe", + Expected: &AssetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AssetName: "aSsEtNaMe", + }, + }, + { + // 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.dEvIcErEgIsTrY/aSsEtS/aSsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAssetIDInsensitively(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.AssetName != v.Expected.AssetName { + t.Fatalf("Expected %q but got %q for AssetName", v.Expected.AssetName, actual.AssetName) + } + + } +} + +func TestSegmentsForAssetId(t *testing.T) { + segments := AssetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AssetId 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/deviceregistry/2024-11-01/assets/method_createorreplace.go b/resource-manager/deviceregistry/2024-11-01/assets/method_createorreplace.go new file mode 100644 index 00000000000..b6a7798f315 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_createorreplace.go @@ -0,0 +1,75 @@ +package assets + +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 CreateOrReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Asset +} + +// CreateOrReplace ... +func (c AssetsClient) CreateOrReplace(ctx context.Context, id AssetId, input Asset) (result CreateOrReplaceOperationResponse, 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 +} + +// CreateOrReplaceThenPoll performs CreateOrReplace then polls until it's completed +func (c AssetsClient) CreateOrReplaceThenPoll(ctx context.Context, id AssetId, input Asset) error { + result, err := c.CreateOrReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/method_delete.go b/resource-manager/deviceregistry/2024-11-01/assets/method_delete.go new file mode 100644 index 00000000000..34b6146a5f2 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_delete.go @@ -0,0 +1,70 @@ +package assets + +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 AssetsClient) Delete(ctx context.Context, id AssetId) (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 AssetsClient) DeleteThenPoll(ctx context.Context, id AssetId) 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/deviceregistry/2024-11-01/assets/method_get.go b/resource-manager/deviceregistry/2024-11-01/assets/method_get.go new file mode 100644 index 00000000000..8eabe4d065a --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_get.go @@ -0,0 +1,53 @@ +package assets + +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 *Asset +} + +// Get ... +func (c AssetsClient) Get(ctx context.Context, id AssetId) (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 + } + + var model Asset + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/method_listbyresourcegroup.go b/resource-manager/deviceregistry/2024-11-01/assets/method_listbyresourcegroup.go new file mode 100644 index 00000000000..c063d4d77db --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package assets + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Asset +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AssetsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AssetsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AssetOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/method_listbysubscription.go b/resource-manager/deviceregistry/2024-11-01/assets/method_listbysubscription.go new file mode 100644 index 00000000000..fe6c812e1cb --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_listbysubscription.go @@ -0,0 +1,106 @@ +package assets + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Asset +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Asset +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AssetsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/assets", 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 *[]Asset `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AssetsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AssetOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AssetsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AssetOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Asset, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/method_update.go b/resource-manager/deviceregistry/2024-11-01/assets/method_update.go new file mode 100644 index 00000000000..42754ffb942 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/method_update.go @@ -0,0 +1,75 @@ +package assets + +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 + Model *Asset +} + +// Update ... +func (c AssetsClient) Update(ctx context.Context, id AssetId, input AssetUpdate) (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 AssetsClient) UpdateThenPoll(ctx context.Context, id AssetId, input AssetUpdate) 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/deviceregistry/2024-11-01/assets/model_asset.go b/resource-manager/deviceregistry/2024-11-01/assets/model_asset.go new file mode 100644 index 00000000000..24857b429fa --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_asset.go @@ -0,0 +1,19 @@ +package assets + +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 Asset struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AssetProperties `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/deviceregistry/2024-11-01/assets/model_assetproperties.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetproperties.go new file mode 100644 index 00000000000..73ce93da09b --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetproperties.go @@ -0,0 +1,31 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetProperties struct { + AssetEndpointProfileRef string `json:"assetEndpointProfileRef"` + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *Topic `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DiscoveredAssetRefs *[]string `json:"discoveredAssetRefs,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + ExternalAssetId *string `json:"externalAssetId,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` + Status *AssetStatus `json:"status,omitempty"` + Uuid *string `json:"uuid,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatus.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatus.go new file mode 100644 index 00000000000..59adc5ba1c8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatus.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatus struct { + Datasets *[]AssetStatusDataset `json:"datasets,omitempty"` + Errors *[]AssetStatusError `json:"errors,omitempty"` + Events *[]AssetStatusEvent `json:"events,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusdataset.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusdataset.go new file mode 100644 index 00000000000..511593b5e8f --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusdataset.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusDataset struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatuserror.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatuserror.go new file mode 100644 index 00000000000..c87108ecc08 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatuserror.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusError struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusevent.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusevent.go new file mode 100644 index 00000000000..2438f4620ca --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetstatusevent.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetStatusEvent struct { + MessageSchemaReference *MessageSchemaReference `json:"messageSchemaReference,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdate.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdate.go new file mode 100644 index 00000000000..6ff6aa0a80b --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdate struct { + Properties *AssetUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdateproperties.go b/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdateproperties.go new file mode 100644 index 00000000000..e18024904a9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_assetupdateproperties.go @@ -0,0 +1,24 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetUpdateProperties struct { + Attributes *map[string]interface{} `json:"attributes,omitempty"` + Datasets *[]Dataset `json:"datasets,omitempty"` + DefaultDatasetsConfiguration *string `json:"defaultDatasetsConfiguration,omitempty"` + DefaultEventsConfiguration *string `json:"defaultEventsConfiguration,omitempty"` + DefaultTopic *TopicUpdate `json:"defaultTopic,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DocumentationUri *string `json:"documentationUri,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Events *[]Event `json:"events,omitempty"` + HardwareRevision *string `json:"hardwareRevision,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + ManufacturerUri *string `json:"manufacturerUri,omitempty"` + Model *string `json:"model,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SoftwareRevision *string `json:"softwareRevision,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_datapoint.go b/resource-manager/deviceregistry/2024-11-01/assets/model_datapoint.go new file mode 100644 index 00000000000..45563621600 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_datapoint.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPoint struct { + DataPointConfiguration *string `json:"dataPointConfiguration,omitempty"` + DataSource string `json:"dataSource"` + Name string `json:"name"` + ObservabilityMode *DataPointObservabilityMode `json:"observabilityMode,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_dataset.go b/resource-manager/deviceregistry/2024-11-01/assets/model_dataset.go new file mode 100644 index 00000000000..6bd5a412380 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_dataset.go @@ -0,0 +1,11 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dataset struct { + DataPoints *[]DataPoint `json:"dataPoints,omitempty"` + DatasetConfiguration *string `json:"datasetConfiguration,omitempty"` + Name string `json:"name"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_event.go b/resource-manager/deviceregistry/2024-11-01/assets/model_event.go new file mode 100644 index 00000000000..0586fe3f37b --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_event.go @@ -0,0 +1,12 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Event struct { + EventConfiguration *string `json:"eventConfiguration,omitempty"` + EventNotifier string `json:"eventNotifier"` + Name string `json:"name"` + ObservabilityMode *EventObservabilityMode `json:"observabilityMode,omitempty"` + Topic *Topic `json:"topic,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_extendedlocation.go b/resource-manager/deviceregistry/2024-11-01/assets/model_extendedlocation.go new file mode 100644 index 00000000000..1ab2aa85f80 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_extendedlocation.go @@ -0,0 +1,9 @@ +package assets + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_messageschemareference.go b/resource-manager/deviceregistry/2024-11-01/assets/model_messageschemareference.go new file mode 100644 index 00000000000..098722031b9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_messageschemareference.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageSchemaReference struct { + SchemaName string `json:"schemaName"` + SchemaRegistryNamespace string `json:"schemaRegistryNamespace"` + SchemaVersion string `json:"schemaVersion"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_topic.go b/resource-manager/deviceregistry/2024-11-01/assets/model_topic.go new file mode 100644 index 00000000000..83d513322ab --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_topic.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topic struct { + Path string `json:"path"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/model_topicupdate.go b/resource-manager/deviceregistry/2024-11-01/assets/model_topicupdate.go new file mode 100644 index 00000000000..d43a63c0c8e --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/model_topicupdate.go @@ -0,0 +1,9 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicUpdate struct { + Path *string `json:"path,omitempty"` + Retain *TopicRetainType `json:"retain,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/assets/predicates.go b/resource-manager/deviceregistry/2024-11-01/assets/predicates.go new file mode 100644 index 00000000000..cedd4ebc101 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/predicates.go @@ -0,0 +1,32 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AssetOperationPredicate) Matches(input Asset) 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/deviceregistry/2024-11-01/assets/version.go b/resource-manager/deviceregistry/2024-11-01/assets/version.go new file mode 100644 index 00000000000..296a730ec87 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/assets/version.go @@ -0,0 +1,10 @@ +package assets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/assets/2024-11-01" +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/README.md b/resource-manager/deviceregistry/2024-11-01/billingcontainers/README.md new file mode 100644 index 00000000000..8001a3a9bee --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/billingcontainers` Documentation + +The `billingcontainers` SDK allows for interaction with Azure Resource Manager `deviceregistry` (API Version `2024-11-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/billingcontainers" +``` + + +### Client Initialization + +```go +client := billingcontainers.NewBillingContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BillingContainersClient.Get` + +```go +ctx := context.TODO() +id := billingcontainers.NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + +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: `BillingContainersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/client.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/client.go new file mode 100644 index 00000000000..3361e18593c --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/client.go @@ -0,0 +1,26 @@ +package billingcontainers + +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 BillingContainersClient struct { + Client *resourcemanager.Client +} + +func NewBillingContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*BillingContainersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "billingcontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BillingContainersClient: %+v", err) + } + + return &BillingContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/constants.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/constants.go new file mode 100644 index 00000000000..b98bfe20660 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/constants.go @@ -0,0 +1,60 @@ +package billingcontainers + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer.go new file mode 100644 index 00000000000..38f08f9926f --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer.go @@ -0,0 +1,121 @@ +package billingcontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BillingContainerId{}) +} + +var _ resourceids.ResourceId = &BillingContainerId{} + +// BillingContainerId is a struct representing the Resource ID for a Billing Container +type BillingContainerId struct { + SubscriptionId string + BillingContainerName string +} + +// NewBillingContainerID returns a new BillingContainerId struct +func NewBillingContainerID(subscriptionId string, billingContainerName string) BillingContainerId { + return BillingContainerId{ + SubscriptionId: subscriptionId, + BillingContainerName: billingContainerName, + } +} + +// ParseBillingContainerID parses 'input' into a BillingContainerId +func ParseBillingContainerID(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBillingContainerIDInsensitively parses 'input' case-insensitively into a BillingContainerId +// note: this method should only be used for API response data and not user input +func ParseBillingContainerIDInsensitively(input string) (*BillingContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&BillingContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BillingContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BillingContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.BillingContainerName, ok = input.Parsed["billingContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "billingContainerName", input) + } + + return nil +} + +// ValidateBillingContainerID checks that 'input' can be parsed as a Billing Container ID +func ValidateBillingContainerID(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 := ParseBillingContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Billing Container ID +func (id BillingContainerId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DeviceRegistry/billingContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.BillingContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Billing Container ID +func (id BillingContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"), + resourceids.StaticSegment("staticBillingContainers", "billingContainers", "billingContainers"), + resourceids.UserSpecifiedSegment("billingContainerName", "billingContainerName"), + } +} + +// String returns a human-readable description of this Billing Container ID +func (id BillingContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Billing Container Name: %q", id.BillingContainerName), + } + return fmt.Sprintf("Billing Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer_test.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer_test.go new file mode 100644 index 00000000000..3f44a3afbf9 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/id_billingcontainer_test.go @@ -0,0 +1,237 @@ +package billingcontainers + +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 = &BillingContainerId{} + +func TestNewBillingContainerID(t *testing.T) { + id := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName") + + 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.BillingContainerName != "billingContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'BillingContainerName'", id.BillingContainerName, "billingContainerName") + } +} + +func TestFormatBillingContainerID(t *testing.T) { + actual := NewBillingContainerID("12345678-1234-9876-4563-123456789012", "billingContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBillingContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerID(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.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestParseBillingContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BillingContainerId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "billingContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DeviceRegistry/billingContainers/billingContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE", + Expected: &BillingContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + BillingContainerName: "bIlLiNgCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvIcErEgIsTrY/bIlLiNgCoNtAiNeRs/bIlLiNgCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBillingContainerIDInsensitively(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.BillingContainerName != v.Expected.BillingContainerName { + t.Fatalf("Expected %q but got %q for BillingContainerName", v.Expected.BillingContainerName, actual.BillingContainerName) + } + + } +} + +func TestSegmentsForBillingContainerId(t *testing.T) { + segments := BillingContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BillingContainerId 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/deviceregistry/2024-11-01/billingcontainers/method_get.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/method_get.go new file mode 100644 index 00000000000..564089fc3d8 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/method_get.go @@ -0,0 +1,53 @@ +package billingcontainers + +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 *BillingContainer +} + +// Get ... +func (c BillingContainersClient) Get(ctx context.Context, id BillingContainerId) (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 + } + + var model BillingContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/method_listbysubscription.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/method_listbysubscription.go new file mode 100644 index 00000000000..4f6fa1d21b7 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/method_listbysubscription.go @@ -0,0 +1,106 @@ +package billingcontainers + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingContainer +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingContainer +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c BillingContainersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceRegistry/billingContainers", 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 *[]BillingContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c BillingContainersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, BillingContainerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BillingContainersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BillingContainerOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]BillingContainer, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainer.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainer.go new file mode 100644 index 00000000000..d897ec1b71d --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainer.go @@ -0,0 +1,17 @@ +package billingcontainers + +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 BillingContainer struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingContainerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainerproperties.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainerproperties.go new file mode 100644 index 00000000000..ad3f625d084 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/model_billingcontainerproperties.go @@ -0,0 +1,8 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/deviceregistry/2024-11-01/billingcontainers/predicates.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/predicates.go new file mode 100644 index 00000000000..8e61fac37ac --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/predicates.go @@ -0,0 +1,32 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingContainerOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p BillingContainerOperationPredicate) Matches(input BillingContainer) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/deviceregistry/2024-11-01/billingcontainers/version.go b/resource-manager/deviceregistry/2024-11-01/billingcontainers/version.go new file mode 100644 index 00000000000..3362d67d2a4 --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/billingcontainers/version.go @@ -0,0 +1,10 @@ +package billingcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/billingcontainers/2024-11-01" +} diff --git a/resource-manager/deviceregistry/2024-11-01/client.go b/resource-manager/deviceregistry/2024-11-01/client.go new file mode 100644 index 00000000000..1191643ffba --- /dev/null +++ b/resource-manager/deviceregistry/2024-11-01/client.go @@ -0,0 +1,46 @@ +package v2024_11_01 + +// 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/deviceregistry/2024-11-01/assetendpointprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/assets" + "github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-11-01/billingcontainers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AssetEndpointProfiles *assetendpointprofiles.AssetEndpointProfilesClient + Assets *assets.AssetsClient + BillingContainers *billingcontainers.BillingContainersClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + assetEndpointProfilesClient, err := assetendpointprofiles.NewAssetEndpointProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AssetEndpointProfiles client: %+v", err) + } + configureFunc(assetEndpointProfilesClient.Client) + + assetsClient, err := assets.NewAssetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Assets client: %+v", err) + } + configureFunc(assetsClient.Client) + + billingContainersClient, err := billingcontainers.NewBillingContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BillingContainers client: %+v", err) + } + configureFunc(billingContainersClient.Client) + + return &Client{ + AssetEndpointProfiles: assetEndpointProfilesClient, + Assets: assetsClient, + BillingContainers: billingContainersClient, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/client.go b/resource-manager/devopsinfrastructure/2024-10-19/client.go new file mode 100644 index 00000000000..5135cc8bf5c --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/client.go @@ -0,0 +1,64 @@ +package v2024_10_19 + +// 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/devopsinfrastructure/2024-10-19/imageversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/pools" + "github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails" + "github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/sku" + "github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + ImageVersions *imageversions.ImageVersionsClient + Pools *pools.PoolsClient + ResourceDetails *resourcedetails.ResourceDetailsClient + Sku *sku.SkuClient + SubscriptionUsages *subscriptionusages.SubscriptionUsagesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + imageVersionsClient, err := imageversions.NewImageVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ImageVersions client: %+v", err) + } + configureFunc(imageVersionsClient.Client) + + poolsClient, err := pools.NewPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Pools client: %+v", err) + } + configureFunc(poolsClient.Client) + + resourceDetailsClient, err := resourcedetails.NewResourceDetailsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceDetails client: %+v", err) + } + configureFunc(resourceDetailsClient.Client) + + skuClient, err := sku.NewSkuClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Sku client: %+v", err) + } + configureFunc(skuClient.Client) + + subscriptionUsagesClient, err := subscriptionusages.NewSubscriptionUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SubscriptionUsages client: %+v", err) + } + configureFunc(subscriptionUsagesClient.Client) + + return &Client{ + ImageVersions: imageVersionsClient, + Pools: poolsClient, + ResourceDetails: resourceDetailsClient, + Sku: skuClient, + SubscriptionUsages: subscriptionUsagesClient, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/README.md b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/README.md new file mode 100644 index 00000000000..10ccb3fe7fa --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/imageversions` Documentation + +The `imageversions` SDK allows for interaction with Azure Resource Manager `devopsinfrastructure` (API Version `2024-10-19`). + +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/devopsinfrastructure/2024-10-19/imageversions" +``` + + +### Client Initialization + +```go +client := imageversions.NewImageVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ImageVersionsClient.ListByImage` + +```go +ctx := context.TODO() +id := imageversions.NewImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "imageName") + +// alternatively `client.ListByImage(ctx, id)` can be used to do batched pagination +items, err := client.ListByImageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/client.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/client.go new file mode 100644 index 00000000000..7a3a0578fb2 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/client.go @@ -0,0 +1,26 @@ +package imageversions + +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 ImageVersionsClient struct { + Client *resourcemanager.Client +} + +func NewImageVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ImageVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "imageversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ImageVersionsClient: %+v", err) + } + + return &ImageVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image.go new file mode 100644 index 00000000000..3718f59644a --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image.go @@ -0,0 +1,130 @@ +package imageversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ImageId{}) +} + +var _ resourceids.ResourceId = &ImageId{} + +// ImageId is a struct representing the Resource ID for a Image +type ImageId struct { + SubscriptionId string + ResourceGroupName string + ImageName string +} + +// NewImageID returns a new ImageId struct +func NewImageID(subscriptionId string, resourceGroupName string, imageName string) ImageId { + return ImageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ImageName: imageName, + } +} + +// ParseImageID parses 'input' into a ImageId +func ParseImageID(input string) (*ImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&ImageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ImageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseImageIDInsensitively parses 'input' case-insensitively into a ImageId +// note: this method should only be used for API response data and not user input +func ParseImageIDInsensitively(input string) (*ImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&ImageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ImageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ImageId) 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.ImageName, ok = input.Parsed["imageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "imageName", input) + } + + return nil +} + +// ValidateImageID checks that 'input' can be parsed as a Image ID +func ValidateImageID(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 := ParseImageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Image ID +func (id ImageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevOpsInfrastructure/images/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ImageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Image ID +func (id ImageId) 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("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"), + resourceids.StaticSegment("staticImages", "images", "images"), + resourceids.UserSpecifiedSegment("imageName", "imageName"), + } +} + +// String returns a human-readable description of this Image ID +func (id ImageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Image Name: %q", id.ImageName), + } + return fmt.Sprintf("Image (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image_test.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image_test.go new file mode 100644 index 00000000000..c5505f12514 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/id_image_test.go @@ -0,0 +1,282 @@ +package imageversions + +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 = &ImageId{} + +func TestNewImageID(t *testing.T) { + id := NewImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "imageName") + + 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.ImageName != "imageName" { + t.Fatalf("Expected %q but got %q for Segment 'ImageName'", id.ImageName, "imageName") + } +} + +func TestFormatImageID(t *testing.T) { + actual := NewImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "imageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images/imageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseImageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ImageId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images/imageName", + Expected: &ImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ImageName: "imageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images/imageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseImageID(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.ImageName != v.Expected.ImageName { + t.Fatalf("Expected %q but got %q for ImageName", v.Expected.ImageName, actual.ImageName) + } + + } +} + +func TestParseImageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ImageId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/iMaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images/imageName", + Expected: &ImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ImageName: "imageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/images/imageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/iMaGeS/iMaGeNaMe", + Expected: &ImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ImageName: "iMaGeNaMe", + }, + }, + { + // 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.dEvOpSiNfRaStRuCtUrE/iMaGeS/iMaGeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseImageIDInsensitively(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.ImageName != v.Expected.ImageName { + t.Fatalf("Expected %q but got %q for ImageName", v.Expected.ImageName, actual.ImageName) + } + + } +} + +func TestSegmentsForImageId(t *testing.T) { + segments := ImageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ImageId 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/devopsinfrastructure/2024-10-19/imageversions/method_listbyimage.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/method_listbyimage.go new file mode 100644 index 00000000000..34815b734af --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/method_listbyimage.go @@ -0,0 +1,105 @@ +package imageversions + +import ( + "context" + "fmt" + "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 ListByImageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ImageVersion +} + +type ListByImageCompleteResult struct { + LatestHttpResponse *http.Response + Items []ImageVersion +} + +type ListByImageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByImageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByImage ... +func (c ImageVersionsClient) ListByImage(ctx context.Context, id ImageId) (result ListByImageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByImageCustomPager{}, + Path: fmt.Sprintf("%s/versions", 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 *[]ImageVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByImageComplete retrieves all the results into a single object +func (c ImageVersionsClient) ListByImageComplete(ctx context.Context, id ImageId) (ListByImageCompleteResult, error) { + return c.ListByImageCompleteMatchingPredicate(ctx, id, ImageVersionOperationPredicate{}) +} + +// ListByImageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ImageVersionsClient) ListByImageCompleteMatchingPredicate(ctx context.Context, id ImageId, predicate ImageVersionOperationPredicate) (result ListByImageCompleteResult, err error) { + items := make([]ImageVersion, 0) + + resp, err := c.ListByImage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByImageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversion.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversion.go new file mode 100644 index 00000000000..9080d66706e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversion.go @@ -0,0 +1,16 @@ +package imageversions + +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 ImageVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ImageVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversionproperties.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversionproperties.go new file mode 100644 index 00000000000..1f97bd37b50 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/model_imageversionproperties.go @@ -0,0 +1,8 @@ +package imageversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageVersionProperties struct { + Version string `json:"version"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/imageversions/predicates.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/predicates.go new file mode 100644 index 00000000000..4744837f5f3 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/predicates.go @@ -0,0 +1,27 @@ +package imageversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ImageVersionOperationPredicate) Matches(input ImageVersion) 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/devopsinfrastructure/2024-10-19/imageversions/version.go b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/version.go new file mode 100644 index 00000000000..6d7766790b0 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/imageversions/version.go @@ -0,0 +1,10 @@ +package imageversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-19" + +func userAgent() string { + return "hashicorp/go-azure-sdk/imageversions/2024-10-19" +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/README.md b/resource-manager/devopsinfrastructure/2024-10-19/pools/README.md new file mode 100644 index 00000000000..3fd1ec923aa --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/pools` Documentation + +The `pools` SDK allows for interaction with Azure Resource Manager `devopsinfrastructure` (API Version `2024-10-19`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/pools" +``` + + +### Client Initialization + +```go +client := pools.NewPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PoolsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := pools.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + +payload := pools.Pool{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PoolsClient.Delete` + +```go +ctx := context.TODO() +id := pools.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PoolsClient.Get` + +```go +ctx := context.TODO() +id := pools.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + +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: `PoolsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PoolsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PoolsClient.Update` + +```go +ctx := context.TODO() +id := pools.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + +payload := pools.PoolUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/client.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/client.go new file mode 100644 index 00000000000..5860764dffe --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/client.go @@ -0,0 +1,26 @@ +package pools + +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 PoolsClient struct { + Client *resourcemanager.Client +} + +func NewPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*PoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "pools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PoolsClient: %+v", err) + } + + return &PoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/constants.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/constants.go new file mode 100644 index 00000000000..e311ee19900 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/constants.go @@ -0,0 +1,380 @@ +package pools + +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 AzureDevOpsPermissionType string + +const ( + AzureDevOpsPermissionTypeCreatorOnly AzureDevOpsPermissionType = "CreatorOnly" + AzureDevOpsPermissionTypeInherit AzureDevOpsPermissionType = "Inherit" + AzureDevOpsPermissionTypeSpecificAccounts AzureDevOpsPermissionType = "SpecificAccounts" +) + +func PossibleValuesForAzureDevOpsPermissionType() []string { + return []string{ + string(AzureDevOpsPermissionTypeCreatorOnly), + string(AzureDevOpsPermissionTypeInherit), + string(AzureDevOpsPermissionTypeSpecificAccounts), + } +} + +func (s *AzureDevOpsPermissionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureDevOpsPermissionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureDevOpsPermissionType(input string) (*AzureDevOpsPermissionType, error) { + vals := map[string]AzureDevOpsPermissionType{ + "creatoronly": AzureDevOpsPermissionTypeCreatorOnly, + "inherit": AzureDevOpsPermissionTypeInherit, + "specificaccounts": AzureDevOpsPermissionTypeSpecificAccounts, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureDevOpsPermissionType(input) + return &out, nil +} + +type CachingType string + +const ( + CachingTypeNone CachingType = "None" + CachingTypeReadOnly CachingType = "ReadOnly" + CachingTypeReadWrite CachingType = "ReadWrite" +) + +func PossibleValuesForCachingType() []string { + return []string{ + string(CachingTypeNone), + string(CachingTypeReadOnly), + string(CachingTypeReadWrite), + } +} + +func (s *CachingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCachingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCachingType(input string) (*CachingType, error) { + vals := map[string]CachingType{ + "none": CachingTypeNone, + "readonly": CachingTypeReadOnly, + "readwrite": CachingTypeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CachingType(input) + return &out, nil +} + +type LogonType string + +const ( + LogonTypeInteractive LogonType = "Interactive" + LogonTypeService LogonType = "Service" +) + +func PossibleValuesForLogonType() []string { + return []string{ + string(LogonTypeInteractive), + string(LogonTypeService), + } +} + +func (s *LogonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogonType(input string) (*LogonType, error) { + vals := map[string]LogonType{ + "interactive": LogonTypeInteractive, + "service": LogonTypeService, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogonType(input) + return &out, nil +} + +type OsDiskStorageAccountType string + +const ( + OsDiskStorageAccountTypePremium OsDiskStorageAccountType = "Premium" + OsDiskStorageAccountTypeStandard OsDiskStorageAccountType = "Standard" + OsDiskStorageAccountTypeStandardSSD OsDiskStorageAccountType = "StandardSSD" +) + +func PossibleValuesForOsDiskStorageAccountType() []string { + return []string{ + string(OsDiskStorageAccountTypePremium), + string(OsDiskStorageAccountTypeStandard), + string(OsDiskStorageAccountTypeStandardSSD), + } +} + +func (s *OsDiskStorageAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsDiskStorageAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOsDiskStorageAccountType(input string) (*OsDiskStorageAccountType, error) { + vals := map[string]OsDiskStorageAccountType{ + "premium": OsDiskStorageAccountTypePremium, + "standard": OsDiskStorageAccountTypeStandard, + "standardssd": OsDiskStorageAccountTypeStandardSSD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OsDiskStorageAccountType(input) + return &out, nil +} + +type PredictionPreference string + +const ( + PredictionPreferenceBalanced PredictionPreference = "Balanced" + PredictionPreferenceBestPerformance PredictionPreference = "BestPerformance" + PredictionPreferenceMoreCostEffective PredictionPreference = "MoreCostEffective" + PredictionPreferenceMorePerformance PredictionPreference = "MorePerformance" + PredictionPreferenceMostCostEffective PredictionPreference = "MostCostEffective" +) + +func PossibleValuesForPredictionPreference() []string { + return []string{ + string(PredictionPreferenceBalanced), + string(PredictionPreferenceBestPerformance), + string(PredictionPreferenceMoreCostEffective), + string(PredictionPreferenceMorePerformance), + string(PredictionPreferenceMostCostEffective), + } +} + +func (s *PredictionPreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePredictionPreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePredictionPreference(input string) (*PredictionPreference, error) { + vals := map[string]PredictionPreference{ + "balanced": PredictionPreferenceBalanced, + "bestperformance": PredictionPreferenceBestPerformance, + "morecosteffective": PredictionPreferenceMoreCostEffective, + "moreperformance": PredictionPreferenceMorePerformance, + "mostcosteffective": PredictionPreferenceMostCostEffective, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PredictionPreference(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourcePredictionsProfileType string + +const ( + ResourcePredictionsProfileTypeAutomatic ResourcePredictionsProfileType = "Automatic" + ResourcePredictionsProfileTypeManual ResourcePredictionsProfileType = "Manual" +) + +func PossibleValuesForResourcePredictionsProfileType() []string { + return []string{ + string(ResourcePredictionsProfileTypeAutomatic), + string(ResourcePredictionsProfileTypeManual), + } +} + +func (s *ResourcePredictionsProfileType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourcePredictionsProfileType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourcePredictionsProfileType(input string) (*ResourcePredictionsProfileType, error) { + vals := map[string]ResourcePredictionsProfileType{ + "automatic": ResourcePredictionsProfileTypeAutomatic, + "manual": ResourcePredictionsProfileTypeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourcePredictionsProfileType(input) + return &out, nil +} + +type StorageAccountType string + +const ( + StorageAccountTypePremiumLRS StorageAccountType = "Premium_LRS" + StorageAccountTypePremiumZRS StorageAccountType = "Premium_ZRS" + StorageAccountTypeStandardLRS StorageAccountType = "Standard_LRS" + StorageAccountTypeStandardSSDLRS StorageAccountType = "StandardSSD_LRS" + StorageAccountTypeStandardSSDZRS StorageAccountType = "StandardSSD_ZRS" +) + +func PossibleValuesForStorageAccountType() []string { + return []string{ + string(StorageAccountTypePremiumLRS), + string(StorageAccountTypePremiumZRS), + string(StorageAccountTypeStandardLRS), + string(StorageAccountTypeStandardSSDLRS), + string(StorageAccountTypeStandardSSDZRS), + } +} + +func (s *StorageAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAccountType(input string) (*StorageAccountType, error) { + vals := map[string]StorageAccountType{ + "premium_lrs": StorageAccountTypePremiumLRS, + "premium_zrs": StorageAccountTypePremiumZRS, + "standard_lrs": StorageAccountTypeStandardLRS, + "standardssd_lrs": StorageAccountTypeStandardSSDLRS, + "standardssd_zrs": StorageAccountTypeStandardSSDZRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAccountType(input) + return &out, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool.go new file mode 100644 index 00000000000..bc3f8dd26ad --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool.go @@ -0,0 +1,130 @@ +package pools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PoolId{}) +} + +var _ resourceids.ResourceId = &PoolId{} + +// PoolId is a struct representing the Resource ID for a Pool +type PoolId struct { + SubscriptionId string + ResourceGroupName string + PoolName string +} + +// NewPoolID returns a new PoolId struct +func NewPoolID(subscriptionId string, resourceGroupName string, poolName string) PoolId { + return PoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PoolName: poolName, + } +} + +// ParsePoolID parses 'input' into a PoolId +func ParsePoolID(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePoolIDInsensitively parses 'input' case-insensitively into a PoolId +// note: this method should only be used for API response data and not user input +func ParsePoolIDInsensitively(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PoolId) 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.PoolName, ok = input.Parsed["poolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "poolName", input) + } + + return nil +} + +// ValidatePoolID checks that 'input' can be parsed as a Pool ID +func ValidatePoolID(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 := ParsePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Pool ID +func (id PoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevOpsInfrastructure/pools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Pool ID +func (id PoolId) 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("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"), + resourceids.StaticSegment("staticPools", "pools", "pools"), + resourceids.UserSpecifiedSegment("poolName", "poolName"), + } +} + +// String returns a human-readable description of this Pool ID +func (id PoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Pool Name: %q", id.PoolName), + } + return fmt.Sprintf("Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool_test.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool_test.go new file mode 100644 index 00000000000..18d34ed807c --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/id_pool_test.go @@ -0,0 +1,282 @@ +package pools + +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 = &PoolId{} + +func TestNewPoolID(t *testing.T) { + id := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + + 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.PoolName != "poolName" { + t.Fatalf("Expected %q but got %q for Segment 'PoolName'", id.PoolName, "poolName") + } +} + +func TestFormatPoolID(t *testing.T) { + actual := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PoolName: "poolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolID(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.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestParsePoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/pOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PoolName: "poolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/pOoLs/pOoLnAmE", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PoolName: "pOoLnAmE", + }, + }, + { + // 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.dEvOpSiNfRaStRuCtUrE/pOoLs/pOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolIDInsensitively(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.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestSegmentsForPoolId(t *testing.T) { + segments := PoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PoolId 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/devopsinfrastructure/2024-10-19/pools/method_createorupdate.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_createorupdate.go new file mode 100644 index 00000000000..6017e9f5eab --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_createorupdate.go @@ -0,0 +1,75 @@ +package pools + +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 + Model *Pool +} + +// CreateOrUpdate ... +func (c PoolsClient) CreateOrUpdate(ctx context.Context, id PoolId, input Pool) (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 PoolsClient) CreateOrUpdateThenPoll(ctx context.Context, id PoolId, input Pool) 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/devopsinfrastructure/2024-10-19/pools/method_delete.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_delete.go new file mode 100644 index 00000000000..deed72618de --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_delete.go @@ -0,0 +1,70 @@ +package pools + +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 PoolsClient) Delete(ctx context.Context, id PoolId) (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 PoolsClient) DeleteThenPoll(ctx context.Context, id PoolId) 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/devopsinfrastructure/2024-10-19/pools/method_get.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_get.go new file mode 100644 index 00000000000..8947bf1c25f --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_get.go @@ -0,0 +1,53 @@ +package pools + +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 *Pool +} + +// Get ... +func (c PoolsClient) Get(ctx context.Context, id PoolId) (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 + } + + var model Pool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbyresourcegroup.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3f040edc555 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package pools + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Pool +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Pool +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c PoolsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DevOpsInfrastructure/pools", 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 *[]Pool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c PoolsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, PoolOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PoolsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PoolOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Pool, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbysubscription.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbysubscription.go new file mode 100644 index 00000000000..131eac5670e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_listbysubscription.go @@ -0,0 +1,106 @@ +package pools + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Pool +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Pool +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c PoolsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DevOpsInfrastructure/pools", 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 *[]Pool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c PoolsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, PoolOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PoolsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PoolOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Pool, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/method_update.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_update.go new file mode 100644 index 00000000000..3bec7d745bc --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/method_update.go @@ -0,0 +1,75 @@ +package pools + +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 + Model *Pool +} + +// Update ... +func (c PoolsClient) Update(ctx context.Context, id PoolId, input PoolUpdate) (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 PoolsClient) UpdateThenPoll(ctx context.Context, id PoolId, input PoolUpdate) 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/devopsinfrastructure/2024-10-19/pools/model_agentprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_agentprofile.go new file mode 100644 index 00000000000..3daf4624465 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_agentprofile.go @@ -0,0 +1,115 @@ +package pools + +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 AgentProfile interface { + AgentProfile() BaseAgentProfileImpl +} + +var _ AgentProfile = BaseAgentProfileImpl{} + +type BaseAgentProfileImpl struct { + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + ResourcePredictionsProfile ResourcePredictionsProfile `json:"resourcePredictionsProfile"` +} + +func (s BaseAgentProfileImpl) AgentProfile() BaseAgentProfileImpl { + return s +} + +var _ AgentProfile = RawAgentProfileImpl{} + +// RawAgentProfileImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawAgentProfileImpl struct { + agentProfile BaseAgentProfileImpl + Type string + Values map[string]interface{} +} + +func (s RawAgentProfileImpl) AgentProfile() BaseAgentProfileImpl { + return s.agentProfile +} + +var _ json.Unmarshaler = &BaseAgentProfileImpl{} + +func (s *BaseAgentProfileImpl) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Kind = decoded.Kind + s.ResourcePredictions = decoded.ResourcePredictions + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseAgentProfileImpl into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourcePredictionsProfile"]; ok { + impl, err := UnmarshalResourcePredictionsProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourcePredictionsProfile' for 'BaseAgentProfileImpl': %+v", err) + } + s.ResourcePredictionsProfile = impl + } + + return nil +} + +func UnmarshalAgentProfileImplementation(input []byte) (AgentProfile, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling AgentProfile into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Stateful") { + var out Stateful + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Stateful: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Stateless") { + var out StatelessAgentProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StatelessAgentProfile: %+v", err) + } + return out, nil + } + + var parent BaseAgentProfileImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAgentProfileImpl: %+v", err) + } + + return RawAgentProfileImpl{ + agentProfile: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_automaticresourcepredictionsprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_automaticresourcepredictionsprofile.go new file mode 100644 index 00000000000..aadf94c6367 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_automaticresourcepredictionsprofile.go @@ -0,0 +1,50 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResourcePredictionsProfile = AutomaticResourcePredictionsProfile{} + +type AutomaticResourcePredictionsProfile struct { + PredictionPreference *PredictionPreference `json:"predictionPreference,omitempty"` + + // Fields inherited from ResourcePredictionsProfile + + Kind ResourcePredictionsProfileType `json:"kind"` +} + +func (s AutomaticResourcePredictionsProfile) ResourcePredictionsProfile() BaseResourcePredictionsProfileImpl { + return BaseResourcePredictionsProfileImpl{ + Kind: s.Kind, + } +} + +var _ json.Marshaler = AutomaticResourcePredictionsProfile{} + +func (s AutomaticResourcePredictionsProfile) MarshalJSON() ([]byte, error) { + type wrapper AutomaticResourcePredictionsProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomaticResourcePredictionsProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomaticResourcePredictionsProfile: %+v", err) + } + + decoded["kind"] = "Automatic" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomaticResourcePredictionsProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopsorganizationprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopsorganizationprofile.go new file mode 100644 index 00000000000..8bfb7d68d9e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopsorganizationprofile.go @@ -0,0 +1,51 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OrganizationProfile = AzureDevOpsOrganizationProfile{} + +type AzureDevOpsOrganizationProfile struct { + Organizations []Organization `json:"organizations"` + PermissionProfile *AzureDevOpsPermissionProfile `json:"permissionProfile,omitempty"` + + // Fields inherited from OrganizationProfile + + Kind string `json:"kind"` +} + +func (s AzureDevOpsOrganizationProfile) OrganizationProfile() BaseOrganizationProfileImpl { + return BaseOrganizationProfileImpl{ + Kind: s.Kind, + } +} + +var _ json.Marshaler = AzureDevOpsOrganizationProfile{} + +func (s AzureDevOpsOrganizationProfile) MarshalJSON() ([]byte, error) { + type wrapper AzureDevOpsOrganizationProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDevOpsOrganizationProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDevOpsOrganizationProfile: %+v", err) + } + + decoded["kind"] = "AzureDevOps" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDevOpsOrganizationProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopspermissionprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopspermissionprofile.go new file mode 100644 index 00000000000..8f6cb8a42d8 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_azuredevopspermissionprofile.go @@ -0,0 +1,10 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureDevOpsPermissionProfile struct { + Groups *[]string `json:"groups,omitempty"` + Kind AzureDevOpsPermissionType `json:"kind"` + Users *[]string `json:"users,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_datadisk.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_datadisk.go new file mode 100644 index 00000000000..d7e570a9c31 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_datadisk.go @@ -0,0 +1,11 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataDisk struct { + Caching *CachingType `json:"caching,omitempty"` + DiskSizeGiB *int64 `json:"diskSizeGiB,omitempty"` + DriveLetter *string `json:"driveLetter,omitempty"` + StorageAccountType *StorageAccountType `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_devopsazuresku.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_devopsazuresku.go new file mode 100644 index 00000000000..0fff7500dd0 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_devopsazuresku.go @@ -0,0 +1,8 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DevOpsAzureSku struct { + Name string `json:"name"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_fabricprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_fabricprofile.go new file mode 100644 index 00000000000..844ef602fbf --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_fabricprofile.go @@ -0,0 +1,75 @@ +package pools + +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 FabricProfile interface { + FabricProfile() BaseFabricProfileImpl +} + +var _ FabricProfile = BaseFabricProfileImpl{} + +type BaseFabricProfileImpl struct { + Kind string `json:"kind"` +} + +func (s BaseFabricProfileImpl) FabricProfile() BaseFabricProfileImpl { + return s +} + +var _ FabricProfile = RawFabricProfileImpl{} + +// RawFabricProfileImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFabricProfileImpl struct { + fabricProfile BaseFabricProfileImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricProfileImpl) FabricProfile() BaseFabricProfileImpl { + return s.fabricProfile +} + +func UnmarshalFabricProfileImplementation(input []byte) (FabricProfile, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling FabricProfile into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Vmss") { + var out VMSSFabricProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMSSFabricProfile: %+v", err) + } + return out, nil + } + + var parent BaseFabricProfileImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricProfileImpl: %+v", err) + } + + return RawFabricProfileImpl{ + fabricProfile: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganization.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganization.go new file mode 100644 index 00000000000..ebeb8c98da5 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganization.go @@ -0,0 +1,9 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubOrganization struct { + Repositories *[]string `json:"repositories,omitempty"` + Url string `json:"url"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganizationprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganizationprofile.go new file mode 100644 index 00000000000..849a5ed4077 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_githuborganizationprofile.go @@ -0,0 +1,50 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OrganizationProfile = GitHubOrganizationProfile{} + +type GitHubOrganizationProfile struct { + Organizations []GitHubOrganization `json:"organizations"` + + // Fields inherited from OrganizationProfile + + Kind string `json:"kind"` +} + +func (s GitHubOrganizationProfile) OrganizationProfile() BaseOrganizationProfileImpl { + return BaseOrganizationProfileImpl{ + Kind: s.Kind, + } +} + +var _ json.Marshaler = GitHubOrganizationProfile{} + +func (s GitHubOrganizationProfile) MarshalJSON() ([]byte, error) { + type wrapper GitHubOrganizationProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GitHubOrganizationProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GitHubOrganizationProfile: %+v", err) + } + + decoded["kind"] = "GitHub" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GitHubOrganizationProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_manualresourcepredictionsprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_manualresourcepredictionsprofile.go new file mode 100644 index 00000000000..bdc0efb37ef --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_manualresourcepredictionsprofile.go @@ -0,0 +1,49 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResourcePredictionsProfile = ManualResourcePredictionsProfile{} + +type ManualResourcePredictionsProfile struct { + + // Fields inherited from ResourcePredictionsProfile + + Kind ResourcePredictionsProfileType `json:"kind"` +} + +func (s ManualResourcePredictionsProfile) ResourcePredictionsProfile() BaseResourcePredictionsProfileImpl { + return BaseResourcePredictionsProfileImpl{ + Kind: s.Kind, + } +} + +var _ json.Marshaler = ManualResourcePredictionsProfile{} + +func (s ManualResourcePredictionsProfile) MarshalJSON() ([]byte, error) { + type wrapper ManualResourcePredictionsProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManualResourcePredictionsProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManualResourcePredictionsProfile: %+v", err) + } + + decoded["kind"] = "Manual" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManualResourcePredictionsProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_networkprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_networkprofile.go new file mode 100644 index 00000000000..8ecd0977e60 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_networkprofile.go @@ -0,0 +1,8 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfile struct { + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organization.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organization.go new file mode 100644 index 00000000000..9f2517e48f7 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organization.go @@ -0,0 +1,10 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Organization struct { + Parallelism *int64 `json:"parallelism,omitempty"` + Projects *[]string `json:"projects,omitempty"` + Url string `json:"url"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organizationprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organizationprofile.go new file mode 100644 index 00000000000..3bcdfbab920 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_organizationprofile.go @@ -0,0 +1,83 @@ +package pools + +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 OrganizationProfile interface { + OrganizationProfile() BaseOrganizationProfileImpl +} + +var _ OrganizationProfile = BaseOrganizationProfileImpl{} + +type BaseOrganizationProfileImpl struct { + Kind string `json:"kind"` +} + +func (s BaseOrganizationProfileImpl) OrganizationProfile() BaseOrganizationProfileImpl { + return s +} + +var _ OrganizationProfile = RawOrganizationProfileImpl{} + +// RawOrganizationProfileImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawOrganizationProfileImpl struct { + organizationProfile BaseOrganizationProfileImpl + Type string + Values map[string]interface{} +} + +func (s RawOrganizationProfileImpl) OrganizationProfile() BaseOrganizationProfileImpl { + return s.organizationProfile +} + +func UnmarshalOrganizationProfileImplementation(input []byte) (OrganizationProfile, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling OrganizationProfile into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureDevOps") { + var out AzureDevOpsOrganizationProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDevOpsOrganizationProfile: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GitHub") { + var out GitHubOrganizationProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GitHubOrganizationProfile: %+v", err) + } + return out, nil + } + + var parent BaseOrganizationProfileImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOrganizationProfileImpl: %+v", err) + } + + return RawOrganizationProfileImpl{ + organizationProfile: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_osprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_osprofile.go new file mode 100644 index 00000000000..6e9f8503ad0 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_osprofile.go @@ -0,0 +1,9 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsProfile struct { + LogonType *LogonType `json:"logonType,omitempty"` + SecretsManagementSettings *SecretsManagementSettings `json:"secretsManagementSettings,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_pool.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_pool.go new file mode 100644 index 00000000000..bc8e20ffc98 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_pool.go @@ -0,0 +1,20 @@ +package pools + +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 Pool struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *PoolProperties `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/devopsinfrastructure/2024-10-19/pools/model_poolimage.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolimage.go new file mode 100644 index 00000000000..3a80c669b43 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolimage.go @@ -0,0 +1,11 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolImage struct { + Aliases *[]string `json:"aliases,omitempty"` + Buffer *string `json:"buffer,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WellKnownImageName *string `json:"wellKnownImageName,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolproperties.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolproperties.go new file mode 100644 index 00000000000..b68954ce942 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolproperties.go @@ -0,0 +1,66 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolProperties struct { + AgentProfile AgentProfile `json:"agentProfile"` + DevCenterProjectResourceId string `json:"devCenterProjectResourceId"` + FabricProfile FabricProfile `json:"fabricProfile"` + MaximumConcurrency int64 `json:"maximumConcurrency"` + OrganizationProfile OrganizationProfile `json:"organizationProfile"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Unmarshaler = &PoolProperties{} + +func (s *PoolProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DevCenterProjectResourceId string `json:"devCenterProjectResourceId"` + MaximumConcurrency int64 `json:"maximumConcurrency"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DevCenterProjectResourceId = decoded.DevCenterProjectResourceId + s.MaximumConcurrency = decoded.MaximumConcurrency + s.ProvisioningState = decoded.ProvisioningState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PoolProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["agentProfile"]; ok { + impl, err := UnmarshalAgentProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'AgentProfile' for 'PoolProperties': %+v", err) + } + s.AgentProfile = impl + } + + if v, ok := temp["fabricProfile"]; ok { + impl, err := UnmarshalFabricProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricProfile' for 'PoolProperties': %+v", err) + } + s.FabricProfile = impl + } + + if v, ok := temp["organizationProfile"]; ok { + impl, err := UnmarshalOrganizationProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'OrganizationProfile' for 'PoolProperties': %+v", err) + } + s.OrganizationProfile = impl + } + + return nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdate.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdate.go new file mode 100644 index 00000000000..596e730feb1 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdate.go @@ -0,0 +1,14 @@ +package pools + +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 PoolUpdate struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *PoolUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdateproperties.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdateproperties.go new file mode 100644 index 00000000000..8c77964fc72 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_poolupdateproperties.go @@ -0,0 +1,66 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolUpdateProperties struct { + AgentProfile AgentProfile `json:"agentProfile"` + DevCenterProjectResourceId *string `json:"devCenterProjectResourceId,omitempty"` + FabricProfile FabricProfile `json:"fabricProfile"` + MaximumConcurrency *int64 `json:"maximumConcurrency,omitempty"` + OrganizationProfile OrganizationProfile `json:"organizationProfile"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Unmarshaler = &PoolUpdateProperties{} + +func (s *PoolUpdateProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DevCenterProjectResourceId *string `json:"devCenterProjectResourceId,omitempty"` + MaximumConcurrency *int64 `json:"maximumConcurrency,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DevCenterProjectResourceId = decoded.DevCenterProjectResourceId + s.MaximumConcurrency = decoded.MaximumConcurrency + s.ProvisioningState = decoded.ProvisioningState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PoolUpdateProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["agentProfile"]; ok { + impl, err := UnmarshalAgentProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'AgentProfile' for 'PoolUpdateProperties': %+v", err) + } + s.AgentProfile = impl + } + + if v, ok := temp["fabricProfile"]; ok { + impl, err := UnmarshalFabricProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricProfile' for 'PoolUpdateProperties': %+v", err) + } + s.FabricProfile = impl + } + + if v, ok := temp["organizationProfile"]; ok { + impl, err := UnmarshalOrganizationProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'OrganizationProfile' for 'PoolUpdateProperties': %+v", err) + } + s.OrganizationProfile = impl + } + + return nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_resourcepredictionsprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_resourcepredictionsprofile.go new file mode 100644 index 00000000000..4a55ded929e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_resourcepredictionsprofile.go @@ -0,0 +1,83 @@ +package pools + +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 ResourcePredictionsProfile interface { + ResourcePredictionsProfile() BaseResourcePredictionsProfileImpl +} + +var _ ResourcePredictionsProfile = BaseResourcePredictionsProfileImpl{} + +type BaseResourcePredictionsProfileImpl struct { + Kind ResourcePredictionsProfileType `json:"kind"` +} + +func (s BaseResourcePredictionsProfileImpl) ResourcePredictionsProfile() BaseResourcePredictionsProfileImpl { + return s +} + +var _ ResourcePredictionsProfile = RawResourcePredictionsProfileImpl{} + +// RawResourcePredictionsProfileImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawResourcePredictionsProfileImpl struct { + resourcePredictionsProfile BaseResourcePredictionsProfileImpl + Type string + Values map[string]interface{} +} + +func (s RawResourcePredictionsProfileImpl) ResourcePredictionsProfile() BaseResourcePredictionsProfileImpl { + return s.resourcePredictionsProfile +} + +func UnmarshalResourcePredictionsProfileImplementation(input []byte) (ResourcePredictionsProfile, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ResourcePredictionsProfile into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Automatic") { + var out AutomaticResourcePredictionsProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomaticResourcePredictionsProfile: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Manual") { + var out ManualResourcePredictionsProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManualResourcePredictionsProfile: %+v", err) + } + return out, nil + } + + var parent BaseResourcePredictionsProfileImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResourcePredictionsProfileImpl: %+v", err) + } + + return RawResourcePredictionsProfileImpl{ + resourcePredictionsProfile: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_secretsmanagementsettings.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_secretsmanagementsettings.go new file mode 100644 index 00000000000..27d0fef3d0f --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_secretsmanagementsettings.go @@ -0,0 +1,10 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretsManagementSettings struct { + CertificateStoreLocation *string `json:"certificateStoreLocation,omitempty"` + KeyExportable bool `json:"keyExportable"` + ObservedCertificates []string `json:"observedCertificates"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_stateful.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_stateful.go new file mode 100644 index 00000000000..4ae92b79ac9 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_stateful.go @@ -0,0 +1,89 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AgentProfile = Stateful{} + +type Stateful struct { + GracePeriodTimeSpan *string `json:"gracePeriodTimeSpan,omitempty"` + MaxAgentLifetime *string `json:"maxAgentLifetime,omitempty"` + + // Fields inherited from AgentProfile + + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + ResourcePredictionsProfile ResourcePredictionsProfile `json:"resourcePredictionsProfile"` +} + +func (s Stateful) AgentProfile() BaseAgentProfileImpl { + return BaseAgentProfileImpl{ + Kind: s.Kind, + ResourcePredictions: s.ResourcePredictions, + ResourcePredictionsProfile: s.ResourcePredictionsProfile, + } +} + +var _ json.Marshaler = Stateful{} + +func (s Stateful) MarshalJSON() ([]byte, error) { + type wrapper Stateful + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Stateful: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Stateful: %+v", err) + } + + decoded["kind"] = "Stateful" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Stateful: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Stateful{} + +func (s *Stateful) UnmarshalJSON(bytes []byte) error { + var decoded struct { + GracePeriodTimeSpan *string `json:"gracePeriodTimeSpan,omitempty"` + MaxAgentLifetime *string `json:"maxAgentLifetime,omitempty"` + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.GracePeriodTimeSpan = decoded.GracePeriodTimeSpan + s.MaxAgentLifetime = decoded.MaxAgentLifetime + s.Kind = decoded.Kind + s.ResourcePredictions = decoded.ResourcePredictions + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Stateful into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourcePredictionsProfile"]; ok { + impl, err := UnmarshalResourcePredictionsProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourcePredictionsProfile' for 'Stateful': %+v", err) + } + s.ResourcePredictionsProfile = impl + } + + return nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_statelessagentprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_statelessagentprofile.go new file mode 100644 index 00000000000..c28ed9ba169 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_statelessagentprofile.go @@ -0,0 +1,83 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AgentProfile = StatelessAgentProfile{} + +type StatelessAgentProfile struct { + + // Fields inherited from AgentProfile + + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + ResourcePredictionsProfile ResourcePredictionsProfile `json:"resourcePredictionsProfile"` +} + +func (s StatelessAgentProfile) AgentProfile() BaseAgentProfileImpl { + return BaseAgentProfileImpl{ + Kind: s.Kind, + ResourcePredictions: s.ResourcePredictions, + ResourcePredictionsProfile: s.ResourcePredictionsProfile, + } +} + +var _ json.Marshaler = StatelessAgentProfile{} + +func (s StatelessAgentProfile) MarshalJSON() ([]byte, error) { + type wrapper StatelessAgentProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StatelessAgentProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StatelessAgentProfile: %+v", err) + } + + decoded["kind"] = "Stateless" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StatelessAgentProfile: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &StatelessAgentProfile{} + +func (s *StatelessAgentProfile) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Kind string `json:"kind"` + ResourcePredictions *interface{} `json:"resourcePredictions,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Kind = decoded.Kind + s.ResourcePredictions = decoded.ResourcePredictions + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StatelessAgentProfile into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourcePredictionsProfile"]; ok { + impl, err := UnmarshalResourcePredictionsProfileImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourcePredictionsProfile' for 'StatelessAgentProfile': %+v", err) + } + s.ResourcePredictionsProfile = impl + } + + return nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_storageprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_storageprofile.go new file mode 100644 index 00000000000..327c32aec0f --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_storageprofile.go @@ -0,0 +1,9 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageProfile struct { + DataDisks *[]DataDisk `json:"dataDisks,omitempty"` + OsDiskStorageAccountType *OsDiskStorageAccountType `json:"osDiskStorageAccountType,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/model_vmssfabricprofile.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_vmssfabricprofile.go new file mode 100644 index 00000000000..7dbc8973ac9 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/model_vmssfabricprofile.go @@ -0,0 +1,54 @@ +package pools + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricProfile = VMSSFabricProfile{} + +type VMSSFabricProfile struct { + Images []PoolImage `json:"images"` + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + OsProfile *OsProfile `json:"osProfile,omitempty"` + Sku DevOpsAzureSku `json:"sku"` + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` + + // Fields inherited from FabricProfile + + Kind string `json:"kind"` +} + +func (s VMSSFabricProfile) FabricProfile() BaseFabricProfileImpl { + return BaseFabricProfileImpl{ + Kind: s.Kind, + } +} + +var _ json.Marshaler = VMSSFabricProfile{} + +func (s VMSSFabricProfile) MarshalJSON() ([]byte, error) { + type wrapper VMSSFabricProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMSSFabricProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMSSFabricProfile: %+v", err) + } + + decoded["kind"] = "Vmss" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMSSFabricProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/pools/predicates.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/predicates.go new file mode 100644 index 00000000000..3db83e0643e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/predicates.go @@ -0,0 +1,32 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PoolOperationPredicate) Matches(input Pool) 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/devopsinfrastructure/2024-10-19/pools/version.go b/resource-manager/devopsinfrastructure/2024-10-19/pools/version.go new file mode 100644 index 00000000000..515d4c43b65 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/pools/version.go @@ -0,0 +1,10 @@ +package pools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-19" + +func userAgent() string { + return "hashicorp/go-azure-sdk/pools/2024-10-19" +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/README.md b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/README.md new file mode 100644 index 00000000000..2b0e6d3f1c4 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails` Documentation + +The `resourcedetails` SDK allows for interaction with Azure Resource Manager `devopsinfrastructure` (API Version `2024-10-19`). + +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/devopsinfrastructure/2024-10-19/resourcedetails" +``` + + +### Client Initialization + +```go +client := resourcedetails.NewResourceDetailsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceDetailsClient.ListByPool` + +```go +ctx := context.TODO() +id := resourcedetails.NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + +// alternatively `client.ListByPool(ctx, id)` can be used to do batched pagination +items, err := client.ListByPoolComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/client.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/client.go new file mode 100644 index 00000000000..5b0006bf4e6 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/client.go @@ -0,0 +1,26 @@ +package resourcedetails + +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 ResourceDetailsClient struct { + Client *resourcemanager.Client +} + +func NewResourceDetailsClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceDetailsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resourcedetails", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceDetailsClient: %+v", err) + } + + return &ResourceDetailsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/constants.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/constants.go new file mode 100644 index 00000000000..e2a8101d4b1 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/constants.go @@ -0,0 +1,78 @@ +package resourcedetails + +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 ResourceStatus string + +const ( + ResourceStatusAllocated ResourceStatus = "Allocated" + ResourceStatusLeased ResourceStatus = "Leased" + ResourceStatusNotReady ResourceStatus = "NotReady" + ResourceStatusPendingReimage ResourceStatus = "PendingReimage" + ResourceStatusPendingReturn ResourceStatus = "PendingReturn" + ResourceStatusProvisioning ResourceStatus = "Provisioning" + ResourceStatusReady ResourceStatus = "Ready" + ResourceStatusReimaging ResourceStatus = "Reimaging" + ResourceStatusReturned ResourceStatus = "Returned" + ResourceStatusStarting ResourceStatus = "Starting" + ResourceStatusUpdating ResourceStatus = "Updating" +) + +func PossibleValuesForResourceStatus() []string { + return []string{ + string(ResourceStatusAllocated), + string(ResourceStatusLeased), + string(ResourceStatusNotReady), + string(ResourceStatusPendingReimage), + string(ResourceStatusPendingReturn), + string(ResourceStatusProvisioning), + string(ResourceStatusReady), + string(ResourceStatusReimaging), + string(ResourceStatusReturned), + string(ResourceStatusStarting), + string(ResourceStatusUpdating), + } +} + +func (s *ResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceStatus(input string) (*ResourceStatus, error) { + vals := map[string]ResourceStatus{ + "allocated": ResourceStatusAllocated, + "leased": ResourceStatusLeased, + "notready": ResourceStatusNotReady, + "pendingreimage": ResourceStatusPendingReimage, + "pendingreturn": ResourceStatusPendingReturn, + "provisioning": ResourceStatusProvisioning, + "ready": ResourceStatusReady, + "reimaging": ResourceStatusReimaging, + "returned": ResourceStatusReturned, + "starting": ResourceStatusStarting, + "updating": ResourceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceStatus(input) + return &out, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool.go new file mode 100644 index 00000000000..083fad90987 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool.go @@ -0,0 +1,130 @@ +package resourcedetails + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PoolId{}) +} + +var _ resourceids.ResourceId = &PoolId{} + +// PoolId is a struct representing the Resource ID for a Pool +type PoolId struct { + SubscriptionId string + ResourceGroupName string + PoolName string +} + +// NewPoolID returns a new PoolId struct +func NewPoolID(subscriptionId string, resourceGroupName string, poolName string) PoolId { + return PoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PoolName: poolName, + } +} + +// ParsePoolID parses 'input' into a PoolId +func ParsePoolID(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePoolIDInsensitively parses 'input' case-insensitively into a PoolId +// note: this method should only be used for API response data and not user input +func ParsePoolIDInsensitively(input string) (*PoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&PoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PoolId) 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.PoolName, ok = input.Parsed["poolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "poolName", input) + } + + return nil +} + +// ValidatePoolID checks that 'input' can be parsed as a Pool ID +func ValidatePoolID(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 := ParsePoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Pool ID +func (id PoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevOpsInfrastructure/pools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Pool ID +func (id PoolId) 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("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"), + resourceids.StaticSegment("staticPools", "pools", "pools"), + resourceids.UserSpecifiedSegment("poolName", "poolName"), + } +} + +// String returns a human-readable description of this Pool ID +func (id PoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Pool Name: %q", id.PoolName), + } + return fmt.Sprintf("Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool_test.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool_test.go new file mode 100644 index 00000000000..52302875a8d --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/id_pool_test.go @@ -0,0 +1,282 @@ +package resourcedetails + +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 = &PoolId{} + +func TestNewPoolID(t *testing.T) { + id := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName") + + 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.PoolName != "poolName" { + t.Fatalf("Expected %q but got %q for Segment 'PoolName'", id.PoolName, "poolName") + } +} + +func TestFormatPoolID(t *testing.T) { + actual := NewPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "poolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PoolName: "poolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolID(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.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestParsePoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PoolId + }{ + { + // 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.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/pOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PoolName: "poolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/poolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/pOoLs/pOoLnAmE", + Expected: &PoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PoolName: "pOoLnAmE", + }, + }, + { + // 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.dEvOpSiNfRaStRuCtUrE/pOoLs/pOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePoolIDInsensitively(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.PoolName != v.Expected.PoolName { + t.Fatalf("Expected %q but got %q for PoolName", v.Expected.PoolName, actual.PoolName) + } + + } +} + +func TestSegmentsForPoolId(t *testing.T) { + segments := PoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PoolId 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/devopsinfrastructure/2024-10-19/resourcedetails/method_listbypool.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/method_listbypool.go new file mode 100644 index 00000000000..6330001e75f --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/method_listbypool.go @@ -0,0 +1,105 @@ +package resourcedetails + +import ( + "context" + "fmt" + "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 ListByPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceDetailsObject +} + +type ListByPoolCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceDetailsObject +} + +type ListByPoolCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByPoolCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByPool ... +func (c ResourceDetailsClient) ListByPool(ctx context.Context, id PoolId) (result ListByPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByPoolCustomPager{}, + Path: fmt.Sprintf("%s/resources", 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 *[]ResourceDetailsObject `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByPoolComplete retrieves all the results into a single object +func (c ResourceDetailsClient) ListByPoolComplete(ctx context.Context, id PoolId) (ListByPoolCompleteResult, error) { + return c.ListByPoolCompleteMatchingPredicate(ctx, id, ResourceDetailsObjectOperationPredicate{}) +} + +// ListByPoolCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceDetailsClient) ListByPoolCompleteMatchingPredicate(ctx context.Context, id PoolId, predicate ResourceDetailsObjectOperationPredicate) (result ListByPoolCompleteResult, err error) { + items := make([]ResourceDetailsObject, 0) + + resp, err := c.ListByPool(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByPoolCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobject.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobject.go new file mode 100644 index 00000000000..4427ce65ddc --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobject.go @@ -0,0 +1,16 @@ +package resourcedetails + +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 ResourceDetailsObject struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceDetailsObjectProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobjectproperties.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobjectproperties.go new file mode 100644 index 00000000000..2656eb02a73 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/model_resourcedetailsobjectproperties.go @@ -0,0 +1,10 @@ +package resourcedetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceDetailsObjectProperties struct { + Image string `json:"image"` + ImageVersion string `json:"imageVersion"` + Status ResourceStatus `json:"status"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/predicates.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/predicates.go new file mode 100644 index 00000000000..cf92e73a78d --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/predicates.go @@ -0,0 +1,27 @@ +package resourcedetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceDetailsObjectOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ResourceDetailsObjectOperationPredicate) Matches(input ResourceDetailsObject) 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/devopsinfrastructure/2024-10-19/resourcedetails/version.go b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/version.go new file mode 100644 index 00000000000..1b4314d50bd --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/resourcedetails/version.go @@ -0,0 +1,10 @@ +package resourcedetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-19" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourcedetails/2024-10-19" +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/README.md b/resource-manager/devopsinfrastructure/2024-10-19/sku/README.md new file mode 100644 index 00000000000..c6e9ebcada3 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/sku` Documentation + +The `sku` SDK allows for interaction with Azure Resource Manager `devopsinfrastructure` (API Version `2024-10-19`). + +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/devopsinfrastructure/2024-10-19/sku" +``` + + +### Client Initialization + +```go +client := sku.NewSkuClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SkuClient.ListByLocation` + +```go +ctx := context.TODO() +id := sku.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/client.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/client.go new file mode 100644 index 00000000000..136c3fb0285 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/client.go @@ -0,0 +1,26 @@ +package sku + +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 SkuClient struct { + Client *resourcemanager.Client +} + +func NewSkuClientWithBaseURI(sdkApi sdkEnv.Api) (*SkuClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sku", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SkuClient: %+v", err) + } + + return &SkuClient{ + Client: client, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/constants.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/constants.go new file mode 100644 index 00000000000..5bc093139f5 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/constants.go @@ -0,0 +1,92 @@ +package sku + +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 ResourceSkuRestrictionsReasonCode string + +const ( + ResourceSkuRestrictionsReasonCodeNotAvailableForSubscription ResourceSkuRestrictionsReasonCode = "NotAvailableForSubscription" + ResourceSkuRestrictionsReasonCodeQuotaId ResourceSkuRestrictionsReasonCode = "QuotaId" +) + +func PossibleValuesForResourceSkuRestrictionsReasonCode() []string { + return []string{ + string(ResourceSkuRestrictionsReasonCodeNotAvailableForSubscription), + string(ResourceSkuRestrictionsReasonCodeQuotaId), + } +} + +func (s *ResourceSkuRestrictionsReasonCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceSkuRestrictionsReasonCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceSkuRestrictionsReasonCode(input string) (*ResourceSkuRestrictionsReasonCode, error) { + vals := map[string]ResourceSkuRestrictionsReasonCode{ + "notavailableforsubscription": ResourceSkuRestrictionsReasonCodeNotAvailableForSubscription, + "quotaid": ResourceSkuRestrictionsReasonCodeQuotaId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceSkuRestrictionsReasonCode(input) + return &out, nil +} + +type ResourceSkuRestrictionsType string + +const ( + ResourceSkuRestrictionsTypeLocation ResourceSkuRestrictionsType = "Location" + ResourceSkuRestrictionsTypeZone ResourceSkuRestrictionsType = "Zone" +) + +func PossibleValuesForResourceSkuRestrictionsType() []string { + return []string{ + string(ResourceSkuRestrictionsTypeLocation), + string(ResourceSkuRestrictionsTypeZone), + } +} + +func (s *ResourceSkuRestrictionsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceSkuRestrictionsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceSkuRestrictionsType(input string) (*ResourceSkuRestrictionsType, error) { + vals := map[string]ResourceSkuRestrictionsType{ + "location": ResourceSkuRestrictionsTypeLocation, + "zone": ResourceSkuRestrictionsTypeZone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceSkuRestrictionsType(input) + return &out, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location.go new file mode 100644 index 00000000000..0987dff78f1 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location.go @@ -0,0 +1,121 @@ +package sku + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DevOpsInfrastructure/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location_test.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location_test.go new file mode 100644 index 00000000000..a892726ba5e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/id_location_test.go @@ -0,0 +1,237 @@ +package sku + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/devopsinfrastructure/2024-10-19/sku/method_listbylocation.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/method_listbylocation.go new file mode 100644 index 00000000000..734beee7e1e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/method_listbylocation.go @@ -0,0 +1,105 @@ +package sku + +import ( + "context" + "fmt" + "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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceSku +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceSku +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c SkuClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/skus", 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 *[]ResourceSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c SkuClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, ResourceSkuOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SkuClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ResourceSkuOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]ResourceSku, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourcesku.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourcesku.go new file mode 100644 index 00000000000..76971520808 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourcesku.go @@ -0,0 +1,16 @@ +package sku + +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 ResourceSku struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceSkuProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskucapabilities.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskucapabilities.go new file mode 100644 index 00000000000..30b04f49dba --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskucapabilities.go @@ -0,0 +1,9 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuCapabilities struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskulocationinfo.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskulocationinfo.go new file mode 100644 index 00000000000..dd758ed458c --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskulocationinfo.go @@ -0,0 +1,14 @@ +package sku + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuLocationInfo struct { + Location string `json:"location"` + ZoneDetails []ResourceSkuZoneDetails `json:"zoneDetails"` + Zones zones.Schema `json:"zones"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuproperties.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuproperties.go new file mode 100644 index 00000000000..c53adbca99e --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuproperties.go @@ -0,0 +1,15 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuProperties struct { + Capabilities []ResourceSkuCapabilities `json:"capabilities"` + Family string `json:"family"` + LocationInfo []ResourceSkuLocationInfo `json:"locationInfo"` + Locations []string `json:"locations"` + ResourceType string `json:"resourceType"` + Restrictions []ResourceSkuRestrictions `json:"restrictions"` + Size string `json:"size"` + Tier string `json:"tier"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictioninfo.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictioninfo.go new file mode 100644 index 00000000000..de21b17c69a --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictioninfo.go @@ -0,0 +1,13 @@ +package sku + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuRestrictionInfo struct { + Locations *[]string `json:"locations,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictions.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictions.go new file mode 100644 index 00000000000..0362a669791 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskurestrictions.go @@ -0,0 +1,11 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuRestrictions struct { + ReasonCode *ResourceSkuRestrictionsReasonCode `json:"reasonCode,omitempty"` + RestrictionInfo ResourceSkuRestrictionInfo `json:"restrictionInfo"` + Type *ResourceSkuRestrictionsType `json:"type,omitempty"` + Values []string `json:"values"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuzonedetails.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuzonedetails.go new file mode 100644 index 00000000000..11e98a5c961 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/model_resourceskuzonedetails.go @@ -0,0 +1,9 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuZoneDetails struct { + Capabilities []ResourceSkuCapabilities `json:"capabilities"` + Name []string `json:"name"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/sku/predicates.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/predicates.go new file mode 100644 index 00000000000..a92bcf28a13 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/predicates.go @@ -0,0 +1,27 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ResourceSkuOperationPredicate) Matches(input ResourceSku) 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/devopsinfrastructure/2024-10-19/sku/version.go b/resource-manager/devopsinfrastructure/2024-10-19/sku/version.go new file mode 100644 index 00000000000..8072a94d139 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/sku/version.go @@ -0,0 +1,10 @@ +package sku + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-19" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sku/2024-10-19" +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/README.md b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/README.md new file mode 100644 index 00000000000..9329f931ae4 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages` Documentation + +The `subscriptionusages` SDK allows for interaction with Azure Resource Manager `devopsinfrastructure` (API Version `2024-10-19`). + +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/devopsinfrastructure/2024-10-19/subscriptionusages" +``` + + +### Client Initialization + +```go +client := subscriptionusages.NewSubscriptionUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SubscriptionUsagesClient.Usages` + +```go +ctx := context.TODO() +id := subscriptionusages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.Usages(ctx, id)` can be used to do batched pagination +items, err := client.UsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/client.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/client.go new file mode 100644 index 00000000000..5829a9a22b0 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/client.go @@ -0,0 +1,26 @@ +package subscriptionusages + +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 SubscriptionUsagesClient struct { + Client *resourcemanager.Client +} + +func NewSubscriptionUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*SubscriptionUsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "subscriptionusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubscriptionUsagesClient: %+v", err) + } + + return &SubscriptionUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location.go new file mode 100644 index 00000000000..7f4b480c928 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location.go @@ -0,0 +1,121 @@ +package subscriptionusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DevOpsInfrastructure/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location_test.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location_test.go new file mode 100644 index 00000000000..40edca1ad41 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/id_location_test.go @@ -0,0 +1,237 @@ +package subscriptionusages + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DevOpsInfrastructure/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dEvOpSiNfRaStRuCtUrE/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/devopsinfrastructure/2024-10-19/subscriptionusages/method_usages.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/method_usages.go new file mode 100644 index 00000000000..7e702bf4cc9 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/method_usages.go @@ -0,0 +1,105 @@ +package subscriptionusages + +import ( + "context" + "fmt" + "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 UsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Quota +} + +type UsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Quota +} + +type UsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *UsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Usages ... +func (c SubscriptionUsagesClient) Usages(ctx context.Context, id LocationId) (result UsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &UsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Quota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UsagesComplete retrieves all the results into a single object +func (c SubscriptionUsagesClient) UsagesComplete(ctx context.Context, id LocationId) (UsagesCompleteResult, error) { + return c.UsagesCompleteMatchingPredicate(ctx, id, QuotaOperationPredicate{}) +} + +// UsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SubscriptionUsagesClient) UsagesCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate QuotaOperationPredicate) (result UsagesCompleteResult, err error) { + items := make([]Quota, 0) + + resp, err := c.Usages(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = UsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quota.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quota.go new file mode 100644 index 00000000000..e0574a3af69 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quota.go @@ -0,0 +1,12 @@ +package subscriptionusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Quota struct { + CurrentValue int64 `json:"currentValue"` + Id string `json:"id"` + Limit int64 `json:"limit"` + Name *QuotaName `json:"name,omitempty"` + Unit string `json:"unit"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quotaname.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quotaname.go new file mode 100644 index 00000000000..f19eeab6cdc --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/model_quotaname.go @@ -0,0 +1,9 @@ +package subscriptionusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/predicates.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/predicates.go new file mode 100644 index 00000000000..6f1a4a19081 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/predicates.go @@ -0,0 +1,32 @@ +package subscriptionusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 + Unit *string +} + +func (p QuotaOperationPredicate) Matches(input Quota) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && *p.Id != input.Id { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + if p.Unit != nil && *p.Unit != input.Unit { + return false + } + + return true +} diff --git a/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/version.go b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/version.go new file mode 100644 index 00000000000..a17f1bd2657 --- /dev/null +++ b/resource-manager/devopsinfrastructure/2024-10-19/subscriptionusages/version.go @@ -0,0 +1,10 @@ +package subscriptionusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-19" + +func userAgent() string { + return "hashicorp/go-azure-sdk/subscriptionusages/2024-10-19" +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/README.md b/resource-manager/netapp/2024-07-01/backuppolicy/README.md new file mode 100644 index 00000000000..8699f0b7e28 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/README.md @@ -0,0 +1,98 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/backuppolicy` Documentation + +The `backuppolicy` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/backuppolicy" +``` + + +### Client Initialization + +```go +client := backuppolicy.NewBackupPolicyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupPolicyClient.BackupPoliciesCreate` + +```go +ctx := context.TODO() +id := backuppolicy.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName") + +payload := backuppolicy.BackupPolicy{ + // ... +} + + +if err := client.BackupPoliciesCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupPolicyClient.BackupPoliciesDelete` + +```go +ctx := context.TODO() +id := backuppolicy.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName") + +if err := client.BackupPoliciesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupPolicyClient.BackupPoliciesGet` + +```go +ctx := context.TODO() +id := backuppolicy.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName") + +read, err := client.BackupPoliciesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupPolicyClient.BackupPoliciesList` + +```go +ctx := context.TODO() +id := backuppolicy.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +read, err := client.BackupPoliciesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupPolicyClient.BackupPoliciesUpdate` + +```go +ctx := context.TODO() +id := backuppolicy.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName") + +payload := backuppolicy.BackupPolicyPatch{ + // ... +} + + +if err := client.BackupPoliciesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/client.go b/resource-manager/netapp/2024-07-01/backuppolicy/client.go new file mode 100644 index 00000000000..8b4fc07ad66 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/client.go @@ -0,0 +1,26 @@ +package backuppolicy + +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 BackupPolicyClient struct { + Client *resourcemanager.Client +} + +func NewBackupPolicyClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupPolicyClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "backuppolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupPolicyClient: %+v", err) + } + + return &BackupPolicyClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy.go b/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy.go new file mode 100644 index 00000000000..7e2cd95f210 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy.go @@ -0,0 +1,139 @@ +package backuppolicy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupPolicyId{}) +} + +var _ resourceids.ResourceId = &BackupPolicyId{} + +// BackupPolicyId is a struct representing the Resource ID for a Backup Policy +type BackupPolicyId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + BackupPolicyName string +} + +// NewBackupPolicyID returns a new BackupPolicyId struct +func NewBackupPolicyID(subscriptionId string, resourceGroupName string, netAppAccountName string, backupPolicyName string) BackupPolicyId { + return BackupPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + BackupPolicyName: backupPolicyName, + } +} + +// ParseBackupPolicyID parses 'input' into a BackupPolicyId +func ParseBackupPolicyID(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupPolicyIDInsensitively parses 'input' case-insensitively into a BackupPolicyId +// note: this method should only be used for API response data and not user input +func ParseBackupPolicyIDInsensitively(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupPolicyId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.BackupPolicyName, ok = input.Parsed["backupPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupPolicyName", input) + } + + return nil +} + +// ValidateBackupPolicyID checks that 'input' can be parsed as a Backup Policy ID +func ValidateBackupPolicyID(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 := ParseBackupPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Policy ID +func (id BackupPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/backupPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.BackupPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Policy ID +func (id BackupPolicyId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyName"), + } +} + +// String returns a human-readable description of this Backup Policy ID +func (id BackupPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Backup Policy Name: %q", id.BackupPolicyName), + } + return fmt.Sprintf("Backup Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy_test.go b/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy_test.go new file mode 100644 index 00000000000..39877320168 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/id_backuppolicy_test.go @@ -0,0 +1,327 @@ +package backuppolicy + +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 = &BackupPolicyId{} + +func TestNewBackupPolicyID(t *testing.T) { + id := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.BackupPolicyName != "backupPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupPolicyName'", id.BackupPolicyName, "backupPolicyName") + } +} + +func TestFormatBackupPolicyID(t *testing.T) { + actual := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies/backupPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies/backupPolicyName", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupPolicyName: "backupPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies/backupPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestParseBackupPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies/backupPolicyName", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupPolicyName: "backupPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupPolicies/backupPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPpOlIcIeS/bAcKuPpOlIcYnAmE", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + BackupPolicyName: "bAcKuPpOlIcYnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPpOlIcIeS/bAcKuPpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestSegmentsForBackupPolicyId(t *testing.T) { + segments := BackupPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupPolicyId 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/netapp/2024-07-01/backuppolicy/id_netappaccount.go b/resource-manager/netapp/2024-07-01/backuppolicy/id_netappaccount.go new file mode 100644 index 00000000000..b10e89e1ad1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/id_netappaccount.go @@ -0,0 +1,130 @@ +package backuppolicy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/backuppolicy/id_netappaccount_test.go new file mode 100644 index 00000000000..455b109bb39 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package backuppolicy + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/backuppolicy/method_backuppoliciescreate.go b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciescreate.go new file mode 100644 index 00000000000..bb886f44754 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciescreate.go @@ -0,0 +1,76 @@ +package backuppolicy + +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 BackupPoliciesCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupPolicy +} + +// BackupPoliciesCreate ... +func (c BackupPolicyClient) BackupPoliciesCreate(ctx context.Context, id BackupPolicyId, input BackupPolicy) (result BackupPoliciesCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// BackupPoliciesCreateThenPoll performs BackupPoliciesCreate then polls until it's completed +func (c BackupPolicyClient) BackupPoliciesCreateThenPoll(ctx context.Context, id BackupPolicyId, input BackupPolicy) error { + result, err := c.BackupPoliciesCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BackupPoliciesCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BackupPoliciesCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesdelete.go b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesdelete.go new file mode 100644 index 00000000000..482cdc1780e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesdelete.go @@ -0,0 +1,71 @@ +package backuppolicy + +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 BackupPoliciesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BackupPoliciesDelete ... +func (c BackupPolicyClient) BackupPoliciesDelete(ctx context.Context, id BackupPolicyId) (result BackupPoliciesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// BackupPoliciesDeleteThenPoll performs BackupPoliciesDelete then polls until it's completed +func (c BackupPolicyClient) BackupPoliciesDeleteThenPoll(ctx context.Context, id BackupPolicyId) error { + result, err := c.BackupPoliciesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing BackupPoliciesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BackupPoliciesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesget.go b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesget.go new file mode 100644 index 00000000000..e8ecfc1fc04 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesget.go @@ -0,0 +1,53 @@ +package backuppolicy + +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 BackupPoliciesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupPolicy +} + +// BackupPoliciesGet ... +func (c BackupPolicyClient) BackupPoliciesGet(ctx context.Context, id BackupPolicyId) (result BackupPoliciesGetOperationResponse, 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 + } + + var model BackupPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppolicieslist.go b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppolicieslist.go new file mode 100644 index 00000000000..7932d964240 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppolicieslist.go @@ -0,0 +1,54 @@ +package backuppolicy + +import ( + "context" + "fmt" + "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 BackupPoliciesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupPoliciesList +} + +// BackupPoliciesList ... +func (c BackupPolicyClient) BackupPoliciesList(ctx context.Context, id NetAppAccountId) (result BackupPoliciesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupPolicies", 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 + } + + var model BackupPoliciesList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesupdate.go b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesupdate.go new file mode 100644 index 00000000000..b24e23a21cf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/method_backuppoliciesupdate.go @@ -0,0 +1,75 @@ +package backuppolicy + +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 BackupPoliciesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupPolicy +} + +// BackupPoliciesUpdate ... +func (c BackupPolicyClient) BackupPoliciesUpdate(ctx context.Context, id BackupPolicyId, input BackupPolicyPatch) (result BackupPoliciesUpdateOperationResponse, 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 +} + +// BackupPoliciesUpdateThenPoll performs BackupPoliciesUpdate then polls until it's completed +func (c BackupPolicyClient) BackupPoliciesUpdateThenPoll(ctx context.Context, id BackupPolicyId, input BackupPolicyPatch) error { + result, err := c.BackupPoliciesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BackupPoliciesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BackupPoliciesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicieslist.go b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicieslist.go new file mode 100644 index 00000000000..3db3d131a60 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicieslist.go @@ -0,0 +1,8 @@ +package backuppolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPoliciesList struct { + Value *[]BackupPolicy `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicy.go b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicy.go new file mode 100644 index 00000000000..747ab65be24 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicy.go @@ -0,0 +1,19 @@ +package backuppolicy + +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 BackupPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BackupPolicyProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicypatch.go b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicypatch.go new file mode 100644 index 00000000000..bf7eecb1358 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicypatch.go @@ -0,0 +1,13 @@ +package backuppolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPolicyPatch struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupPolicyProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicyproperties.go b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicyproperties.go new file mode 100644 index 00000000000..d5694f4797d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/model_backuppolicyproperties.go @@ -0,0 +1,15 @@ +package backuppolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPolicyProperties struct { + BackupPolicyId *string `json:"backupPolicyId,omitempty"` + DailyBackupsToKeep *int64 `json:"dailyBackupsToKeep,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + MonthlyBackupsToKeep *int64 `json:"monthlyBackupsToKeep,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + VolumeBackups *[]VolumeBackups `json:"volumeBackups,omitempty"` + VolumesAssigned *int64 `json:"volumesAssigned,omitempty"` + WeeklyBackupsToKeep *int64 `json:"weeklyBackupsToKeep,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/model_volumebackups.go b/resource-manager/netapp/2024-07-01/backuppolicy/model_volumebackups.go new file mode 100644 index 00000000000..b53afb9ae14 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/model_volumebackups.go @@ -0,0 +1,11 @@ +package backuppolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeBackups struct { + BackupsCount *int64 `json:"backupsCount,omitempty"` + PolicyEnabled *bool `json:"policyEnabled,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` + VolumeResourceId *string `json:"volumeResourceId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backuppolicy/version.go b/resource-manager/netapp/2024-07-01/backuppolicy/version.go new file mode 100644 index 00000000000..af6fd8bf04b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backuppolicy/version.go @@ -0,0 +1,10 @@ +package backuppolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backuppolicy/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/backups/README.md b/resource-manager/netapp/2024-07-01/backups/README.md new file mode 100644 index 00000000000..e7ff576833e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/README.md @@ -0,0 +1,166 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/backups` Documentation + +The `backups` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/backups" +``` + + +### Client Initialization + +```go +client := backups.NewBackupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupsClient.Create` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + +payload := backups.Backup{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.Delete` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.Get` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + +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: `BackupsClient.GetLatestStatus` + +```go +ctx := context.TODO() +id := backups.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.GetLatestStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupsClient.ListByVault` + +```go +ctx := context.TODO() +id := backups.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + +// alternatively `client.ListByVault(ctx, id, backups.DefaultListByVaultOperationOptions())` can be used to do batched pagination +items, err := client.ListByVaultComplete(ctx, id, backups.DefaultListByVaultOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BackupsClient.UnderAccountMigrateBackups` + +```go +ctx := context.TODO() +id := backups.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +payload := backups.BackupsMigrationRequest{ + // ... +} + + +if err := client.UnderAccountMigrateBackupsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.UnderBackupVaultRestoreFiles` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + +payload := backups.BackupRestoreFiles{ + // ... +} + + +if err := client.UnderBackupVaultRestoreFilesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.UnderVolumeMigrateBackups` + +```go +ctx := context.TODO() +id := backups.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := backups.BackupsMigrationRequest{ + // ... +} + + +if err := client.UnderVolumeMigrateBackupsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.Update` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + +payload := backups.BackupPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/backups/client.go b/resource-manager/netapp/2024-07-01/backups/client.go new file mode 100644 index 00000000000..6e1cc70d434 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/client.go @@ -0,0 +1,26 @@ +package backups + +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 BackupsClient struct { + Client *resourcemanager.Client +} + +func NewBackupsClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "backups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupsClient: %+v", err) + } + + return &BackupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/constants.go b/resource-manager/netapp/2024-07-01/backups/constants.go new file mode 100644 index 00000000000..d3c86cd75c0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/constants.go @@ -0,0 +1,142 @@ +package backups + +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 BackupType string + +const ( + BackupTypeManual BackupType = "Manual" + BackupTypeScheduled BackupType = "Scheduled" +) + +func PossibleValuesForBackupType() []string { + return []string{ + string(BackupTypeManual), + string(BackupTypeScheduled), + } +} + +func (s *BackupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupType(input string) (*BackupType, error) { + vals := map[string]BackupType{ + "manual": BackupTypeManual, + "scheduled": BackupTypeScheduled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupType(input) + return &out, nil +} + +type MirrorState string + +const ( + MirrorStateBroken MirrorState = "Broken" + MirrorStateMirrored MirrorState = "Mirrored" + MirrorStateUninitialized MirrorState = "Uninitialized" +) + +func PossibleValuesForMirrorState() []string { + return []string{ + string(MirrorStateBroken), + string(MirrorStateMirrored), + string(MirrorStateUninitialized), + } +} + +func (s *MirrorState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMirrorState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMirrorState(input string) (*MirrorState, error) { + vals := map[string]MirrorState{ + "broken": MirrorStateBroken, + "mirrored": MirrorStateMirrored, + "uninitialized": MirrorStateUninitialized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MirrorState(input) + return &out, nil +} + +type RelationshipStatus string + +const ( + RelationshipStatusFailed RelationshipStatus = "Failed" + RelationshipStatusIdle RelationshipStatus = "Idle" + RelationshipStatusTransferring RelationshipStatus = "Transferring" + RelationshipStatusUnknown RelationshipStatus = "Unknown" +) + +func PossibleValuesForRelationshipStatus() []string { + return []string{ + string(RelationshipStatusFailed), + string(RelationshipStatusIdle), + string(RelationshipStatusTransferring), + string(RelationshipStatusUnknown), + } +} + +func (s *RelationshipStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelationshipStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRelationshipStatus(input string) (*RelationshipStatus, error) { + vals := map[string]RelationshipStatus{ + "failed": RelationshipStatusFailed, + "idle": RelationshipStatusIdle, + "transferring": RelationshipStatusTransferring, + "unknown": RelationshipStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RelationshipStatus(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/id_backup.go b/resource-manager/netapp/2024-07-01/backups/id_backup.go new file mode 100644 index 00000000000..06aacd5f5b5 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_backup.go @@ -0,0 +1,148 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupId{}) +} + +var _ resourceids.ResourceId = &BackupId{} + +// BackupId is a struct representing the Resource ID for a Backup +type BackupId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + BackupVaultName string + BackupName string +} + +// NewBackupID returns a new BackupId struct +func NewBackupID(subscriptionId string, resourceGroupName string, netAppAccountName string, backupVaultName string, backupName string) BackupId { + return BackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + BackupVaultName: backupVaultName, + BackupName: backupName, + } +} + +// ParseBackupID parses 'input' into a BackupId +func ParseBackupID(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupIDInsensitively parses 'input' case-insensitively into a BackupId +// note: this method should only be used for API response data and not user input +func ParseBackupIDInsensitively(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupName, ok = input.Parsed["backupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupName", input) + } + + return nil +} + +// ValidateBackupID checks that 'input' can be parsed as a Backup ID +func ValidateBackupID(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 := ParseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup ID +func (id BackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/backupVaults/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.BackupVaultName, id.BackupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup ID +func (id BackupId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupName", "backupName"), + } +} + +// String returns a human-readable description of this Backup ID +func (id BackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Name: %q", id.BackupName), + } + return fmt.Sprintf("Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backups/id_backup_test.go b/resource-manager/netapp/2024-07-01/backups/id_backup_test.go new file mode 100644 index 00000000000..02c2ee418cc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_backup_test.go @@ -0,0 +1,372 @@ +package backups + +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 = &BackupId{} + +func TestNewBackupID(t *testing.T) { + id := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.BackupVaultName != "backupVaultName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultName") + } + + if id.BackupName != "backupName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupName'", id.BackupName, "backupName") + } +} + +func TestFormatBackupID(t *testing.T) { + actual := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName", "backupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups/backupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups/backupName", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + BackupName: "backupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups/backupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupName != v.Expected.BackupName { + t.Fatalf("Expected %q but got %q for BackupName", v.Expected.BackupName, actual.BackupName) + } + + } +} + +func TestParseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups/backupName", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + BackupName: "backupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/backups/backupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe/bAcKuPs/bAcKuPnAmE", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + BackupVaultName: "bAcKuPvAuLtNaMe", + BackupName: "bAcKuPnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe/bAcKuPs/bAcKuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupName != v.Expected.BackupName { + t.Fatalf("Expected %q but got %q for BackupName", v.Expected.BackupName, actual.BackupName) + } + + } +} + +func TestSegmentsForBackupId(t *testing.T) { + segments := BackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupId 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/netapp/2024-07-01/backups/id_backupvault.go b/resource-manager/netapp/2024-07-01/backups/id_backupvault.go new file mode 100644 index 00000000000..779adf353ca --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_backupvault.go @@ -0,0 +1,139 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, netAppAccountName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultName"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backups/id_backupvault_test.go b/resource-manager/netapp/2024-07-01/backups/id_backupvault_test.go new file mode 100644 index 00000000000..1601bd44bc7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_backupvault_test.go @@ -0,0 +1,327 @@ +package backups + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.BackupVaultName != "backupVaultName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultName") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + BackupVaultName: "bAcKuPvAuLtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/netapp/2024-07-01/backups/id_netappaccount.go b/resource-manager/netapp/2024-07-01/backups/id_netappaccount.go new file mode 100644 index 00000000000..516c7ff3911 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_netappaccount.go @@ -0,0 +1,130 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backups/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/backups/id_netappaccount_test.go new file mode 100644 index 00000000000..18f86cc0302 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package backups + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/backups/id_volume.go b/resource-manager/netapp/2024-07-01/backups/id_volume.go new file mode 100644 index 00000000000..68f2aee4179 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_volume.go @@ -0,0 +1,148 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backups/id_volume_test.go b/resource-manager/netapp/2024-07-01/backups/id_volume_test.go new file mode 100644 index 00000000000..8f1a2ec3f88 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/id_volume_test.go @@ -0,0 +1,372 @@ +package backups + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/backups/method_create.go b/resource-manager/netapp/2024-07-01/backups/method_create.go new file mode 100644 index 00000000000..547e1883e1f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_create.go @@ -0,0 +1,75 @@ +package backups + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Backup +} + +// Create ... +func (c BackupsClient) Create(ctx context.Context, id BackupId, input Backup) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c BackupsClient) CreateThenPoll(ctx context.Context, id BackupId, input Backup) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_delete.go b/resource-manager/netapp/2024-07-01/backups/method_delete.go new file mode 100644 index 00000000000..15a40b88c3c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_delete.go @@ -0,0 +1,70 @@ +package backups + +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 BackupsClient) Delete(ctx context.Context, id BackupId) (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 BackupsClient) DeleteThenPoll(ctx context.Context, id BackupId) 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/netapp/2024-07-01/backups/method_get.go b/resource-manager/netapp/2024-07-01/backups/method_get.go new file mode 100644 index 00000000000..fe88bb84d0a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_get.go @@ -0,0 +1,53 @@ +package backups + +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 *Backup +} + +// Get ... +func (c BackupsClient) Get(ctx context.Context, id BackupId) (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 + } + + var model Backup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_getlateststatus.go b/resource-manager/netapp/2024-07-01/backups/method_getlateststatus.go new file mode 100644 index 00000000000..1668fdfcf7e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_getlateststatus.go @@ -0,0 +1,54 @@ +package backups + +import ( + "context" + "fmt" + "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 GetLatestStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupStatus +} + +// GetLatestStatus ... +func (c BackupsClient) GetLatestStatus(ctx context.Context, id VolumeId) (result GetLatestStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/latestBackupStatus/current", 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 + } + + var model BackupStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_listbyvault.go b/resource-manager/netapp/2024-07-01/backups/method_listbyvault.go new file mode 100644 index 00000000000..3416244ff49 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_listbyvault.go @@ -0,0 +1,134 @@ +package backups + +import ( + "context" + "fmt" + "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 ListByVaultOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Backup +} + +type ListByVaultCompleteResult struct { + LatestHttpResponse *http.Response + Items []Backup +} + +type ListByVaultOperationOptions struct { + Filter *string +} + +func DefaultListByVaultOperationOptions() ListByVaultOperationOptions { + return ListByVaultOperationOptions{} +} + +func (o ListByVaultOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByVaultOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByVaultOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListByVaultCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByVaultCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByVault ... +func (c BackupsClient) ListByVault(ctx context.Context, id BackupVaultId, options ListByVaultOperationOptions) (result ListByVaultOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByVaultCustomPager{}, + Path: fmt.Sprintf("%s/backups", 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 *[]Backup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByVaultComplete retrieves all the results into a single object +func (c BackupsClient) ListByVaultComplete(ctx context.Context, id BackupVaultId, options ListByVaultOperationOptions) (ListByVaultCompleteResult, error) { + return c.ListByVaultCompleteMatchingPredicate(ctx, id, options, BackupOperationPredicate{}) +} + +// ListByVaultCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupsClient) ListByVaultCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, options ListByVaultOperationOptions, predicate BackupOperationPredicate) (result ListByVaultCompleteResult, err error) { + items := make([]Backup, 0) + + resp, err := c.ListByVault(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByVaultCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_underaccountmigratebackups.go b/resource-manager/netapp/2024-07-01/backups/method_underaccountmigratebackups.go new file mode 100644 index 00000000000..d8792fed2b6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_underaccountmigratebackups.go @@ -0,0 +1,73 @@ +package backups + +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 UnderAccountMigrateBackupsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// UnderAccountMigrateBackups ... +func (c BackupsClient) UnderAccountMigrateBackups(ctx context.Context, id NetAppAccountId, input BackupsMigrationRequest) (result UnderAccountMigrateBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateBackups", 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 +} + +// UnderAccountMigrateBackupsThenPoll performs UnderAccountMigrateBackups then polls until it's completed +func (c BackupsClient) UnderAccountMigrateBackupsThenPoll(ctx context.Context, id NetAppAccountId, input BackupsMigrationRequest) error { + result, err := c.UnderAccountMigrateBackups(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnderAccountMigrateBackups: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnderAccountMigrateBackups: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_underbackupvaultrestorefiles.go b/resource-manager/netapp/2024-07-01/backups/method_underbackupvaultrestorefiles.go new file mode 100644 index 00000000000..fae1ff9c3ac --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_underbackupvaultrestorefiles.go @@ -0,0 +1,73 @@ +package backups + +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 UnderBackupVaultRestoreFilesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// UnderBackupVaultRestoreFiles ... +func (c BackupsClient) UnderBackupVaultRestoreFiles(ctx context.Context, id BackupId, input BackupRestoreFiles) (result UnderBackupVaultRestoreFilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFiles", 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 +} + +// UnderBackupVaultRestoreFilesThenPoll performs UnderBackupVaultRestoreFiles then polls until it's completed +func (c BackupsClient) UnderBackupVaultRestoreFilesThenPoll(ctx context.Context, id BackupId, input BackupRestoreFiles) error { + result, err := c.UnderBackupVaultRestoreFiles(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnderBackupVaultRestoreFiles: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnderBackupVaultRestoreFiles: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_undervolumemigratebackups.go b/resource-manager/netapp/2024-07-01/backups/method_undervolumemigratebackups.go new file mode 100644 index 00000000000..1bbdca6b084 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_undervolumemigratebackups.go @@ -0,0 +1,73 @@ +package backups + +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 UnderVolumeMigrateBackupsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// UnderVolumeMigrateBackups ... +func (c BackupsClient) UnderVolumeMigrateBackups(ctx context.Context, id VolumeId, input BackupsMigrationRequest) (result UnderVolumeMigrateBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateBackups", 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 +} + +// UnderVolumeMigrateBackupsThenPoll performs UnderVolumeMigrateBackups then polls until it's completed +func (c BackupsClient) UnderVolumeMigrateBackupsThenPoll(ctx context.Context, id VolumeId, input BackupsMigrationRequest) error { + result, err := c.UnderVolumeMigrateBackups(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnderVolumeMigrateBackups: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnderVolumeMigrateBackups: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/backups/method_update.go b/resource-manager/netapp/2024-07-01/backups/method_update.go new file mode 100644 index 00000000000..0a8669d7caa --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/method_update.go @@ -0,0 +1,75 @@ +package backups + +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 + Model *Backup +} + +// Update ... +func (c BackupsClient) Update(ctx context.Context, id BackupId, input BackupPatch) (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 BackupsClient) UpdateThenPoll(ctx context.Context, id BackupId, input BackupPatch) 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/netapp/2024-07-01/backups/model_backup.go b/resource-manager/netapp/2024-07-01/backups/model_backup.go new file mode 100644 index 00000000000..ef5ef0a7bc6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backup.go @@ -0,0 +1,16 @@ +package backups + +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 Backup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backuppatch.go b/resource-manager/netapp/2024-07-01/backups/model_backuppatch.go new file mode 100644 index 00000000000..a87251f4b0c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backuppatch.go @@ -0,0 +1,8 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPatch struct { + Properties *BackupPatchProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backuppatchproperties.go b/resource-manager/netapp/2024-07-01/backups/model_backuppatchproperties.go new file mode 100644 index 00000000000..b374bda3143 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backuppatchproperties.go @@ -0,0 +1,8 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPatchProperties struct { + Label *string `json:"label,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backupproperties.go b/resource-manager/netapp/2024-07-01/backups/model_backupproperties.go new file mode 100644 index 00000000000..168aa8182a9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backupproperties.go @@ -0,0 +1,36 @@ +package backups + +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 BackupProperties struct { + BackupId *string `json:"backupId,omitempty"` + BackupPolicyResourceId *string `json:"backupPolicyResourceId,omitempty"` + BackupType *BackupType `json:"backupType,omitempty"` + CreationDate *string `json:"creationDate,omitempty"` + FailureReason *string `json:"failureReason,omitempty"` + Label *string `json:"label,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Size *int64 `json:"size,omitempty"` + SnapshotName *string `json:"snapshotName,omitempty"` + UseExistingSnapshot *bool `json:"useExistingSnapshot,omitempty"` + VolumeResourceId string `json:"volumeResourceId"` +} + +func (o *BackupProperties) GetCreationDateAsTime() (*time.Time, error) { + if o.CreationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupProperties) SetCreationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationDate = &formatted +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backuprestorefiles.go b/resource-manager/netapp/2024-07-01/backups/model_backuprestorefiles.go new file mode 100644 index 00000000000..e26ce886407 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backuprestorefiles.go @@ -0,0 +1,10 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreFiles struct { + DestinationVolumeId string `json:"destinationVolumeId"` + FileList []string `json:"fileList"` + RestoreFilePath *string `json:"restoreFilePath,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backupsmigrationrequest.go b/resource-manager/netapp/2024-07-01/backups/model_backupsmigrationrequest.go new file mode 100644 index 00000000000..f0fb612b507 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backupsmigrationrequest.go @@ -0,0 +1,8 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupsMigrationRequest struct { + BackupVaultId string `json:"backupVaultId"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/model_backupstatus.go b/resource-manager/netapp/2024-07-01/backups/model_backupstatus.go new file mode 100644 index 00000000000..e873cd9463d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/model_backupstatus.go @@ -0,0 +1,16 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatus struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Healthy *bool `json:"healthy,omitempty"` + LastTransferSize *int64 `json:"lastTransferSize,omitempty"` + LastTransferType *string `json:"lastTransferType,omitempty"` + MirrorState *MirrorState `json:"mirrorState,omitempty"` + RelationshipStatus *RelationshipStatus `json:"relationshipStatus,omitempty"` + TotalTransferBytes *int64 `json:"totalTransferBytes,omitempty"` + TransferProgressBytes *int64 `json:"transferProgressBytes,omitempty"` + UnhealthyReason *string `json:"unhealthyReason,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backups/predicates.go b/resource-manager/netapp/2024-07-01/backups/predicates.go new file mode 100644 index 00000000000..f5033a2bb91 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/predicates.go @@ -0,0 +1,27 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p BackupOperationPredicate) Matches(input Backup) 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/netapp/2024-07-01/backups/version.go b/resource-manager/netapp/2024-07-01/backups/version.go new file mode 100644 index 00000000000..c2217216252 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backups/version.go @@ -0,0 +1,10 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backups/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/README.md b/resource-manager/netapp/2024-07-01/backupvaults/README.md new file mode 100644 index 00000000000..15674c3394c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/backupvaults` Documentation + +The `backupvaults` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/backupvaults" +``` + + +### Client Initialization + +```go +client := backupvaults.NewBackupVaultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupVaultsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + +payload := backupvaults.BackupVault{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupVaultsClient.Delete` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupVaultsClient.Get` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + +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: `BackupVaultsClient.ListByNetAppAccount` + +```go +ctx := context.TODO() +id := backupvaults.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +// alternatively `client.ListByNetAppAccount(ctx, id)` can be used to do batched pagination +items, err := client.ListByNetAppAccountComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BackupVaultsClient.Update` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + +payload := backupvaults.BackupVaultPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/backupvaults/client.go b/resource-manager/netapp/2024-07-01/backupvaults/client.go new file mode 100644 index 00000000000..57d96b431b5 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/client.go @@ -0,0 +1,26 @@ +package backupvaults + +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 BackupVaultsClient struct { + Client *resourcemanager.Client +} + +func NewBackupVaultsClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupVaultsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "backupvaults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupVaultsClient: %+v", err) + } + + return &BackupVaultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault.go b/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault.go new file mode 100644 index 00000000000..84c03165062 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault.go @@ -0,0 +1,139 @@ +package backupvaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, netAppAccountName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultName"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault_test.go b/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault_test.go new file mode 100644 index 00000000000..2a77aec3df2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/id_backupvault_test.go @@ -0,0 +1,327 @@ +package backupvaults + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.BackupVaultName != "backupVaultName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultName") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "backupVaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + BackupVaultName: "backupVaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/backupVaults/backupVaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + BackupVaultName: "bAcKuPvAuLtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/bAcKuPvAuLtS/bAcKuPvAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/netapp/2024-07-01/backupvaults/id_netappaccount.go b/resource-manager/netapp/2024-07-01/backupvaults/id_netappaccount.go new file mode 100644 index 00000000000..203dcf207ec --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/id_netappaccount.go @@ -0,0 +1,130 @@ +package backupvaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/backupvaults/id_netappaccount_test.go new file mode 100644 index 00000000000..151b0b66fb7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package backupvaults + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/backupvaults/method_createorupdate.go b/resource-manager/netapp/2024-07-01/backupvaults/method_createorupdate.go new file mode 100644 index 00000000000..0f75206e2d7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/method_createorupdate.go @@ -0,0 +1,75 @@ +package backupvaults + +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 + Model *BackupVault +} + +// CreateOrUpdate ... +func (c BackupVaultsClient) CreateOrUpdate(ctx context.Context, id BackupVaultId, input BackupVault) (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 BackupVaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id BackupVaultId, input BackupVault) 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/netapp/2024-07-01/backupvaults/method_delete.go b/resource-manager/netapp/2024-07-01/backupvaults/method_delete.go new file mode 100644 index 00000000000..32a1387f1ba --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/method_delete.go @@ -0,0 +1,70 @@ +package backupvaults + +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 BackupVaultsClient) Delete(ctx context.Context, id BackupVaultId) (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 BackupVaultsClient) DeleteThenPoll(ctx context.Context, id BackupVaultId) 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/netapp/2024-07-01/backupvaults/method_get.go b/resource-manager/netapp/2024-07-01/backupvaults/method_get.go new file mode 100644 index 00000000000..6cd544f7ca9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/method_get.go @@ -0,0 +1,53 @@ +package backupvaults + +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 *BackupVault +} + +// Get ... +func (c BackupVaultsClient) Get(ctx context.Context, id BackupVaultId) (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 + } + + var model BackupVault + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/method_listbynetappaccount.go b/resource-manager/netapp/2024-07-01/backupvaults/method_listbynetappaccount.go new file mode 100644 index 00000000000..a0f46fc1023 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/method_listbynetappaccount.go @@ -0,0 +1,105 @@ +package backupvaults + +import ( + "context" + "fmt" + "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 ListByNetAppAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupVault +} + +type ListByNetAppAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupVault +} + +type ListByNetAppAccountCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByNetAppAccountCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByNetAppAccount ... +func (c BackupVaultsClient) ListByNetAppAccount(ctx context.Context, id NetAppAccountId) (result ListByNetAppAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByNetAppAccountCustomPager{}, + Path: fmt.Sprintf("%s/backupVaults", 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 *[]BackupVault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNetAppAccountComplete retrieves all the results into a single object +func (c BackupVaultsClient) ListByNetAppAccountComplete(ctx context.Context, id NetAppAccountId) (ListByNetAppAccountCompleteResult, error) { + return c.ListByNetAppAccountCompleteMatchingPredicate(ctx, id, BackupVaultOperationPredicate{}) +} + +// ListByNetAppAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupVaultsClient) ListByNetAppAccountCompleteMatchingPredicate(ctx context.Context, id NetAppAccountId, predicate BackupVaultOperationPredicate) (result ListByNetAppAccountCompleteResult, err error) { + items := make([]BackupVault, 0) + + resp, err := c.ListByNetAppAccount(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByNetAppAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/method_update.go b/resource-manager/netapp/2024-07-01/backupvaults/method_update.go new file mode 100644 index 00000000000..8ea7dce3123 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/method_update.go @@ -0,0 +1,75 @@ +package backupvaults + +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 + Model *BackupVault +} + +// Update ... +func (c BackupVaultsClient) Update(ctx context.Context, id BackupVaultId, input BackupVaultPatch) (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 BackupVaultsClient) UpdateThenPoll(ctx context.Context, id BackupVaultId, input BackupVaultPatch) 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/netapp/2024-07-01/backupvaults/model_backupvault.go b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvault.go new file mode 100644 index 00000000000..0e8761f2293 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvault.go @@ -0,0 +1,18 @@ +package backupvaults + +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 BackupVault struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *BackupVaultProperties `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/netapp/2024-07-01/backupvaults/model_backupvaultpatch.go b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvaultpatch.go new file mode 100644 index 00000000000..899e2ecf858 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvaultpatch.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVaultPatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/model_backupvaultproperties.go b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvaultproperties.go new file mode 100644 index 00000000000..7327d4d2119 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/model_backupvaultproperties.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVaultProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/backupvaults/predicates.go b/resource-manager/netapp/2024-07-01/backupvaults/predicates.go new file mode 100644 index 00000000000..53d942f568c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/predicates.go @@ -0,0 +1,32 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVaultOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BackupVaultOperationPredicate) Matches(input BackupVault) 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/netapp/2024-07-01/backupvaults/version.go b/resource-manager/netapp/2024-07-01/backupvaults/version.go new file mode 100644 index 00000000000..faf276c387c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/backupvaults/version.go @@ -0,0 +1,10 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backupvaults/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/README.md b/resource-manager/netapp/2024-07-01/capacitypools/README.md new file mode 100644 index 00000000000..7e4aadedab3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/capacitypools` Documentation + +The `capacitypools` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/capacitypools" +``` + + +### Client Initialization + +```go +client := capacitypools.NewCapacityPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CapacityPoolsClient.PoolsCreateOrUpdate` + +```go +ctx := context.TODO() +id := capacitypools.NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + +payload := capacitypools.CapacityPool{ + // ... +} + + +if err := client.PoolsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CapacityPoolsClient.PoolsDelete` + +```go +ctx := context.TODO() +id := capacitypools.NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + +if err := client.PoolsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CapacityPoolsClient.PoolsGet` + +```go +ctx := context.TODO() +id := capacitypools.NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + +read, err := client.PoolsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CapacityPoolsClient.PoolsList` + +```go +ctx := context.TODO() +id := capacitypools.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +// alternatively `client.PoolsList(ctx, id)` can be used to do batched pagination +items, err := client.PoolsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CapacityPoolsClient.PoolsUpdate` + +```go +ctx := context.TODO() +id := capacitypools.NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + +payload := capacitypools.CapacityPoolPatch{ + // ... +} + + +if err := client.PoolsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/capacitypools/client.go b/resource-manager/netapp/2024-07-01/capacitypools/client.go new file mode 100644 index 00000000000..d7a8be4e076 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/client.go @@ -0,0 +1,26 @@ +package capacitypools + +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 CapacityPoolsClient struct { + Client *resourcemanager.Client +} + +func NewCapacityPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*CapacityPoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "capacitypools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CapacityPoolsClient: %+v", err) + } + + return &CapacityPoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/constants.go b/resource-manager/netapp/2024-07-01/capacitypools/constants.go new file mode 100644 index 00000000000..802074e5dc1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/constants.go @@ -0,0 +1,139 @@ +package capacitypools + +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 EncryptionType string + +const ( + EncryptionTypeDouble EncryptionType = "Double" + EncryptionTypeSingle EncryptionType = "Single" +) + +func PossibleValuesForEncryptionType() []string { + return []string{ + string(EncryptionTypeDouble), + string(EncryptionTypeSingle), + } +} + +func (s *EncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionType(input string) (*EncryptionType, error) { + vals := map[string]EncryptionType{ + "double": EncryptionTypeDouble, + "single": EncryptionTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionType(input) + return &out, nil +} + +type QosType string + +const ( + QosTypeAuto QosType = "Auto" + QosTypeManual QosType = "Manual" +) + +func PossibleValuesForQosType() []string { + return []string{ + string(QosTypeAuto), + string(QosTypeManual), + } +} + +func (s *QosType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQosType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQosType(input string) (*QosType, error) { + vals := map[string]QosType{ + "auto": QosTypeAuto, + "manual": QosTypeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QosType(input) + return &out, nil +} + +type ServiceLevel string + +const ( + ServiceLevelPremium ServiceLevel = "Premium" + ServiceLevelStandard ServiceLevel = "Standard" + ServiceLevelStandardZRS ServiceLevel = "StandardZRS" + ServiceLevelUltra ServiceLevel = "Ultra" +) + +func PossibleValuesForServiceLevel() []string { + return []string{ + string(ServiceLevelPremium), + string(ServiceLevelStandard), + string(ServiceLevelStandardZRS), + string(ServiceLevelUltra), + } +} + +func (s *ServiceLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLevel(input string) (*ServiceLevel, error) { + vals := map[string]ServiceLevel{ + "premium": ServiceLevelPremium, + "standard": ServiceLevelStandard, + "standardzrs": ServiceLevelStandardZRS, + "ultra": ServiceLevelUltra, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLevel(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool.go b/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool.go new file mode 100644 index 00000000000..0e041090dd4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool.go @@ -0,0 +1,139 @@ +package capacitypools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CapacityPoolId{}) +} + +var _ resourceids.ResourceId = &CapacityPoolId{} + +// CapacityPoolId is a struct representing the Resource ID for a Capacity Pool +type CapacityPoolId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string +} + +// NewCapacityPoolID returns a new CapacityPoolId struct +func NewCapacityPoolID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string) CapacityPoolId { + return CapacityPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + } +} + +// ParseCapacityPoolID parses 'input' into a CapacityPoolId +func ParseCapacityPoolID(input string) (*CapacityPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCapacityPoolIDInsensitively parses 'input' case-insensitively into a CapacityPoolId +// note: this method should only be used for API response data and not user input +func ParseCapacityPoolIDInsensitively(input string) (*CapacityPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CapacityPoolId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + return nil +} + +// ValidateCapacityPoolID checks that 'input' can be parsed as a Capacity Pool ID +func ValidateCapacityPoolID(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 := ParseCapacityPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Capacity Pool ID +func (id CapacityPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Capacity Pool ID +func (id CapacityPoolId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + } +} + +// String returns a human-readable description of this Capacity Pool ID +func (id CapacityPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + } + return fmt.Sprintf("Capacity Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool_test.go b/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool_test.go new file mode 100644 index 00000000000..6bfc38a792d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/id_capacitypool_test.go @@ -0,0 +1,327 @@ +package capacitypools + +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 = &CapacityPoolId{} + +func TestNewCapacityPoolID(t *testing.T) { + id := NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } +} + +func TestFormatCapacityPoolID(t *testing.T) { + actual := NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCapacityPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityPoolId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityPoolID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + } +} + +func TestParseCapacityPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityPoolId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityPoolIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + } +} + +func TestSegmentsForCapacityPoolId(t *testing.T) { + segments := CapacityPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CapacityPoolId 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/netapp/2024-07-01/capacitypools/id_netappaccount.go b/resource-manager/netapp/2024-07-01/capacitypools/id_netappaccount.go new file mode 100644 index 00000000000..58a09e2952e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/id_netappaccount.go @@ -0,0 +1,130 @@ +package capacitypools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/capacitypools/id_netappaccount_test.go new file mode 100644 index 00000000000..91d9bae2f9f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package capacitypools + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/capacitypools/method_poolscreateorupdate.go b/resource-manager/netapp/2024-07-01/capacitypools/method_poolscreateorupdate.go new file mode 100644 index 00000000000..2083a6d9987 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/method_poolscreateorupdate.go @@ -0,0 +1,75 @@ +package capacitypools + +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 PoolsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CapacityPool +} + +// PoolsCreateOrUpdate ... +func (c CapacityPoolsClient) PoolsCreateOrUpdate(ctx context.Context, id CapacityPoolId, input CapacityPool) (result PoolsCreateOrUpdateOperationResponse, 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 +} + +// PoolsCreateOrUpdateThenPoll performs PoolsCreateOrUpdate then polls until it's completed +func (c CapacityPoolsClient) PoolsCreateOrUpdateThenPoll(ctx context.Context, id CapacityPoolId, input CapacityPool) error { + result, err := c.PoolsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoolsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PoolsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/method_poolsdelete.go b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsdelete.go new file mode 100644 index 00000000000..36c9e0e6bcf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsdelete.go @@ -0,0 +1,70 @@ +package capacitypools + +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 PoolsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PoolsDelete ... +func (c CapacityPoolsClient) PoolsDelete(ctx context.Context, id CapacityPoolId) (result PoolsDeleteOperationResponse, 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 +} + +// PoolsDeleteThenPoll performs PoolsDelete then polls until it's completed +func (c CapacityPoolsClient) PoolsDeleteThenPoll(ctx context.Context, id CapacityPoolId) error { + result, err := c.PoolsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PoolsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PoolsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/method_poolsget.go b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsget.go new file mode 100644 index 00000000000..f9d5fcc8531 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsget.go @@ -0,0 +1,53 @@ +package capacitypools + +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 PoolsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CapacityPool +} + +// PoolsGet ... +func (c CapacityPoolsClient) PoolsGet(ctx context.Context, id CapacityPoolId) (result PoolsGetOperationResponse, 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 + } + + var model CapacityPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/method_poolslist.go b/resource-manager/netapp/2024-07-01/capacitypools/method_poolslist.go new file mode 100644 index 00000000000..2fe683d61de --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/method_poolslist.go @@ -0,0 +1,105 @@ +package capacitypools + +import ( + "context" + "fmt" + "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 PoolsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CapacityPool +} + +type PoolsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CapacityPool +} + +type PoolsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PoolsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PoolsList ... +func (c CapacityPoolsClient) PoolsList(ctx context.Context, id NetAppAccountId) (result PoolsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PoolsListCustomPager{}, + Path: fmt.Sprintf("%s/capacityPools", 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 *[]CapacityPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PoolsListComplete retrieves all the results into a single object +func (c CapacityPoolsClient) PoolsListComplete(ctx context.Context, id NetAppAccountId) (PoolsListCompleteResult, error) { + return c.PoolsListCompleteMatchingPredicate(ctx, id, CapacityPoolOperationPredicate{}) +} + +// PoolsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CapacityPoolsClient) PoolsListCompleteMatchingPredicate(ctx context.Context, id NetAppAccountId, predicate CapacityPoolOperationPredicate) (result PoolsListCompleteResult, err error) { + items := make([]CapacityPool, 0) + + resp, err := c.PoolsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = PoolsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/method_poolsupdate.go b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsupdate.go new file mode 100644 index 00000000000..df2c44337fd --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/method_poolsupdate.go @@ -0,0 +1,75 @@ +package capacitypools + +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 PoolsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CapacityPool +} + +// PoolsUpdate ... +func (c CapacityPoolsClient) PoolsUpdate(ctx context.Context, id CapacityPoolId, input CapacityPoolPatch) (result PoolsUpdateOperationResponse, 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 +} + +// PoolsUpdateThenPoll performs PoolsUpdate then polls until it's completed +func (c CapacityPoolsClient) PoolsUpdateThenPoll(ctx context.Context, id CapacityPoolId, input CapacityPoolPatch) error { + result, err := c.PoolsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoolsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PoolsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypool.go b/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypool.go new file mode 100644 index 00000000000..f5d6f1ea86d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypool.go @@ -0,0 +1,19 @@ +package capacitypools + +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 CapacityPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties PoolProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypoolpatch.go b/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypoolpatch.go new file mode 100644 index 00000000000..46abcde6b33 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/model_capacitypoolpatch.go @@ -0,0 +1,13 @@ +package capacitypools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityPoolPatch struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PoolPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/model_poolpatchproperties.go b/resource-manager/netapp/2024-07-01/capacitypools/model_poolpatchproperties.go new file mode 100644 index 00000000000..c971dd8637c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/model_poolpatchproperties.go @@ -0,0 +1,10 @@ +package capacitypools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolPatchProperties struct { + CoolAccess *bool `json:"coolAccess,omitempty"` + QosType *QosType `json:"qosType,omitempty"` + Size *int64 `json:"size,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/model_poolproperties.go b/resource-manager/netapp/2024-07-01/capacitypools/model_poolproperties.go new file mode 100644 index 00000000000..a1fee733fb4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/model_poolproperties.go @@ -0,0 +1,16 @@ +package capacitypools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolProperties struct { + CoolAccess *bool `json:"coolAccess,omitempty"` + EncryptionType *EncryptionType `json:"encryptionType,omitempty"` + PoolId *string `json:"poolId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + QosType *QosType `json:"qosType,omitempty"` + ServiceLevel ServiceLevel `json:"serviceLevel"` + Size int64 `json:"size"` + TotalThroughputMibps *float64 `json:"totalThroughputMibps,omitempty"` + UtilizedThroughputMibps *float64 `json:"utilizedThroughputMibps,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/capacitypools/predicates.go b/resource-manager/netapp/2024-07-01/capacitypools/predicates.go new file mode 100644 index 00000000000..386a7986d42 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/predicates.go @@ -0,0 +1,37 @@ +package capacitypools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityPoolOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p CapacityPoolOperationPredicate) Matches(input CapacityPool) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/netapp/2024-07-01/capacitypools/version.go b/resource-manager/netapp/2024-07-01/capacitypools/version.go new file mode 100644 index 00000000000..455d9d57932 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/capacitypools/version.go @@ -0,0 +1,10 @@ +package capacitypools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/capacitypools/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/client.go b/resource-manager/netapp/2024-07-01/client.go new file mode 100644 index 00000000000..4e9c7da9051 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/client.go @@ -0,0 +1,226 @@ +package v2024_07_01 + +// 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/netapp/2024-07-01/backuppolicy" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/backups" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/backupvaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/capacitypools" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/filelocks" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/groupidlistforldapuser" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/netappaccounts" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/netappresource" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/poolchange" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/resetcifspassword" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/restore" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshotpolicy" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshots" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/subvolumes" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumequotarules" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumes" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesonpremmigration" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesrelocation" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesreplication" + "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesrevert" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + BackupPolicy *backuppolicy.BackupPolicyClient + BackupVaults *backupvaults.BackupVaultsClient + Backups *backups.BackupsClient + CapacityPools *capacitypools.CapacityPoolsClient + FileLocks *filelocks.FileLocksClient + GroupIdListForLDAPUser *groupidlistforldapuser.GroupIdListForLDAPUserClient + NetAppAccounts *netappaccounts.NetAppAccountsClient + NetAppResource *netappresource.NetAppResourceClient + PoolChange *poolchange.PoolChangeClient + ResetCifsPassword *resetcifspassword.ResetCifsPasswordClient + Restore *restore.RestoreClient + SnapshotPolicy *snapshotpolicy.SnapshotPolicyClient + SnapshotPolicyListVolumes *snapshotpolicylistvolumes.SnapshotPolicyListVolumesClient + Snapshots *snapshots.SnapshotsClient + SubVolumes *subvolumes.SubVolumesClient + VolumeGroups *volumegroups.VolumeGroupsClient + VolumeQuotaRules *volumequotarules.VolumeQuotaRulesClient + Volumes *volumes.VolumesClient + VolumesOnPremMigration *volumesonpremmigration.VolumesOnPremMigrationClient + VolumesOnPremMigrationFinalize *volumesonpremmigrationfinalize.VolumesOnPremMigrationFinalizeClient + VolumesRelocation *volumesrelocation.VolumesRelocationClient + VolumesReplication *volumesreplication.VolumesReplicationClient + VolumesRevert *volumesrevert.VolumesRevertClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + backupPolicyClient, err := backuppolicy.NewBackupPolicyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupPolicy client: %+v", err) + } + configureFunc(backupPolicyClient.Client) + + backupVaultsClient, err := backupvaults.NewBackupVaultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupVaults client: %+v", err) + } + configureFunc(backupVaultsClient.Client) + + backupsClient, err := backups.NewBackupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Backups client: %+v", err) + } + configureFunc(backupsClient.Client) + + capacityPoolsClient, err := capacitypools.NewCapacityPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CapacityPools client: %+v", err) + } + configureFunc(capacityPoolsClient.Client) + + fileLocksClient, err := filelocks.NewFileLocksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FileLocks client: %+v", err) + } + configureFunc(fileLocksClient.Client) + + groupIdListForLDAPUserClient, err := groupidlistforldapuser.NewGroupIdListForLDAPUserClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GroupIdListForLDAPUser client: %+v", err) + } + configureFunc(groupIdListForLDAPUserClient.Client) + + netAppAccountsClient, err := netappaccounts.NewNetAppAccountsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetAppAccounts client: %+v", err) + } + configureFunc(netAppAccountsClient.Client) + + netAppResourceClient, err := netappresource.NewNetAppResourceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetAppResource client: %+v", err) + } + configureFunc(netAppResourceClient.Client) + + poolChangeClient, err := poolchange.NewPoolChangeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PoolChange client: %+v", err) + } + configureFunc(poolChangeClient.Client) + + resetCifsPasswordClient, err := resetcifspassword.NewResetCifsPasswordClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResetCifsPassword client: %+v", err) + } + configureFunc(resetCifsPasswordClient.Client) + + restoreClient, err := restore.NewRestoreClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Restore client: %+v", err) + } + configureFunc(restoreClient.Client) + + snapshotPolicyClient, err := snapshotpolicy.NewSnapshotPolicyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SnapshotPolicy client: %+v", err) + } + configureFunc(snapshotPolicyClient.Client) + + snapshotPolicyListVolumesClient, err := snapshotpolicylistvolumes.NewSnapshotPolicyListVolumesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SnapshotPolicyListVolumes client: %+v", err) + } + configureFunc(snapshotPolicyListVolumesClient.Client) + + snapshotsClient, err := snapshots.NewSnapshotsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Snapshots client: %+v", err) + } + configureFunc(snapshotsClient.Client) + + subVolumesClient, err := subvolumes.NewSubVolumesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SubVolumes client: %+v", err) + } + configureFunc(subVolumesClient.Client) + + volumeGroupsClient, err := volumegroups.NewVolumeGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumeGroups client: %+v", err) + } + configureFunc(volumeGroupsClient.Client) + + volumeQuotaRulesClient, err := volumequotarules.NewVolumeQuotaRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumeQuotaRules client: %+v", err) + } + configureFunc(volumeQuotaRulesClient.Client) + + volumesClient, err := volumes.NewVolumesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Volumes client: %+v", err) + } + configureFunc(volumesClient.Client) + + volumesOnPremMigrationClient, err := volumesonpremmigration.NewVolumesOnPremMigrationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumesOnPremMigration client: %+v", err) + } + configureFunc(volumesOnPremMigrationClient.Client) + + volumesOnPremMigrationFinalizeClient, err := volumesonpremmigrationfinalize.NewVolumesOnPremMigrationFinalizeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumesOnPremMigrationFinalize client: %+v", err) + } + configureFunc(volumesOnPremMigrationFinalizeClient.Client) + + volumesRelocationClient, err := volumesrelocation.NewVolumesRelocationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumesRelocation client: %+v", err) + } + configureFunc(volumesRelocationClient.Client) + + volumesReplicationClient, err := volumesreplication.NewVolumesReplicationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumesReplication client: %+v", err) + } + configureFunc(volumesReplicationClient.Client) + + volumesRevertClient, err := volumesrevert.NewVolumesRevertClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VolumesRevert client: %+v", err) + } + configureFunc(volumesRevertClient.Client) + + return &Client{ + BackupPolicy: backupPolicyClient, + BackupVaults: backupVaultsClient, + Backups: backupsClient, + CapacityPools: capacityPoolsClient, + FileLocks: fileLocksClient, + GroupIdListForLDAPUser: groupIdListForLDAPUserClient, + NetAppAccounts: netAppAccountsClient, + NetAppResource: netAppResourceClient, + PoolChange: poolChangeClient, + ResetCifsPassword: resetCifsPasswordClient, + Restore: restoreClient, + SnapshotPolicy: snapshotPolicyClient, + SnapshotPolicyListVolumes: snapshotPolicyListVolumesClient, + Snapshots: snapshotsClient, + SubVolumes: subVolumesClient, + VolumeGroups: volumeGroupsClient, + VolumeQuotaRules: volumeQuotaRulesClient, + Volumes: volumesClient, + VolumesOnPremMigration: volumesOnPremMigrationClient, + VolumesOnPremMigrationFinalize: volumesOnPremMigrationFinalizeClient, + VolumesRelocation: volumesRelocationClient, + VolumesReplication: volumesReplicationClient, + VolumesRevert: volumesRevertClient, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/filelocks/README.md b/resource-manager/netapp/2024-07-01/filelocks/README.md new file mode 100644 index 00000000000..da1dbc489de --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/filelocks` Documentation + +The `filelocks` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/filelocks" +``` + + +### Client Initialization + +```go +client := filelocks.NewFileLocksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FileLocksClient.VolumesBreakFileLocks` + +```go +ctx := context.TODO() +id := filelocks.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := filelocks.BreakFileLocksRequest{ + // ... +} + + +if err := client.VolumesBreakFileLocksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/filelocks/client.go b/resource-manager/netapp/2024-07-01/filelocks/client.go new file mode 100644 index 00000000000..56c8b4fc903 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/client.go @@ -0,0 +1,26 @@ +package filelocks + +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 FileLocksClient struct { + Client *resourcemanager.Client +} + +func NewFileLocksClientWithBaseURI(sdkApi sdkEnv.Api) (*FileLocksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "filelocks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FileLocksClient: %+v", err) + } + + return &FileLocksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/filelocks/id_volume.go b/resource-manager/netapp/2024-07-01/filelocks/id_volume.go new file mode 100644 index 00000000000..660324eb77b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/id_volume.go @@ -0,0 +1,148 @@ +package filelocks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/filelocks/id_volume_test.go b/resource-manager/netapp/2024-07-01/filelocks/id_volume_test.go new file mode 100644 index 00000000000..1ae0d4861ac --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/id_volume_test.go @@ -0,0 +1,372 @@ +package filelocks + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/filelocks/method_volumesbreakfilelocks.go b/resource-manager/netapp/2024-07-01/filelocks/method_volumesbreakfilelocks.go new file mode 100644 index 00000000000..c1ff2b4b86f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/method_volumesbreakfilelocks.go @@ -0,0 +1,74 @@ +package filelocks + +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 VolumesBreakFileLocksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesBreakFileLocks ... +func (c FileLocksClient) VolumesBreakFileLocks(ctx context.Context, id VolumeId, input BreakFileLocksRequest) (result VolumesBreakFileLocksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/breakFileLocks", 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 +} + +// VolumesBreakFileLocksThenPoll performs VolumesBreakFileLocks then polls until it's completed +func (c FileLocksClient) VolumesBreakFileLocksThenPoll(ctx context.Context, id VolumeId, input BreakFileLocksRequest) error { + result, err := c.VolumesBreakFileLocks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesBreakFileLocks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesBreakFileLocks: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/filelocks/model_breakfilelocksrequest.go b/resource-manager/netapp/2024-07-01/filelocks/model_breakfilelocksrequest.go new file mode 100644 index 00000000000..62fa9fc9808 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/model_breakfilelocksrequest.go @@ -0,0 +1,9 @@ +package filelocks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BreakFileLocksRequest struct { + ClientIP *string `json:"clientIp,omitempty"` + ConfirmRunningDisruptiveOperation *bool `json:"confirmRunningDisruptiveOperation,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/filelocks/version.go b/resource-manager/netapp/2024-07-01/filelocks/version.go new file mode 100644 index 00000000000..ce9c36c0baf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/filelocks/version.go @@ -0,0 +1,10 @@ +package filelocks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/filelocks/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/README.md b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/README.md new file mode 100644 index 00000000000..4acfa7a20d6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/groupidlistforldapuser` Documentation + +The `groupidlistforldapuser` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/groupidlistforldapuser" +``` + + +### Client Initialization + +```go +client := groupidlistforldapuser.NewGroupIdListForLDAPUserClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GroupIdListForLDAPUserClient.VolumesListGetGroupIdListForLdapUser` + +```go +ctx := context.TODO() +id := groupidlistforldapuser.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := groupidlistforldapuser.GetGroupIdListForLDAPUserRequest{ + // ... +} + + +if err := client.VolumesListGetGroupIdListForLdapUserThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/client.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/client.go new file mode 100644 index 00000000000..b098cba0063 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/client.go @@ -0,0 +1,26 @@ +package groupidlistforldapuser + +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 GroupIdListForLDAPUserClient struct { + Client *resourcemanager.Client +} + +func NewGroupIdListForLDAPUserClientWithBaseURI(sdkApi sdkEnv.Api) (*GroupIdListForLDAPUserClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "groupidlistforldapuser", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroupIdListForLDAPUserClient: %+v", err) + } + + return &GroupIdListForLDAPUserClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume.go new file mode 100644 index 00000000000..597c3e852ab --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume.go @@ -0,0 +1,148 @@ +package groupidlistforldapuser + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume_test.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume_test.go new file mode 100644 index 00000000000..ad956e12e12 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/id_volume_test.go @@ -0,0 +1,372 @@ +package groupidlistforldapuser + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/groupidlistforldapuser/method_volumeslistgetgroupidlistforldapuser.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/method_volumeslistgetgroupidlistforldapuser.go new file mode 100644 index 00000000000..9c2248727d2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/method_volumeslistgetgroupidlistforldapuser.go @@ -0,0 +1,75 @@ +package groupidlistforldapuser + +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 VolumesListGetGroupIdListForLdapUserOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GetGroupIdListForLDAPUserResponse +} + +// VolumesListGetGroupIdListForLdapUser ... +func (c GroupIdListForLDAPUserClient) VolumesListGetGroupIdListForLdapUser(ctx context.Context, id VolumeId, input GetGroupIdListForLDAPUserRequest) (result VolumesListGetGroupIdListForLdapUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getGroupIdListForLdapUser", 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 +} + +// VolumesListGetGroupIdListForLdapUserThenPoll performs VolumesListGetGroupIdListForLdapUser then polls until it's completed +func (c GroupIdListForLDAPUserClient) VolumesListGetGroupIdListForLdapUserThenPoll(ctx context.Context, id VolumeId, input GetGroupIdListForLDAPUserRequest) error { + result, err := c.VolumesListGetGroupIdListForLdapUser(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesListGetGroupIdListForLdapUser: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesListGetGroupIdListForLdapUser: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserrequest.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserrequest.go new file mode 100644 index 00000000000..797ecd9aa2a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserrequest.go @@ -0,0 +1,8 @@ +package groupidlistforldapuser + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetGroupIdListForLDAPUserRequest struct { + Username string `json:"username"` +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserresponse.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserresponse.go new file mode 100644 index 00000000000..42c528df2f2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/model_getgroupidlistforldapuserresponse.go @@ -0,0 +1,8 @@ +package groupidlistforldapuser + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetGroupIdListForLDAPUserResponse struct { + GroupIdsForLdapUser *[]string `json:"groupIdsForLdapUser,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/groupidlistforldapuser/version.go b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/version.go new file mode 100644 index 00000000000..4e9af58a33b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/groupidlistforldapuser/version.go @@ -0,0 +1,10 @@ +package groupidlistforldapuser + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/groupidlistforldapuser/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/README.md b/resource-manager/netapp/2024-07-01/netappaccounts/README.md new file mode 100644 index 00000000000..77e013567ce --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/netappaccounts` Documentation + +The `netappaccounts` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/netappaccounts" +``` + + +### Client Initialization + +```go +client := netappaccounts.NewNetAppAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetAppAccountsClient.AccountsCreateOrUpdate` + +```go +ctx := context.TODO() +id := netappaccounts.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +payload := netappaccounts.NetAppAccount{ + // ... +} + + +if err := client.AccountsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsDelete` + +```go +ctx := context.TODO() +id := netappaccounts.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +if err := client.AccountsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsGet` + +```go +ctx := context.TODO() +id := netappaccounts.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +read, err := client.AccountsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsList` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.AccountsList(ctx, id)` can be used to do batched pagination +items, err := client.AccountsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.AccountsListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.AccountsListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsRenewCredentials` + +```go +ctx := context.TODO() +id := netappaccounts.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +if err := client.AccountsRenewCredentialsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetAppAccountsClient.AccountsUpdate` + +```go +ctx := context.TODO() +id := netappaccounts.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +payload := netappaccounts.NetAppAccountPatch{ + // ... +} + + +if err := client.AccountsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/client.go b/resource-manager/netapp/2024-07-01/netappaccounts/client.go new file mode 100644 index 00000000000..240204954a3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/client.go @@ -0,0 +1,26 @@ +package netappaccounts + +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 NetAppAccountsClient struct { + Client *resourcemanager.Client +} + +func NewNetAppAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetAppAccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "netappaccounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetAppAccountsClient: %+v", err) + } + + return &NetAppAccountsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/constants.go b/resource-manager/netapp/2024-07-01/netappaccounts/constants.go new file mode 100644 index 00000000000..f8d0489c2a0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/constants.go @@ -0,0 +1,151 @@ +package netappaccounts + +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 ActiveDirectoryStatus string + +const ( + ActiveDirectoryStatusCreated ActiveDirectoryStatus = "Created" + ActiveDirectoryStatusDeleted ActiveDirectoryStatus = "Deleted" + ActiveDirectoryStatusError ActiveDirectoryStatus = "Error" + ActiveDirectoryStatusInUse ActiveDirectoryStatus = "InUse" + ActiveDirectoryStatusUpdating ActiveDirectoryStatus = "Updating" +) + +func PossibleValuesForActiveDirectoryStatus() []string { + return []string{ + string(ActiveDirectoryStatusCreated), + string(ActiveDirectoryStatusDeleted), + string(ActiveDirectoryStatusError), + string(ActiveDirectoryStatusInUse), + string(ActiveDirectoryStatusUpdating), + } +} + +func (s *ActiveDirectoryStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveDirectoryStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveDirectoryStatus(input string) (*ActiveDirectoryStatus, error) { + vals := map[string]ActiveDirectoryStatus{ + "created": ActiveDirectoryStatusCreated, + "deleted": ActiveDirectoryStatusDeleted, + "error": ActiveDirectoryStatusError, + "inuse": ActiveDirectoryStatusInUse, + "updating": ActiveDirectoryStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveDirectoryStatus(input) + return &out, nil +} + +type KeySource string + +const ( + KeySourceMicrosoftPointKeyVault KeySource = "Microsoft.KeyVault" + KeySourceMicrosoftPointNetApp KeySource = "Microsoft.NetApp" +) + +func PossibleValuesForKeySource() []string { + return []string{ + string(KeySourceMicrosoftPointKeyVault), + string(KeySourceMicrosoftPointNetApp), + } +} + +func (s *KeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeySource(input string) (*KeySource, error) { + vals := map[string]KeySource{ + "microsoft.keyvault": KeySourceMicrosoftPointKeyVault, + "microsoft.netapp": KeySourceMicrosoftPointNetApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeySource(input) + return &out, nil +} + +type KeyVaultStatus string + +const ( + KeyVaultStatusCreated KeyVaultStatus = "Created" + KeyVaultStatusDeleted KeyVaultStatus = "Deleted" + KeyVaultStatusError KeyVaultStatus = "Error" + KeyVaultStatusInUse KeyVaultStatus = "InUse" + KeyVaultStatusUpdating KeyVaultStatus = "Updating" +) + +func PossibleValuesForKeyVaultStatus() []string { + return []string{ + string(KeyVaultStatusCreated), + string(KeyVaultStatusDeleted), + string(KeyVaultStatusError), + string(KeyVaultStatusInUse), + string(KeyVaultStatusUpdating), + } +} + +func (s *KeyVaultStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultStatus(input string) (*KeyVaultStatus, error) { + vals := map[string]KeyVaultStatus{ + "created": KeyVaultStatusCreated, + "deleted": KeyVaultStatusDeleted, + "error": KeyVaultStatusError, + "inuse": KeyVaultStatusInUse, + "updating": KeyVaultStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultStatus(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount.go b/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount.go new file mode 100644 index 00000000000..e49b1665e3b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount.go @@ -0,0 +1,130 @@ +package netappaccounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount_test.go new file mode 100644 index 00000000000..ef0ce3e4636 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package netappaccounts + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/netappaccounts/method_accountscreateorupdate.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountscreateorupdate.go new file mode 100644 index 00000000000..42add8d5ac1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountscreateorupdate.go @@ -0,0 +1,75 @@ +package netappaccounts + +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 AccountsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetAppAccount +} + +// AccountsCreateOrUpdate ... +func (c NetAppAccountsClient) AccountsCreateOrUpdate(ctx context.Context, id NetAppAccountId, input NetAppAccount) (result AccountsCreateOrUpdateOperationResponse, 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 +} + +// AccountsCreateOrUpdateThenPoll performs AccountsCreateOrUpdate then polls until it's completed +func (c NetAppAccountsClient) AccountsCreateOrUpdateThenPoll(ctx context.Context, id NetAppAccountId, input NetAppAccount) error { + result, err := c.AccountsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsdelete.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsdelete.go new file mode 100644 index 00000000000..ae46b7b061d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsdelete.go @@ -0,0 +1,70 @@ +package netappaccounts + +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 AccountsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsDelete ... +func (c NetAppAccountsClient) AccountsDelete(ctx context.Context, id NetAppAccountId) (result AccountsDeleteOperationResponse, 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 +} + +// AccountsDeleteThenPoll performs AccountsDelete then polls until it's completed +func (c NetAppAccountsClient) AccountsDeleteThenPoll(ctx context.Context, id NetAppAccountId) error { + result, err := c.AccountsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing AccountsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsget.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsget.go new file mode 100644 index 00000000000..c1ec9504bf9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsget.go @@ -0,0 +1,53 @@ +package netappaccounts + +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 AccountsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetAppAccount +} + +// AccountsGet ... +func (c NetAppAccountsClient) AccountsGet(ctx context.Context, id NetAppAccountId) (result AccountsGetOperationResponse, 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 + } + + var model NetAppAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslist.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslist.go new file mode 100644 index 00000000000..761a210fd34 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslist.go @@ -0,0 +1,106 @@ +package netappaccounts + +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 AccountsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetAppAccount +} + +type AccountsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetAppAccount +} + +type AccountsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AccountsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AccountsList ... +func (c NetAppAccountsClient) AccountsList(ctx context.Context, id commonids.ResourceGroupId) (result AccountsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AccountsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetApp/netAppAccounts", 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 *[]NetAppAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListComplete retrieves all the results into a single object +func (c NetAppAccountsClient) AccountsListComplete(ctx context.Context, id commonids.ResourceGroupId) (AccountsListCompleteResult, error) { + return c.AccountsListCompleteMatchingPredicate(ctx, id, NetAppAccountOperationPredicate{}) +} + +// AccountsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetAppAccountsClient) AccountsListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetAppAccountOperationPredicate) (result AccountsListCompleteResult, err error) { + items := make([]NetAppAccount, 0) + + resp, err := c.AccountsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = AccountsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslistbysubscription.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslistbysubscription.go new file mode 100644 index 00000000000..adea8a00480 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountslistbysubscription.go @@ -0,0 +1,106 @@ +package netappaccounts + +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 AccountsListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetAppAccount +} + +type AccountsListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetAppAccount +} + +type AccountsListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AccountsListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AccountsListBySubscription ... +func (c NetAppAccountsClient) AccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result AccountsListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AccountsListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetApp/netAppAccounts", 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 *[]NetAppAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListBySubscriptionComplete retrieves all the results into a single object +func (c NetAppAccountsClient) AccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (AccountsListBySubscriptionCompleteResult, error) { + return c.AccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, NetAppAccountOperationPredicate{}) +} + +// AccountsListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetAppAccountsClient) AccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetAppAccountOperationPredicate) (result AccountsListBySubscriptionCompleteResult, err error) { + items := make([]NetAppAccount, 0) + + resp, err := c.AccountsListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = AccountsListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsrenewcredentials.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsrenewcredentials.go new file mode 100644 index 00000000000..4d7aca0b151 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsrenewcredentials.go @@ -0,0 +1,70 @@ +package netappaccounts + +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 AccountsRenewCredentialsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsRenewCredentials ... +func (c NetAppAccountsClient) AccountsRenewCredentials(ctx context.Context, id NetAppAccountId) (result AccountsRenewCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renewCredentials", 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 +} + +// AccountsRenewCredentialsThenPoll performs AccountsRenewCredentials then polls until it's completed +func (c NetAppAccountsClient) AccountsRenewCredentialsThenPoll(ctx context.Context, id NetAppAccountId) error { + result, err := c.AccountsRenewCredentials(ctx, id) + if err != nil { + return fmt.Errorf("performing AccountsRenewCredentials: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsRenewCredentials: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsupdate.go b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsupdate.go new file mode 100644 index 00000000000..8957725808a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/method_accountsupdate.go @@ -0,0 +1,75 @@ +package netappaccounts + +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 AccountsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetAppAccount +} + +// AccountsUpdate ... +func (c NetAppAccountsClient) AccountsUpdate(ctx context.Context, id NetAppAccountId, input NetAppAccountPatch) (result AccountsUpdateOperationResponse, 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 +} + +// AccountsUpdateThenPoll performs AccountsUpdate then polls until it's completed +func (c NetAppAccountsClient) AccountsUpdateThenPoll(ctx context.Context, id NetAppAccountId, input NetAppAccountPatch) error { + result, err := c.AccountsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_accountencryption.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_accountencryption.go new file mode 100644 index 00000000000..93f1a662f77 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_accountencryption.go @@ -0,0 +1,10 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountEncryption struct { + Identity *EncryptionIdentity `json:"identity,omitempty"` + KeySource *KeySource `json:"keySource,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_accountproperties.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_accountproperties.go new file mode 100644 index 00000000000..18428908f56 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_accountproperties.go @@ -0,0 +1,11 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountProperties struct { + ActiveDirectories *[]ActiveDirectory `json:"activeDirectories,omitempty"` + DisableShowmount *bool `json:"disableShowmount,omitempty"` + Encryption *AccountEncryption `json:"encryption,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_activedirectory.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_activedirectory.go new file mode 100644 index 00000000000..81bbf0d2927 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_activedirectory.go @@ -0,0 +1,30 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectory struct { + ActiveDirectoryId *string `json:"activeDirectoryId,omitempty"` + AdName *string `json:"adName,omitempty"` + Administrators *[]string `json:"administrators,omitempty"` + AesEncryption *bool `json:"aesEncryption,omitempty"` + AllowLocalNfsUsersWithLdap *bool `json:"allowLocalNfsUsersWithLdap,omitempty"` + BackupOperators *[]string `json:"backupOperators,omitempty"` + Dns *string `json:"dns,omitempty"` + Domain *string `json:"domain,omitempty"` + EncryptDCConnections *bool `json:"encryptDCConnections,omitempty"` + KdcIP *string `json:"kdcIP,omitempty"` + LdapOverTLS *bool `json:"ldapOverTLS,omitempty"` + LdapSearchScope *LdapSearchScopeOpt `json:"ldapSearchScope,omitempty"` + LdapSigning *bool `json:"ldapSigning,omitempty"` + OrganizationalUnit *string `json:"organizationalUnit,omitempty"` + Password *string `json:"password,omitempty"` + PreferredServersForLdapClient *string `json:"preferredServersForLdapClient,omitempty"` + SecurityOperators *[]string `json:"securityOperators,omitempty"` + ServerRootCACertificate *string `json:"serverRootCACertificate,omitempty"` + Site *string `json:"site,omitempty"` + SmbServerName *string `json:"smbServerName,omitempty"` + Status *ActiveDirectoryStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_encryptionidentity.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_encryptionidentity.go new file mode 100644 index 00000000000..50cf4dbf679 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_encryptionidentity.go @@ -0,0 +1,9 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionIdentity struct { + PrincipalId *string `json:"principalId,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_keyvaultproperties.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_keyvaultproperties.go new file mode 100644 index 00000000000..f4722a948a2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_keyvaultproperties.go @@ -0,0 +1,12 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName string `json:"keyName"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultResourceId *string `json:"keyVaultResourceId,omitempty"` + KeyVaultUri string `json:"keyVaultUri"` + Status *KeyVaultStatus `json:"status,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_ldapsearchscopeopt.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_ldapsearchscopeopt.go new file mode 100644 index 00000000000..c476b0f0875 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_ldapsearchscopeopt.go @@ -0,0 +1,10 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LdapSearchScopeOpt struct { + GroupDN *string `json:"groupDN,omitempty"` + GroupMembershipFilter *string `json:"groupMembershipFilter,omitempty"` + UserDN *string `json:"userDN,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/model_netappaccount.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_netappaccount.go new file mode 100644 index 00000000000..ae38663e126 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_netappaccount.go @@ -0,0 +1,21 @@ +package netappaccounts + +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 NetAppAccount struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccountProperties `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/netapp/2024-07-01/netappaccounts/model_netappaccountpatch.go b/resource-manager/netapp/2024-07-01/netappaccounts/model_netappaccountpatch.go new file mode 100644 index 00000000000..9f24bca3d5a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/model_netappaccountpatch.go @@ -0,0 +1,18 @@ +package netappaccounts + +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 NetAppAccountPatch struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AccountProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappaccounts/predicates.go b/resource-manager/netapp/2024-07-01/netappaccounts/predicates.go new file mode 100644 index 00000000000..ad2c0a55483 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/predicates.go @@ -0,0 +1,37 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetAppAccountOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetAppAccountOperationPredicate) Matches(input NetAppAccount) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/netapp/2024-07-01/netappaccounts/version.go b/resource-manager/netapp/2024-07-01/netappaccounts/version.go new file mode 100644 index 00000000000..692f82f5a4f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappaccounts/version.go @@ -0,0 +1,10 @@ +package netappaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/netappaccounts/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/README.md b/resource-manager/netapp/2024-07-01/netappresource/README.md new file mode 100644 index 00000000000..b6bda64ed26 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/README.md @@ -0,0 +1,202 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/netappresource` Documentation + +The `netappresource` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/netappresource" +``` + + +### Client Initialization + +```go +client := netappresource.NewNetAppResourceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetAppResourceClient.CheckFilePathAvailability` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := netappresource.FilePathAvailabilityRequest{ + // ... +} + + +read, err := client.CheckFilePathAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := netappresource.ResourceNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.CheckQuotaAvailability` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := netappresource.QuotaAvailabilityRequest{ + // ... +} + + +read, err := client.CheckQuotaAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.QueryNetworkSiblingSet` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := netappresource.QueryNetworkSiblingSetRequest{ + // ... +} + + +read, err := client.QueryNetworkSiblingSet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.QueryRegionInfo` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.QueryRegionInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.QuotaLimitsGet` + +```go +ctx := context.TODO() +id := netappresource.NewQuotaLimitID("12345678-1234-9876-4563-123456789012", "locationName", "quotaLimitName") + +read, err := client.QuotaLimitsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.QuotaLimitsList` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.QuotaLimitsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.RegionInfosGet` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.RegionInfosGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetAppResourceClient.RegionInfosList` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.RegionInfosList(ctx, id)` can be used to do batched pagination +items, err := client.RegionInfosListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetAppResourceClient.UpdateNetworkSiblingSet` + +```go +ctx := context.TODO() +id := netappresource.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := netappresource.UpdateNetworkSiblingSetRequest{ + // ... +} + + +if err := client.UpdateNetworkSiblingSetThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/netappresource/client.go b/resource-manager/netapp/2024-07-01/netappresource/client.go new file mode 100644 index 00000000000..0bfc3f358ce --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/client.go @@ -0,0 +1,26 @@ +package netappresource + +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 NetAppResourceClient struct { + Client *resourcemanager.Client +} + +func NewNetAppResourceClientWithBaseURI(sdkApi sdkEnv.Api) (*NetAppResourceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "netappresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetAppResourceClient: %+v", err) + } + + return &NetAppResourceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/constants.go b/resource-manager/netapp/2024-07-01/netappresource/constants.go new file mode 100644 index 00000000000..5f4e36630e6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/constants.go @@ -0,0 +1,298 @@ +package netappresource + +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 CheckNameResourceTypes string + +const ( + CheckNameResourceTypesMicrosoftPointNetAppNetAppAccounts CheckNameResourceTypes = "Microsoft.NetApp/netAppAccounts" + CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools CheckNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools" + CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes CheckNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes" + CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots CheckNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes/snapshots" +) + +func PossibleValuesForCheckNameResourceTypes() []string { + return []string{ + string(CheckNameResourceTypesMicrosoftPointNetAppNetAppAccounts), + string(CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools), + string(CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes), + string(CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots), + } +} + +func (s *CheckNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameResourceTypes(input string) (*CheckNameResourceTypes, error) { + vals := map[string]CheckNameResourceTypes{ + "microsoft.netapp/netappaccounts": CheckNameResourceTypesMicrosoftPointNetAppNetAppAccounts, + "microsoft.netapp/netappaccounts/capacitypools": CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools, + "microsoft.netapp/netappaccounts/capacitypools/volumes": CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes, + "microsoft.netapp/netappaccounts/capacitypools/volumes/snapshots": CheckNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameResourceTypes(input) + return &out, nil +} + +type CheckQuotaNameResourceTypes string + +const ( + CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccounts CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts" + CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools" + CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes" + CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes/snapshots" +) + +func PossibleValuesForCheckQuotaNameResourceTypes() []string { + return []string{ + string(CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccounts), + string(CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools), + string(CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes), + string(CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots), + } +} + +func (s *CheckQuotaNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckQuotaNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckQuotaNameResourceTypes(input string) (*CheckQuotaNameResourceTypes, error) { + vals := map[string]CheckQuotaNameResourceTypes{ + "microsoft.netapp/netappaccounts": CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccounts, + "microsoft.netapp/netappaccounts/capacitypools": CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPools, + "microsoft.netapp/netappaccounts/capacitypools/volumes": CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumes, + "microsoft.netapp/netappaccounts/capacitypools/volumes/snapshots": CheckQuotaNameResourceTypesMicrosoftPointNetAppNetAppAccountsCapacityPoolsVolumesSnapshots, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckQuotaNameResourceTypes(input) + return &out, nil +} + +type InAvailabilityReasonType string + +const ( + InAvailabilityReasonTypeAlreadyExists InAvailabilityReasonType = "AlreadyExists" + InAvailabilityReasonTypeInvalid InAvailabilityReasonType = "Invalid" +) + +func PossibleValuesForInAvailabilityReasonType() []string { + return []string{ + string(InAvailabilityReasonTypeAlreadyExists), + string(InAvailabilityReasonTypeInvalid), + } +} + +func (s *InAvailabilityReasonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInAvailabilityReasonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInAvailabilityReasonType(input string) (*InAvailabilityReasonType, error) { + vals := map[string]InAvailabilityReasonType{ + "alreadyexists": InAvailabilityReasonTypeAlreadyExists, + "invalid": InAvailabilityReasonTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InAvailabilityReasonType(input) + return &out, nil +} + +type NetworkFeatures string + +const ( + NetworkFeaturesBasic NetworkFeatures = "Basic" + NetworkFeaturesBasicStandard NetworkFeatures = "Basic_Standard" + NetworkFeaturesStandard NetworkFeatures = "Standard" + NetworkFeaturesStandardBasic NetworkFeatures = "Standard_Basic" +) + +func PossibleValuesForNetworkFeatures() []string { + return []string{ + string(NetworkFeaturesBasic), + string(NetworkFeaturesBasicStandard), + string(NetworkFeaturesStandard), + string(NetworkFeaturesStandardBasic), + } +} + +func (s *NetworkFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkFeatures(input string) (*NetworkFeatures, error) { + vals := map[string]NetworkFeatures{ + "basic": NetworkFeaturesBasic, + "basic_standard": NetworkFeaturesBasicStandard, + "standard": NetworkFeaturesStandard, + "standard_basic": NetworkFeaturesStandardBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkFeatures(input) + return &out, nil +} + +type NetworkSiblingSetProvisioningState string + +const ( + NetworkSiblingSetProvisioningStateCanceled NetworkSiblingSetProvisioningState = "Canceled" + NetworkSiblingSetProvisioningStateFailed NetworkSiblingSetProvisioningState = "Failed" + NetworkSiblingSetProvisioningStateSucceeded NetworkSiblingSetProvisioningState = "Succeeded" + NetworkSiblingSetProvisioningStateUpdating NetworkSiblingSetProvisioningState = "Updating" +) + +func PossibleValuesForNetworkSiblingSetProvisioningState() []string { + return []string{ + string(NetworkSiblingSetProvisioningStateCanceled), + string(NetworkSiblingSetProvisioningStateFailed), + string(NetworkSiblingSetProvisioningStateSucceeded), + string(NetworkSiblingSetProvisioningStateUpdating), + } +} + +func (s *NetworkSiblingSetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkSiblingSetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkSiblingSetProvisioningState(input string) (*NetworkSiblingSetProvisioningState, error) { + vals := map[string]NetworkSiblingSetProvisioningState{ + "canceled": NetworkSiblingSetProvisioningStateCanceled, + "failed": NetworkSiblingSetProvisioningStateFailed, + "succeeded": NetworkSiblingSetProvisioningStateSucceeded, + "updating": NetworkSiblingSetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkSiblingSetProvisioningState(input) + return &out, nil +} + +type RegionStorageToNetworkProximity string + +const ( + RegionStorageToNetworkProximityAcrossTTwo RegionStorageToNetworkProximity = "AcrossT2" + RegionStorageToNetworkProximityDefault RegionStorageToNetworkProximity = "Default" + RegionStorageToNetworkProximityTOne RegionStorageToNetworkProximity = "T1" + RegionStorageToNetworkProximityTOneAndAcrossTTwo RegionStorageToNetworkProximity = "T1AndAcrossT2" + RegionStorageToNetworkProximityTOneAndTTwo RegionStorageToNetworkProximity = "T1AndT2" + RegionStorageToNetworkProximityTOneAndTTwoAndAcrossTTwo RegionStorageToNetworkProximity = "T1AndT2AndAcrossT2" + RegionStorageToNetworkProximityTTwo RegionStorageToNetworkProximity = "T2" + RegionStorageToNetworkProximityTTwoAndAcrossTTwo RegionStorageToNetworkProximity = "T2AndAcrossT2" +) + +func PossibleValuesForRegionStorageToNetworkProximity() []string { + return []string{ + string(RegionStorageToNetworkProximityAcrossTTwo), + string(RegionStorageToNetworkProximityDefault), + string(RegionStorageToNetworkProximityTOne), + string(RegionStorageToNetworkProximityTOneAndAcrossTTwo), + string(RegionStorageToNetworkProximityTOneAndTTwo), + string(RegionStorageToNetworkProximityTOneAndTTwoAndAcrossTTwo), + string(RegionStorageToNetworkProximityTTwo), + string(RegionStorageToNetworkProximityTTwoAndAcrossTTwo), + } +} + +func (s *RegionStorageToNetworkProximity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegionStorageToNetworkProximity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegionStorageToNetworkProximity(input string) (*RegionStorageToNetworkProximity, error) { + vals := map[string]RegionStorageToNetworkProximity{ + "acrosst2": RegionStorageToNetworkProximityAcrossTTwo, + "default": RegionStorageToNetworkProximityDefault, + "t1": RegionStorageToNetworkProximityTOne, + "t1andacrosst2": RegionStorageToNetworkProximityTOneAndAcrossTTwo, + "t1andt2": RegionStorageToNetworkProximityTOneAndTTwo, + "t1andt2andacrosst2": RegionStorageToNetworkProximityTOneAndTTwoAndAcrossTTwo, + "t2": RegionStorageToNetworkProximityTTwo, + "t2andacrosst2": RegionStorageToNetworkProximityTTwoAndAcrossTTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegionStorageToNetworkProximity(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/id_location.go b/resource-manager/netapp/2024-07-01/netappresource/id_location.go new file mode 100644 index 00000000000..7f5f70c69df --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/id_location.go @@ -0,0 +1,121 @@ +package netappresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.NetApp/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/id_location_test.go b/resource-manager/netapp/2024-07-01/netappresource/id_location_test.go new file mode 100644 index 00000000000..6e374aa4ecb --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/id_location_test.go @@ -0,0 +1,237 @@ +package netappresource + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/netapp/2024-07-01/netappresource/id_quotalimit.go b/resource-manager/netapp/2024-07-01/netappresource/id_quotalimit.go new file mode 100644 index 00000000000..b35ac4de378 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/id_quotalimit.go @@ -0,0 +1,130 @@ +package netappresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&QuotaLimitId{}) +} + +var _ resourceids.ResourceId = &QuotaLimitId{} + +// QuotaLimitId is a struct representing the Resource ID for a Quota Limit +type QuotaLimitId struct { + SubscriptionId string + LocationName string + QuotaLimitName string +} + +// NewQuotaLimitID returns a new QuotaLimitId struct +func NewQuotaLimitID(subscriptionId string, locationName string, quotaLimitName string) QuotaLimitId { + return QuotaLimitId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + QuotaLimitName: quotaLimitName, + } +} + +// ParseQuotaLimitID parses 'input' into a QuotaLimitId +func ParseQuotaLimitID(input string) (*QuotaLimitId, error) { + parser := resourceids.NewParserFromResourceIdType(&QuotaLimitId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QuotaLimitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQuotaLimitIDInsensitively parses 'input' case-insensitively into a QuotaLimitId +// note: this method should only be used for API response data and not user input +func ParseQuotaLimitIDInsensitively(input string) (*QuotaLimitId, error) { + parser := resourceids.NewParserFromResourceIdType(&QuotaLimitId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QuotaLimitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QuotaLimitId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.QuotaLimitName, ok = input.Parsed["quotaLimitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "quotaLimitName", input) + } + + return nil +} + +// ValidateQuotaLimitID checks that 'input' can be parsed as a Quota Limit ID +func ValidateQuotaLimitID(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 := ParseQuotaLimitID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Quota Limit ID +func (id QuotaLimitId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.NetApp/locations/%s/quotaLimits/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.QuotaLimitName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Quota Limit ID +func (id QuotaLimitId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticQuotaLimits", "quotaLimits", "quotaLimits"), + resourceids.UserSpecifiedSegment("quotaLimitName", "quotaLimitName"), + } +} + +// String returns a human-readable description of this Quota Limit ID +func (id QuotaLimitId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Quota Limit Name: %q", id.QuotaLimitName), + } + return fmt.Sprintf("Quota Limit (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/id_quotalimit_test.go b/resource-manager/netapp/2024-07-01/netappresource/id_quotalimit_test.go new file mode 100644 index 00000000000..3d154522c0a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/id_quotalimit_test.go @@ -0,0 +1,282 @@ +package netappresource + +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 = &QuotaLimitId{} + +func TestNewQuotaLimitID(t *testing.T) { + id := NewQuotaLimitID("12345678-1234-9876-4563-123456789012", "locationName", "quotaLimitName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.QuotaLimitName != "quotaLimitName" { + t.Fatalf("Expected %q but got %q for Segment 'QuotaLimitName'", id.QuotaLimitName, "quotaLimitName") + } +} + +func TestFormatQuotaLimitID(t *testing.T) { + actual := NewQuotaLimitID("12345678-1234-9876-4563-123456789012", "locationName", "quotaLimitName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits/quotaLimitName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQuotaLimitID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QuotaLimitId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits/quotaLimitName", + Expected: &QuotaLimitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + QuotaLimitName: "quotaLimitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits/quotaLimitName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQuotaLimitID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.QuotaLimitName != v.Expected.QuotaLimitName { + t.Fatalf("Expected %q but got %q for QuotaLimitName", v.Expected.QuotaLimitName, actual.QuotaLimitName) + } + + } +} + +func TestParseQuotaLimitIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QuotaLimitId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE/qUoTaLiMiTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits/quotaLimitName", + Expected: &QuotaLimitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + QuotaLimitName: "quotaLimitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetApp/locations/locationName/quotaLimits/quotaLimitName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE/qUoTaLiMiTs/qUoTaLiMiTnAmE", + Expected: &QuotaLimitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + QuotaLimitName: "qUoTaLiMiTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtApP/lOcAtIoNs/lOcAtIoNnAmE/qUoTaLiMiTs/qUoTaLiMiTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQuotaLimitIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.QuotaLimitName != v.Expected.QuotaLimitName { + t.Fatalf("Expected %q but got %q for QuotaLimitName", v.Expected.QuotaLimitName, actual.QuotaLimitName) + } + + } +} + +func TestSegmentsForQuotaLimitId(t *testing.T) { + segments := QuotaLimitId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QuotaLimitId 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/netapp/2024-07-01/netappresource/method_checkfilepathavailability.go b/resource-manager/netapp/2024-07-01/netappresource/method_checkfilepathavailability.go new file mode 100644 index 00000000000..fcd3daa5d29 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_checkfilepathavailability.go @@ -0,0 +1,58 @@ +package netappresource + +import ( + "context" + "fmt" + "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 CheckFilePathAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckAvailabilityResponse +} + +// CheckFilePathAvailability ... +func (c NetAppResourceClient) CheckFilePathAvailability(ctx context.Context, id LocationId, input FilePathAvailabilityRequest) (result CheckFilePathAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkFilePathAvailability", 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 + } + + var model CheckAvailabilityResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_checknameavailability.go b/resource-manager/netapp/2024-07-01/netappresource/method_checknameavailability.go new file mode 100644 index 00000000000..788eb6035e5 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_checknameavailability.go @@ -0,0 +1,58 @@ +package netappresource + +import ( + "context" + "fmt" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckAvailabilityResponse +} + +// CheckNameAvailability ... +func (c NetAppResourceClient) CheckNameAvailability(ctx context.Context, id LocationId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 + } + + var model CheckAvailabilityResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_checkquotaavailability.go b/resource-manager/netapp/2024-07-01/netappresource/method_checkquotaavailability.go new file mode 100644 index 00000000000..75b1541b588 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_checkquotaavailability.go @@ -0,0 +1,58 @@ +package netappresource + +import ( + "context" + "fmt" + "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 CheckQuotaAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckAvailabilityResponse +} + +// CheckQuotaAvailability ... +func (c NetAppResourceClient) CheckQuotaAvailability(ctx context.Context, id LocationId, input QuotaAvailabilityRequest) (result CheckQuotaAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkQuotaAvailability", 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 + } + + var model CheckAvailabilityResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_querynetworksiblingset.go b/resource-manager/netapp/2024-07-01/netappresource/method_querynetworksiblingset.go new file mode 100644 index 00000000000..1777bea9e98 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_querynetworksiblingset.go @@ -0,0 +1,58 @@ +package netappresource + +import ( + "context" + "fmt" + "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 QueryNetworkSiblingSetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSiblingSet +} + +// QueryNetworkSiblingSet ... +func (c NetAppResourceClient) QueryNetworkSiblingSet(ctx context.Context, id LocationId, input QueryNetworkSiblingSetRequest) (result QueryNetworkSiblingSetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryNetworkSiblingSet", 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 + } + + var model NetworkSiblingSet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_queryregioninfo.go b/resource-manager/netapp/2024-07-01/netappresource/method_queryregioninfo.go new file mode 100644 index 00000000000..dc45f121299 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_queryregioninfo.go @@ -0,0 +1,54 @@ +package netappresource + +import ( + "context" + "fmt" + "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 QueryRegionInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RegionInfo +} + +// QueryRegionInfo ... +func (c NetAppResourceClient) QueryRegionInfo(ctx context.Context, id LocationId) (result QueryRegionInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/regionInfo", 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 + } + + var model RegionInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitsget.go b/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitsget.go new file mode 100644 index 00000000000..cd1492d82a8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitsget.go @@ -0,0 +1,53 @@ +package netappresource + +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 QuotaLimitsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionQuotaItem +} + +// QuotaLimitsGet ... +func (c NetAppResourceClient) QuotaLimitsGet(ctx context.Context, id QuotaLimitId) (result QuotaLimitsGetOperationResponse, 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 + } + + var model SubscriptionQuotaItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitslist.go b/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitslist.go new file mode 100644 index 00000000000..81645f131b0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_quotalimitslist.go @@ -0,0 +1,54 @@ +package netappresource + +import ( + "context" + "fmt" + "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 QuotaLimitsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionQuotaItemList +} + +// QuotaLimitsList ... +func (c NetAppResourceClient) QuotaLimitsList(ctx context.Context, id LocationId) (result QuotaLimitsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/quotaLimits", 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 + } + + var model SubscriptionQuotaItemList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_regioninfosget.go b/resource-manager/netapp/2024-07-01/netappresource/method_regioninfosget.go new file mode 100644 index 00000000000..89e4991022d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_regioninfosget.go @@ -0,0 +1,54 @@ +package netappresource + +import ( + "context" + "fmt" + "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 RegionInfosGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RegionInfoResource +} + +// RegionInfosGet ... +func (c NetAppResourceClient) RegionInfosGet(ctx context.Context, id LocationId) (result RegionInfosGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/regionInfos/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 + } + + var model RegionInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_regioninfoslist.go b/resource-manager/netapp/2024-07-01/netappresource/method_regioninfoslist.go new file mode 100644 index 00000000000..87038bafe2a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_regioninfoslist.go @@ -0,0 +1,105 @@ +package netappresource + +import ( + "context" + "fmt" + "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 RegionInfosListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegionInfoResource +} + +type RegionInfosListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RegionInfoResource +} + +type RegionInfosListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegionInfosListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegionInfosList ... +func (c NetAppResourceClient) RegionInfosList(ctx context.Context, id LocationId) (result RegionInfosListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RegionInfosListCustomPager{}, + Path: fmt.Sprintf("%s/regionInfos", 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 *[]RegionInfoResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegionInfosListComplete retrieves all the results into a single object +func (c NetAppResourceClient) RegionInfosListComplete(ctx context.Context, id LocationId) (RegionInfosListCompleteResult, error) { + return c.RegionInfosListCompleteMatchingPredicate(ctx, id, RegionInfoResourceOperationPredicate{}) +} + +// RegionInfosListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetAppResourceClient) RegionInfosListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate RegionInfoResourceOperationPredicate) (result RegionInfosListCompleteResult, err error) { + items := make([]RegionInfoResource, 0) + + resp, err := c.RegionInfosList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RegionInfosListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/method_updatenetworksiblingset.go b/resource-manager/netapp/2024-07-01/netappresource/method_updatenetworksiblingset.go new file mode 100644 index 00000000000..47e6dd6cba8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/method_updatenetworksiblingset.go @@ -0,0 +1,75 @@ +package netappresource + +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 UpdateNetworkSiblingSetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSiblingSet +} + +// UpdateNetworkSiblingSet ... +func (c NetAppResourceClient) UpdateNetworkSiblingSet(ctx context.Context, id LocationId, input UpdateNetworkSiblingSetRequest) (result UpdateNetworkSiblingSetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateNetworkSiblingSet", 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 +} + +// UpdateNetworkSiblingSetThenPoll performs UpdateNetworkSiblingSet then polls until it's completed +func (c NetAppResourceClient) UpdateNetworkSiblingSetThenPoll(ctx context.Context, id LocationId, input UpdateNetworkSiblingSetRequest) error { + result, err := c.UpdateNetworkSiblingSet(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateNetworkSiblingSet: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateNetworkSiblingSet: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_checkavailabilityresponse.go b/resource-manager/netapp/2024-07-01/netappresource/model_checkavailabilityresponse.go new file mode 100644 index 00000000000..6423d9de076 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_checkavailabilityresponse.go @@ -0,0 +1,10 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckAvailabilityResponse struct { + IsAvailable *bool `json:"isAvailable,omitempty"` + Message *string `json:"message,omitempty"` + Reason *InAvailabilityReasonType `json:"reason,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_filepathavailabilityrequest.go b/resource-manager/netapp/2024-07-01/netappresource/model_filepathavailabilityrequest.go new file mode 100644 index 00000000000..41575ebe014 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_filepathavailabilityrequest.go @@ -0,0 +1,10 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FilePathAvailabilityRequest struct { + AvailabilityZone *string `json:"availabilityZone,omitempty"` + Name string `json:"name"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_networksiblingset.go b/resource-manager/netapp/2024-07-01/netappresource/model_networksiblingset.go new file mode 100644 index 00000000000..6873f71c613 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_networksiblingset.go @@ -0,0 +1,13 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSiblingSet struct { + NetworkFeatures *NetworkFeatures `json:"networkFeatures,omitempty"` + NetworkSiblingSetId *string `json:"networkSiblingSetId,omitempty"` + NetworkSiblingSetStateId *string `json:"networkSiblingSetStateId,omitempty"` + NicInfoList *[]NicInfo `json:"nicInfoList,omitempty"` + ProvisioningState *NetworkSiblingSetProvisioningState `json:"provisioningState,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_nicinfo.go b/resource-manager/netapp/2024-07-01/netappresource/model_nicinfo.go new file mode 100644 index 00000000000..5ee50025a75 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_nicinfo.go @@ -0,0 +1,9 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NicInfo struct { + IPAddress *string `json:"ipAddress,omitempty"` + VolumeResourceIds *[]string `json:"volumeResourceIds,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_querynetworksiblingsetrequest.go b/resource-manager/netapp/2024-07-01/netappresource/model_querynetworksiblingsetrequest.go new file mode 100644 index 00000000000..35c102048c3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_querynetworksiblingsetrequest.go @@ -0,0 +1,9 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryNetworkSiblingSetRequest struct { + NetworkSiblingSetId string `json:"networkSiblingSetId"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_quotaavailabilityrequest.go b/resource-manager/netapp/2024-07-01/netappresource/model_quotaavailabilityrequest.go new file mode 100644 index 00000000000..d8df9ac4cef --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_quotaavailabilityrequest.go @@ -0,0 +1,10 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaAvailabilityRequest struct { + Name string `json:"name"` + ResourceGroup string `json:"resourceGroup"` + Type CheckQuotaNameResourceTypes `json:"type"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_regioninfo.go b/resource-manager/netapp/2024-07-01/netappresource/model_regioninfo.go new file mode 100644 index 00000000000..63c92a72c98 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_regioninfo.go @@ -0,0 +1,9 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionInfo struct { + AvailabilityZoneMappings *[]RegionInfoAvailabilityZoneMappingsInlined `json:"availabilityZoneMappings,omitempty"` + StorageToNetworkProximity *RegionStorageToNetworkProximity `json:"storageToNetworkProximity,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_regioninfoavailabilityzonemappingsinlined.go b/resource-manager/netapp/2024-07-01/netappresource/model_regioninfoavailabilityzonemappingsinlined.go new file mode 100644 index 00000000000..36fce7489dc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_regioninfoavailabilityzonemappingsinlined.go @@ -0,0 +1,9 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionInfoAvailabilityZoneMappingsInlined struct { + AvailabilityZone *string `json:"availabilityZone,omitempty"` + IsAvailable *bool `json:"isAvailable,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_regioninforesource.go b/resource-manager/netapp/2024-07-01/netappresource/model_regioninforesource.go new file mode 100644 index 00000000000..9e9a94461d9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_regioninforesource.go @@ -0,0 +1,16 @@ +package netappresource + +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 RegionInfoResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RegionInfo `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_resourcenameavailabilityrequest.go b/resource-manager/netapp/2024-07-01/netappresource/model_resourcenameavailabilityrequest.go new file mode 100644 index 00000000000..0bfbaf4c0e9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_resourcenameavailabilityrequest.go @@ -0,0 +1,10 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailabilityRequest struct { + Name string `json:"name"` + ResourceGroup string `json:"resourceGroup"` + Type CheckNameResourceTypes `json:"type"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitem.go b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitem.go new file mode 100644 index 00000000000..88a5cbd39c1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitem.go @@ -0,0 +1,16 @@ +package netappresource + +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 SubscriptionQuotaItem struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubscriptionQuotaItemProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemlist.go b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemlist.go new file mode 100644 index 00000000000..800319869a1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemlist.go @@ -0,0 +1,8 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionQuotaItemList struct { + Value *[]SubscriptionQuotaItem `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemproperties.go b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemproperties.go new file mode 100644 index 00000000000..01cdd538c05 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_subscriptionquotaitemproperties.go @@ -0,0 +1,9 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionQuotaItemProperties struct { + Current *int64 `json:"current,omitempty"` + Default *int64 `json:"default,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/model_updatenetworksiblingsetrequest.go b/resource-manager/netapp/2024-07-01/netappresource/model_updatenetworksiblingsetrequest.go new file mode 100644 index 00000000000..ea780814344 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/model_updatenetworksiblingsetrequest.go @@ -0,0 +1,11 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateNetworkSiblingSetRequest struct { + NetworkFeatures NetworkFeatures `json:"networkFeatures"` + NetworkSiblingSetId string `json:"networkSiblingSetId"` + NetworkSiblingSetStateId string `json:"networkSiblingSetStateId"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/netapp/2024-07-01/netappresource/predicates.go b/resource-manager/netapp/2024-07-01/netappresource/predicates.go new file mode 100644 index 00000000000..cbc494a4360 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/predicates.go @@ -0,0 +1,27 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionInfoResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RegionInfoResourceOperationPredicate) Matches(input RegionInfoResource) 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/netapp/2024-07-01/netappresource/version.go b/resource-manager/netapp/2024-07-01/netappresource/version.go new file mode 100644 index 00000000000..e81571d074f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/netappresource/version.go @@ -0,0 +1,10 @@ +package netappresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/netappresource/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/poolchange/README.md b/resource-manager/netapp/2024-07-01/poolchange/README.md new file mode 100644 index 00000000000..fc664adfa14 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/poolchange` Documentation + +The `poolchange` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/poolchange" +``` + + +### Client Initialization + +```go +client := poolchange.NewPoolChangeClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PoolChangeClient.VolumesPoolChange` + +```go +ctx := context.TODO() +id := poolchange.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := poolchange.PoolChangeRequest{ + // ... +} + + +if err := client.VolumesPoolChangeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/poolchange/client.go b/resource-manager/netapp/2024-07-01/poolchange/client.go new file mode 100644 index 00000000000..a83eadc3fe1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/client.go @@ -0,0 +1,26 @@ +package poolchange + +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 PoolChangeClient struct { + Client *resourcemanager.Client +} + +func NewPoolChangeClientWithBaseURI(sdkApi sdkEnv.Api) (*PoolChangeClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "poolchange", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PoolChangeClient: %+v", err) + } + + return &PoolChangeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/poolchange/id_volume.go b/resource-manager/netapp/2024-07-01/poolchange/id_volume.go new file mode 100644 index 00000000000..db883b5bdcb --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/id_volume.go @@ -0,0 +1,148 @@ +package poolchange + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/poolchange/id_volume_test.go b/resource-manager/netapp/2024-07-01/poolchange/id_volume_test.go new file mode 100644 index 00000000000..85f31b29d70 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/id_volume_test.go @@ -0,0 +1,372 @@ +package poolchange + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/poolchange/method_volumespoolchange.go b/resource-manager/netapp/2024-07-01/poolchange/method_volumespoolchange.go new file mode 100644 index 00000000000..7a0ca0e6450 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/method_volumespoolchange.go @@ -0,0 +1,74 @@ +package poolchange + +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 VolumesPoolChangeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesPoolChange ... +func (c PoolChangeClient) VolumesPoolChange(ctx context.Context, id VolumeId, input PoolChangeRequest) (result VolumesPoolChangeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/poolChange", 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 +} + +// VolumesPoolChangeThenPoll performs VolumesPoolChange then polls until it's completed +func (c PoolChangeClient) VolumesPoolChangeThenPoll(ctx context.Context, id VolumeId, input PoolChangeRequest) error { + result, err := c.VolumesPoolChange(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesPoolChange: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesPoolChange: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/poolchange/model_poolchangerequest.go b/resource-manager/netapp/2024-07-01/poolchange/model_poolchangerequest.go new file mode 100644 index 00000000000..19402a5b699 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/model_poolchangerequest.go @@ -0,0 +1,8 @@ +package poolchange + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolChangeRequest struct { + NewPoolResourceId string `json:"newPoolResourceId"` +} diff --git a/resource-manager/netapp/2024-07-01/poolchange/version.go b/resource-manager/netapp/2024-07-01/poolchange/version.go new file mode 100644 index 00000000000..01ddfcc6e75 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/poolchange/version.go @@ -0,0 +1,10 @@ +package poolchange + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/poolchange/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/resetcifspassword/client.go b/resource-manager/netapp/2024-07-01/resetcifspassword/client.go new file mode 100644 index 00000000000..ba2cbb22bb0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/resetcifspassword/client.go @@ -0,0 +1,26 @@ +package resetcifspassword + +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 ResetCifsPasswordClient struct { + Client *resourcemanager.Client +} + +func NewResetCifsPasswordClientWithBaseURI(sdkApi sdkEnv.Api) (*ResetCifsPasswordClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resetcifspassword", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResetCifsPasswordClient: %+v", err) + } + + return &ResetCifsPasswordClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume.go b/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume.go new file mode 100644 index 00000000000..c5a2844bb7b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume.go @@ -0,0 +1,148 @@ +package resetcifspassword + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume_test.go b/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume_test.go new file mode 100644 index 00000000000..0b3b2133026 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/resetcifspassword/id_volume_test.go @@ -0,0 +1,372 @@ +package resetcifspassword + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/resetcifspassword/method_volumesresetcifspassword.go b/resource-manager/netapp/2024-07-01/resetcifspassword/method_volumesresetcifspassword.go new file mode 100644 index 00000000000..d8bdd81cd6f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/resetcifspassword/method_volumesresetcifspassword.go @@ -0,0 +1,69 @@ +package resetcifspassword + +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 VolumesResetCifsPasswordOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesResetCifsPassword ... +func (c ResetCifsPasswordClient) VolumesResetCifsPassword(ctx context.Context, id VolumeId) (result VolumesResetCifsPasswordOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetCifsPassword", 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 +} + +// VolumesResetCifsPasswordThenPoll performs VolumesResetCifsPassword then polls until it's completed +func (c ResetCifsPasswordClient) VolumesResetCifsPasswordThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesResetCifsPassword(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesResetCifsPassword: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesResetCifsPassword: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/resetcifspassword/version.go b/resource-manager/netapp/2024-07-01/resetcifspassword/version.go new file mode 100644 index 00000000000..861e83c6b0a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/resetcifspassword/version.go @@ -0,0 +1,10 @@ +package resetcifspassword + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resetcifspassword/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/restore/README.md b/resource-manager/netapp/2024-07-01/restore/README.md new file mode 100644 index 00000000000..d16e258b2e9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/restore` Documentation + +The `restore` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/restore" +``` + + +### Client Initialization + +```go +client := restore.NewRestoreClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RestoreClient.BackupsGetVolumeLatestRestoreStatus` + +```go +ctx := context.TODO() +id := restore.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.BackupsGetVolumeLatestRestoreStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/netapp/2024-07-01/restore/client.go b/resource-manager/netapp/2024-07-01/restore/client.go new file mode 100644 index 00000000000..1ce453be7c3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/client.go @@ -0,0 +1,26 @@ +package restore + +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 RestoreClient struct { + Client *resourcemanager.Client +} + +func NewRestoreClientWithBaseURI(sdkApi sdkEnv.Api) (*RestoreClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "restore", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RestoreClient: %+v", err) + } + + return &RestoreClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/restore/constants.go b/resource-manager/netapp/2024-07-01/restore/constants.go new file mode 100644 index 00000000000..c734520711f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/constants.go @@ -0,0 +1,101 @@ +package restore + +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 MirrorState string + +const ( + MirrorStateBroken MirrorState = "Broken" + MirrorStateMirrored MirrorState = "Mirrored" + MirrorStateUninitialized MirrorState = "Uninitialized" +) + +func PossibleValuesForMirrorState() []string { + return []string{ + string(MirrorStateBroken), + string(MirrorStateMirrored), + string(MirrorStateUninitialized), + } +} + +func (s *MirrorState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMirrorState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMirrorState(input string) (*MirrorState, error) { + vals := map[string]MirrorState{ + "broken": MirrorStateBroken, + "mirrored": MirrorStateMirrored, + "uninitialized": MirrorStateUninitialized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MirrorState(input) + return &out, nil +} + +type RelationshipStatus string + +const ( + RelationshipStatusFailed RelationshipStatus = "Failed" + RelationshipStatusIdle RelationshipStatus = "Idle" + RelationshipStatusTransferring RelationshipStatus = "Transferring" + RelationshipStatusUnknown RelationshipStatus = "Unknown" +) + +func PossibleValuesForRelationshipStatus() []string { + return []string{ + string(RelationshipStatusFailed), + string(RelationshipStatusIdle), + string(RelationshipStatusTransferring), + string(RelationshipStatusUnknown), + } +} + +func (s *RelationshipStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelationshipStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRelationshipStatus(input string) (*RelationshipStatus, error) { + vals := map[string]RelationshipStatus{ + "failed": RelationshipStatusFailed, + "idle": RelationshipStatusIdle, + "transferring": RelationshipStatusTransferring, + "unknown": RelationshipStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RelationshipStatus(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/restore/id_volume.go b/resource-manager/netapp/2024-07-01/restore/id_volume.go new file mode 100644 index 00000000000..9e76588a555 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/id_volume.go @@ -0,0 +1,148 @@ +package restore + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/restore/id_volume_test.go b/resource-manager/netapp/2024-07-01/restore/id_volume_test.go new file mode 100644 index 00000000000..7762bc57cb4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/id_volume_test.go @@ -0,0 +1,372 @@ +package restore + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/restore/method_backupsgetvolumelatestrestorestatus.go b/resource-manager/netapp/2024-07-01/restore/method_backupsgetvolumelatestrestorestatus.go new file mode 100644 index 00000000000..42b453d7f1a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/method_backupsgetvolumelatestrestorestatus.go @@ -0,0 +1,54 @@ +package restore + +import ( + "context" + "fmt" + "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 BackupsGetVolumeLatestRestoreStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreStatus +} + +// BackupsGetVolumeLatestRestoreStatus ... +func (c RestoreClient) BackupsGetVolumeLatestRestoreStatus(ctx context.Context, id VolumeId) (result BackupsGetVolumeLatestRestoreStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/latestRestoreStatus/current", 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 + } + + var model RestoreStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/restore/model_restorestatus.go b/resource-manager/netapp/2024-07-01/restore/model_restorestatus.go new file mode 100644 index 00000000000..546d31e9ce7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/model_restorestatus.go @@ -0,0 +1,13 @@ +package restore + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreStatus struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Healthy *bool `json:"healthy,omitempty"` + MirrorState *MirrorState `json:"mirrorState,omitempty"` + RelationshipStatus *RelationshipStatus `json:"relationshipStatus,omitempty"` + TotalTransferBytes *int64 `json:"totalTransferBytes,omitempty"` + UnhealthyReason *string `json:"unhealthyReason,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/restore/version.go b/resource-manager/netapp/2024-07-01/restore/version.go new file mode 100644 index 00000000000..8eef4acdf4c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/restore/version.go @@ -0,0 +1,10 @@ +package restore + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/restore/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/README.md b/resource-manager/netapp/2024-07-01/snapshotpolicy/README.md new file mode 100644 index 00000000000..0667ddcf6c1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/README.md @@ -0,0 +1,102 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshotpolicy` Documentation + +The `snapshotpolicy` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/snapshotpolicy" +``` + + +### Client Initialization + +```go +client := snapshotpolicy.NewSnapshotPolicyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SnapshotPolicyClient.SnapshotPoliciesCreate` + +```go +ctx := context.TODO() +id := snapshotpolicy.NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + +payload := snapshotpolicy.SnapshotPolicy{ + // ... +} + + +read, err := client.SnapshotPoliciesCreate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotPolicyClient.SnapshotPoliciesDelete` + +```go +ctx := context.TODO() +id := snapshotpolicy.NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + +if err := client.SnapshotPoliciesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SnapshotPolicyClient.SnapshotPoliciesGet` + +```go +ctx := context.TODO() +id := snapshotpolicy.NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + +read, err := client.SnapshotPoliciesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotPolicyClient.SnapshotPoliciesList` + +```go +ctx := context.TODO() +id := snapshotpolicy.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +read, err := client.SnapshotPoliciesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotPolicyClient.SnapshotPoliciesUpdate` + +```go +ctx := context.TODO() +id := snapshotpolicy.NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + +payload := snapshotpolicy.SnapshotPolicyPatch{ + // ... +} + + +if err := client.SnapshotPoliciesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/client.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/client.go new file mode 100644 index 00000000000..e92eedba749 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/client.go @@ -0,0 +1,26 @@ +package snapshotpolicy + +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 SnapshotPolicyClient struct { + Client *resourcemanager.Client +} + +func NewSnapshotPolicyClientWithBaseURI(sdkApi sdkEnv.Api) (*SnapshotPolicyClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "snapshotpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SnapshotPolicyClient: %+v", err) + } + + return &SnapshotPolicyClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount.go new file mode 100644 index 00000000000..14deafbb222 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount.go @@ -0,0 +1,130 @@ +package snapshotpolicy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount_test.go new file mode 100644 index 00000000000..37ac2f7a327 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package snapshotpolicy + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy.go new file mode 100644 index 00000000000..0f5ca81ebc0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy.go @@ -0,0 +1,139 @@ +package snapshotpolicy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SnapshotPolicyId{}) +} + +var _ resourceids.ResourceId = &SnapshotPolicyId{} + +// SnapshotPolicyId is a struct representing the Resource ID for a Snapshot Policy +type SnapshotPolicyId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + SnapshotPolicyName string +} + +// NewSnapshotPolicyID returns a new SnapshotPolicyId struct +func NewSnapshotPolicyID(subscriptionId string, resourceGroupName string, netAppAccountName string, snapshotPolicyName string) SnapshotPolicyId { + return SnapshotPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + SnapshotPolicyName: snapshotPolicyName, + } +} + +// ParseSnapshotPolicyID parses 'input' into a SnapshotPolicyId +func ParseSnapshotPolicyID(input string) (*SnapshotPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotPolicyIDInsensitively parses 'input' case-insensitively into a SnapshotPolicyId +// note: this method should only be used for API response data and not user input +func ParseSnapshotPolicyIDInsensitively(input string) (*SnapshotPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotPolicyId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.SnapshotPolicyName, ok = input.Parsed["snapshotPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotPolicyName", input) + } + + return nil +} + +// ValidateSnapshotPolicyID checks that 'input' can be parsed as a Snapshot Policy ID +func ValidateSnapshotPolicyID(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 := ParseSnapshotPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot Policy ID +func (id SnapshotPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/snapshotPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.SnapshotPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot Policy ID +func (id SnapshotPolicyId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticSnapshotPolicies", "snapshotPolicies", "snapshotPolicies"), + resourceids.UserSpecifiedSegment("snapshotPolicyName", "snapshotPolicyName"), + } +} + +// String returns a human-readable description of this Snapshot Policy ID +func (id SnapshotPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Snapshot Policy Name: %q", id.SnapshotPolicyName), + } + return fmt.Sprintf("Snapshot Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy_test.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy_test.go new file mode 100644 index 00000000000..47db3863892 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/id_snapshotpolicy_test.go @@ -0,0 +1,327 @@ +package snapshotpolicy + +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 = &SnapshotPolicyId{} + +func TestNewSnapshotPolicyID(t *testing.T) { + id := NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.SnapshotPolicyName != "snapshotPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotPolicyName'", id.SnapshotPolicyName, "snapshotPolicyName") + } +} + +func TestFormatSnapshotPolicyID(t *testing.T) { + actual := NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + SnapshotPolicyName: "snapshotPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotPolicyID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.SnapshotPolicyName != v.Expected.SnapshotPolicyName { + t.Fatalf("Expected %q but got %q for SnapshotPolicyName", v.Expected.SnapshotPolicyName, actual.SnapshotPolicyName) + } + + } +} + +func TestParseSnapshotPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + SnapshotPolicyName: "snapshotPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS/sNaPsHoTpOlIcYnAmE", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + SnapshotPolicyName: "sNaPsHoTpOlIcYnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS/sNaPsHoTpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotPolicyIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.SnapshotPolicyName != v.Expected.SnapshotPolicyName { + t.Fatalf("Expected %q but got %q for SnapshotPolicyName", v.Expected.SnapshotPolicyName, actual.SnapshotPolicyName) + } + + } +} + +func TestSegmentsForSnapshotPolicyId(t *testing.T) { + segments := SnapshotPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotPolicyId 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/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciescreate.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciescreate.go new file mode 100644 index 00000000000..8210e2fad73 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciescreate.go @@ -0,0 +1,58 @@ +package snapshotpolicy + +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 SnapshotPoliciesCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotPolicy +} + +// SnapshotPoliciesCreate ... +func (c SnapshotPolicyClient) SnapshotPoliciesCreate(ctx context.Context, id SnapshotPolicyId, input SnapshotPolicy) (result SnapshotPoliciesCreateOperationResponse, 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 + } + + var model SnapshotPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesdelete.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesdelete.go new file mode 100644 index 00000000000..88822a15bf8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesdelete.go @@ -0,0 +1,71 @@ +package snapshotpolicy + +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 SnapshotPoliciesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SnapshotPoliciesDelete ... +func (c SnapshotPolicyClient) SnapshotPoliciesDelete(ctx context.Context, id SnapshotPolicyId) (result SnapshotPoliciesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// SnapshotPoliciesDeleteThenPoll performs SnapshotPoliciesDelete then polls until it's completed +func (c SnapshotPolicyClient) SnapshotPoliciesDeleteThenPoll(ctx context.Context, id SnapshotPolicyId) error { + result, err := c.SnapshotPoliciesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing SnapshotPoliciesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SnapshotPoliciesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesget.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesget.go new file mode 100644 index 00000000000..15d2b69d7c1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesget.go @@ -0,0 +1,53 @@ +package snapshotpolicy + +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 SnapshotPoliciesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotPolicy +} + +// SnapshotPoliciesGet ... +func (c SnapshotPolicyClient) SnapshotPoliciesGet(ctx context.Context, id SnapshotPolicyId) (result SnapshotPoliciesGetOperationResponse, 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 + } + + var model SnapshotPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpolicieslist.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpolicieslist.go new file mode 100644 index 00000000000..eca667d1eb4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpolicieslist.go @@ -0,0 +1,54 @@ +package snapshotpolicy + +import ( + "context" + "fmt" + "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 SnapshotPoliciesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotPoliciesList +} + +// SnapshotPoliciesList ... +func (c SnapshotPolicyClient) SnapshotPoliciesList(ctx context.Context, id NetAppAccountId) (result SnapshotPoliciesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshotPolicies", 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 + } + + var model SnapshotPoliciesList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesupdate.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesupdate.go new file mode 100644 index 00000000000..c0cf93edf94 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/method_snapshotpoliciesupdate.go @@ -0,0 +1,75 @@ +package snapshotpolicy + +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 SnapshotPoliciesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotPolicy +} + +// SnapshotPoliciesUpdate ... +func (c SnapshotPolicyClient) SnapshotPoliciesUpdate(ctx context.Context, id SnapshotPolicyId, input SnapshotPolicyPatch) (result SnapshotPoliciesUpdateOperationResponse, 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 +} + +// SnapshotPoliciesUpdateThenPoll performs SnapshotPoliciesUpdate then polls until it's completed +func (c SnapshotPolicyClient) SnapshotPoliciesUpdateThenPoll(ctx context.Context, id SnapshotPolicyId, input SnapshotPolicyPatch) error { + result, err := c.SnapshotPoliciesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SnapshotPoliciesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SnapshotPoliciesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_dailyschedule.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_dailyschedule.go new file mode 100644 index 00000000000..bdafb72e6e0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_dailyschedule.go @@ -0,0 +1,11 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailySchedule struct { + Hour *int64 `json:"hour,omitempty"` + Minute *int64 `json:"minute,omitempty"` + SnapshotsToKeep *int64 `json:"snapshotsToKeep,omitempty"` + UsedBytes *int64 `json:"usedBytes,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_hourlyschedule.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_hourlyschedule.go new file mode 100644 index 00000000000..a1e5d0fa028 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_hourlyschedule.go @@ -0,0 +1,10 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HourlySchedule struct { + Minute *int64 `json:"minute,omitempty"` + SnapshotsToKeep *int64 `json:"snapshotsToKeep,omitempty"` + UsedBytes *int64 `json:"usedBytes,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_monthlyschedule.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_monthlyschedule.go new file mode 100644 index 00000000000..02cbcad6a59 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_monthlyschedule.go @@ -0,0 +1,12 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonthlySchedule struct { + DaysOfMonth *string `json:"daysOfMonth,omitempty"` + Hour *int64 `json:"hour,omitempty"` + Minute *int64 `json:"minute,omitempty"` + SnapshotsToKeep *int64 `json:"snapshotsToKeep,omitempty"` + UsedBytes *int64 `json:"usedBytes,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicieslist.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicieslist.go new file mode 100644 index 00000000000..910e2519adb --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicieslist.go @@ -0,0 +1,8 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotPoliciesList struct { + Value *[]SnapshotPolicy `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicy.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicy.go new file mode 100644 index 00000000000..310cfaaf1bb --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicy.go @@ -0,0 +1,19 @@ +package snapshotpolicy + +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 SnapshotPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SnapshotPolicyProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicypatch.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicypatch.go new file mode 100644 index 00000000000..76df9be172b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicypatch.go @@ -0,0 +1,13 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotPolicyPatch struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotPolicyProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicyproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicyproperties.go new file mode 100644 index 00000000000..fb4fb0fcb05 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_snapshotpolicyproperties.go @@ -0,0 +1,13 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotPolicyProperties struct { + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + MonthlySchedule *MonthlySchedule `json:"monthlySchedule,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/model_weeklyschedule.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_weeklyschedule.go new file mode 100644 index 00000000000..128ece7ef5e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/model_weeklyschedule.go @@ -0,0 +1,12 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklySchedule struct { + Day *string `json:"day,omitempty"` + Hour *int64 `json:"hour,omitempty"` + Minute *int64 `json:"minute,omitempty"` + SnapshotsToKeep *int64 `json:"snapshotsToKeep,omitempty"` + UsedBytes *int64 `json:"usedBytes,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicy/version.go b/resource-manager/netapp/2024-07-01/snapshotpolicy/version.go new file mode 100644 index 00000000000..d490e2d2f75 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicy/version.go @@ -0,0 +1,10 @@ +package snapshotpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/snapshotpolicy/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/README.md b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/README.md new file mode 100644 index 00000000000..a15a004726e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes` Documentation + +The `snapshotpolicylistvolumes` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/snapshotpolicylistvolumes" +``` + + +### Client Initialization + +```go +client := snapshotpolicylistvolumes.NewSnapshotPolicyListVolumesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SnapshotPolicyListVolumesClient.SnapshotPoliciesListVolumes` + +```go +ctx := context.TODO() +id := snapshotpolicylistvolumes.NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + +read, err := client.SnapshotPoliciesListVolumes(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/client.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/client.go new file mode 100644 index 00000000000..6098b871f64 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/client.go @@ -0,0 +1,26 @@ +package snapshotpolicylistvolumes + +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 SnapshotPolicyListVolumesClient struct { + Client *resourcemanager.Client +} + +func NewSnapshotPolicyListVolumesClientWithBaseURI(sdkApi sdkEnv.Api) (*SnapshotPolicyListVolumesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "snapshotpolicylistvolumes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SnapshotPolicyListVolumesClient: %+v", err) + } + + return &SnapshotPolicyListVolumesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/constants.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/constants.go new file mode 100644 index 00000000000..c3a395d5f82 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/constants.go @@ -0,0 +1,608 @@ +package snapshotpolicylistvolumes + +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 AvsDataStore string + +const ( + AvsDataStoreDisabled AvsDataStore = "Disabled" + AvsDataStoreEnabled AvsDataStore = "Enabled" +) + +func PossibleValuesForAvsDataStore() []string { + return []string{ + string(AvsDataStoreDisabled), + string(AvsDataStoreEnabled), + } +} + +func (s *AvsDataStore) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAvsDataStore(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAvsDataStore(input string) (*AvsDataStore, error) { + vals := map[string]AvsDataStore{ + "disabled": AvsDataStoreDisabled, + "enabled": AvsDataStoreEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AvsDataStore(input) + return &out, nil +} + +type ChownMode string + +const ( + ChownModeRestricted ChownMode = "Restricted" + ChownModeUnrestricted ChownMode = "Unrestricted" +) + +func PossibleValuesForChownMode() []string { + return []string{ + string(ChownModeRestricted), + string(ChownModeUnrestricted), + } +} + +func (s *ChownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChownMode(input string) (*ChownMode, error) { + vals := map[string]ChownMode{ + "restricted": ChownModeRestricted, + "unrestricted": ChownModeUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChownMode(input) + return &out, nil +} + +type CoolAccessRetrievalPolicy string + +const ( + CoolAccessRetrievalPolicyDefault CoolAccessRetrievalPolicy = "Default" + CoolAccessRetrievalPolicyNever CoolAccessRetrievalPolicy = "Never" + CoolAccessRetrievalPolicyOnRead CoolAccessRetrievalPolicy = "OnRead" +) + +func PossibleValuesForCoolAccessRetrievalPolicy() []string { + return []string{ + string(CoolAccessRetrievalPolicyDefault), + string(CoolAccessRetrievalPolicyNever), + string(CoolAccessRetrievalPolicyOnRead), + } +} + +func (s *CoolAccessRetrievalPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoolAccessRetrievalPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoolAccessRetrievalPolicy(input string) (*CoolAccessRetrievalPolicy, error) { + vals := map[string]CoolAccessRetrievalPolicy{ + "default": CoolAccessRetrievalPolicyDefault, + "never": CoolAccessRetrievalPolicyNever, + "onread": CoolAccessRetrievalPolicyOnRead, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoolAccessRetrievalPolicy(input) + return &out, nil +} + +type EnableSubvolumes string + +const ( + EnableSubvolumesDisabled EnableSubvolumes = "Disabled" + EnableSubvolumesEnabled EnableSubvolumes = "Enabled" +) + +func PossibleValuesForEnableSubvolumes() []string { + return []string{ + string(EnableSubvolumesDisabled), + string(EnableSubvolumesEnabled), + } +} + +func (s *EnableSubvolumes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableSubvolumes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnableSubvolumes(input string) (*EnableSubvolumes, error) { + vals := map[string]EnableSubvolumes{ + "disabled": EnableSubvolumesDisabled, + "enabled": EnableSubvolumesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnableSubvolumes(input) + return &out, nil +} + +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftPointKeyVault EncryptionKeySource = "Microsoft.KeyVault" + EncryptionKeySourceMicrosoftPointNetApp EncryptionKeySource = "Microsoft.NetApp" +) + +func PossibleValuesForEncryptionKeySource() []string { + return []string{ + string(EncryptionKeySourceMicrosoftPointKeyVault), + string(EncryptionKeySourceMicrosoftPointNetApp), + } +} + +func (s *EncryptionKeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionKeySource(input string) (*EncryptionKeySource, error) { + vals := map[string]EncryptionKeySource{ + "microsoft.keyvault": EncryptionKeySourceMicrosoftPointKeyVault, + "microsoft.netapp": EncryptionKeySourceMicrosoftPointNetApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionKeySource(input) + return &out, nil +} + +type EndpointType string + +const ( + EndpointTypeDst EndpointType = "dst" + EndpointTypeSrc EndpointType = "src" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeDst), + string(EndpointTypeSrc), + } +} + +func (s *EndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "dst": EndpointTypeDst, + "src": EndpointTypeSrc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type FileAccessLogs string + +const ( + FileAccessLogsDisabled FileAccessLogs = "Disabled" + FileAccessLogsEnabled FileAccessLogs = "Enabled" +) + +func PossibleValuesForFileAccessLogs() []string { + return []string{ + string(FileAccessLogsDisabled), + string(FileAccessLogsEnabled), + } +} + +func (s *FileAccessLogs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFileAccessLogs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFileAccessLogs(input string) (*FileAccessLogs, error) { + vals := map[string]FileAccessLogs{ + "disabled": FileAccessLogsDisabled, + "enabled": FileAccessLogsEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileAccessLogs(input) + return &out, nil +} + +type NetworkFeatures string + +const ( + NetworkFeaturesBasic NetworkFeatures = "Basic" + NetworkFeaturesBasicStandard NetworkFeatures = "Basic_Standard" + NetworkFeaturesStandard NetworkFeatures = "Standard" + NetworkFeaturesStandardBasic NetworkFeatures = "Standard_Basic" +) + +func PossibleValuesForNetworkFeatures() []string { + return []string{ + string(NetworkFeaturesBasic), + string(NetworkFeaturesBasicStandard), + string(NetworkFeaturesStandard), + string(NetworkFeaturesStandardBasic), + } +} + +func (s *NetworkFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkFeatures(input string) (*NetworkFeatures, error) { + vals := map[string]NetworkFeatures{ + "basic": NetworkFeaturesBasic, + "basic_standard": NetworkFeaturesBasicStandard, + "standard": NetworkFeaturesStandard, + "standard_basic": NetworkFeaturesStandardBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkFeatures(input) + return &out, nil +} + +type ReplicationSchedule string + +const ( + ReplicationScheduleDaily ReplicationSchedule = "daily" + ReplicationScheduleHourly ReplicationSchedule = "hourly" + ReplicationScheduleOneZerominutely ReplicationSchedule = "_10minutely" +) + +func PossibleValuesForReplicationSchedule() []string { + return []string{ + string(ReplicationScheduleDaily), + string(ReplicationScheduleHourly), + string(ReplicationScheduleOneZerominutely), + } +} + +func (s *ReplicationSchedule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationSchedule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationSchedule(input string) (*ReplicationSchedule, error) { + vals := map[string]ReplicationSchedule{ + "daily": ReplicationScheduleDaily, + "hourly": ReplicationScheduleHourly, + "_10minutely": ReplicationScheduleOneZerominutely, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationSchedule(input) + return &out, nil +} + +type SecurityStyle string + +const ( + SecurityStyleNtfs SecurityStyle = "ntfs" + SecurityStyleUnix SecurityStyle = "unix" +) + +func PossibleValuesForSecurityStyle() []string { + return []string{ + string(SecurityStyleNtfs), + string(SecurityStyleUnix), + } +} + +func (s *SecurityStyle) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityStyle(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityStyle(input string) (*SecurityStyle, error) { + vals := map[string]SecurityStyle{ + "ntfs": SecurityStyleNtfs, + "unix": SecurityStyleUnix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityStyle(input) + return &out, nil +} + +type ServiceLevel string + +const ( + ServiceLevelPremium ServiceLevel = "Premium" + ServiceLevelStandard ServiceLevel = "Standard" + ServiceLevelStandardZRS ServiceLevel = "StandardZRS" + ServiceLevelUltra ServiceLevel = "Ultra" +) + +func PossibleValuesForServiceLevel() []string { + return []string{ + string(ServiceLevelPremium), + string(ServiceLevelStandard), + string(ServiceLevelStandardZRS), + string(ServiceLevelUltra), + } +} + +func (s *ServiceLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLevel(input string) (*ServiceLevel, error) { + vals := map[string]ServiceLevel{ + "premium": ServiceLevelPremium, + "standard": ServiceLevelStandard, + "standardzrs": ServiceLevelStandardZRS, + "ultra": ServiceLevelUltra, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLevel(input) + return &out, nil +} + +type SmbAccessBasedEnumeration string + +const ( + SmbAccessBasedEnumerationDisabled SmbAccessBasedEnumeration = "Disabled" + SmbAccessBasedEnumerationEnabled SmbAccessBasedEnumeration = "Enabled" +) + +func PossibleValuesForSmbAccessBasedEnumeration() []string { + return []string{ + string(SmbAccessBasedEnumerationDisabled), + string(SmbAccessBasedEnumerationEnabled), + } +} + +func (s *SmbAccessBasedEnumeration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbAccessBasedEnumeration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbAccessBasedEnumeration(input string) (*SmbAccessBasedEnumeration, error) { + vals := map[string]SmbAccessBasedEnumeration{ + "disabled": SmbAccessBasedEnumerationDisabled, + "enabled": SmbAccessBasedEnumerationEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbAccessBasedEnumeration(input) + return &out, nil +} + +type SmbNonBrowsable string + +const ( + SmbNonBrowsableDisabled SmbNonBrowsable = "Disabled" + SmbNonBrowsableEnabled SmbNonBrowsable = "Enabled" +) + +func PossibleValuesForSmbNonBrowsable() []string { + return []string{ + string(SmbNonBrowsableDisabled), + string(SmbNonBrowsableEnabled), + } +} + +func (s *SmbNonBrowsable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbNonBrowsable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbNonBrowsable(input string) (*SmbNonBrowsable, error) { + vals := map[string]SmbNonBrowsable{ + "disabled": SmbNonBrowsableDisabled, + "enabled": SmbNonBrowsableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbNonBrowsable(input) + return &out, nil +} + +type VolumeStorageToNetworkProximity string + +const ( + VolumeStorageToNetworkProximityAcrossTTwo VolumeStorageToNetworkProximity = "AcrossT2" + VolumeStorageToNetworkProximityDefault VolumeStorageToNetworkProximity = "Default" + VolumeStorageToNetworkProximityTOne VolumeStorageToNetworkProximity = "T1" + VolumeStorageToNetworkProximityTTwo VolumeStorageToNetworkProximity = "T2" +) + +func PossibleValuesForVolumeStorageToNetworkProximity() []string { + return []string{ + string(VolumeStorageToNetworkProximityAcrossTTwo), + string(VolumeStorageToNetworkProximityDefault), + string(VolumeStorageToNetworkProximityTOne), + string(VolumeStorageToNetworkProximityTTwo), + } +} + +func (s *VolumeStorageToNetworkProximity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeStorageToNetworkProximity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeStorageToNetworkProximity(input string) (*VolumeStorageToNetworkProximity, error) { + vals := map[string]VolumeStorageToNetworkProximity{ + "acrosst2": VolumeStorageToNetworkProximityAcrossTTwo, + "default": VolumeStorageToNetworkProximityDefault, + "t1": VolumeStorageToNetworkProximityTOne, + "t2": VolumeStorageToNetworkProximityTTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeStorageToNetworkProximity(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy.go new file mode 100644 index 00000000000..c366a171e15 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy.go @@ -0,0 +1,139 @@ +package snapshotpolicylistvolumes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SnapshotPolicyId{}) +} + +var _ resourceids.ResourceId = &SnapshotPolicyId{} + +// SnapshotPolicyId is a struct representing the Resource ID for a Snapshot Policy +type SnapshotPolicyId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + SnapshotPolicyName string +} + +// NewSnapshotPolicyID returns a new SnapshotPolicyId struct +func NewSnapshotPolicyID(subscriptionId string, resourceGroupName string, netAppAccountName string, snapshotPolicyName string) SnapshotPolicyId { + return SnapshotPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + SnapshotPolicyName: snapshotPolicyName, + } +} + +// ParseSnapshotPolicyID parses 'input' into a SnapshotPolicyId +func ParseSnapshotPolicyID(input string) (*SnapshotPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotPolicyIDInsensitively parses 'input' case-insensitively into a SnapshotPolicyId +// note: this method should only be used for API response data and not user input +func ParseSnapshotPolicyIDInsensitively(input string) (*SnapshotPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotPolicyId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.SnapshotPolicyName, ok = input.Parsed["snapshotPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotPolicyName", input) + } + + return nil +} + +// ValidateSnapshotPolicyID checks that 'input' can be parsed as a Snapshot Policy ID +func ValidateSnapshotPolicyID(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 := ParseSnapshotPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot Policy ID +func (id SnapshotPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/snapshotPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.SnapshotPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot Policy ID +func (id SnapshotPolicyId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticSnapshotPolicies", "snapshotPolicies", "snapshotPolicies"), + resourceids.UserSpecifiedSegment("snapshotPolicyName", "snapshotPolicyName"), + } +} + +// String returns a human-readable description of this Snapshot Policy ID +func (id SnapshotPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Snapshot Policy Name: %q", id.SnapshotPolicyName), + } + return fmt.Sprintf("Snapshot Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy_test.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy_test.go new file mode 100644 index 00000000000..8dad1f1572b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/id_snapshotpolicy_test.go @@ -0,0 +1,327 @@ +package snapshotpolicylistvolumes + +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 = &SnapshotPolicyId{} + +func TestNewSnapshotPolicyID(t *testing.T) { + id := NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.SnapshotPolicyName != "snapshotPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotPolicyName'", id.SnapshotPolicyName, "snapshotPolicyName") + } +} + +func TestFormatSnapshotPolicyID(t *testing.T) { + actual := NewSnapshotPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "snapshotPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + SnapshotPolicyName: "snapshotPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotPolicyID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.SnapshotPolicyName != v.Expected.SnapshotPolicyName { + t.Fatalf("Expected %q but got %q for SnapshotPolicyName", v.Expected.SnapshotPolicyName, actual.SnapshotPolicyName) + } + + } +} + +func TestParseSnapshotPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotPolicyId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + SnapshotPolicyName: "snapshotPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/snapshotPolicies/snapshotPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS/sNaPsHoTpOlIcYnAmE", + Expected: &SnapshotPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + SnapshotPolicyName: "sNaPsHoTpOlIcYnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/sNaPsHoTpOlIcIeS/sNaPsHoTpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotPolicyIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.SnapshotPolicyName != v.Expected.SnapshotPolicyName { + t.Fatalf("Expected %q but got %q for SnapshotPolicyName", v.Expected.SnapshotPolicyName, actual.SnapshotPolicyName) + } + + } +} + +func TestSegmentsForSnapshotPolicyId(t *testing.T) { + segments := SnapshotPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotPolicyId 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/netapp/2024-07-01/snapshotpolicylistvolumes/method_snapshotpolicieslistvolumes.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/method_snapshotpolicieslistvolumes.go new file mode 100644 index 00000000000..88466bae80e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/method_snapshotpolicieslistvolumes.go @@ -0,0 +1,54 @@ +package snapshotpolicylistvolumes + +import ( + "context" + "fmt" + "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 SnapshotPoliciesListVolumesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotPolicyVolumeList +} + +// SnapshotPoliciesListVolumes ... +func (c SnapshotPolicyListVolumesClient) SnapshotPoliciesListVolumes(ctx context.Context, id SnapshotPolicyId) (result SnapshotPoliciesListVolumesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/volumes", 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 + } + + var model SnapshotPolicyVolumeList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_exportpolicyrule.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_exportpolicyrule.go new file mode 100644 index 00000000000..dd6bb7a20fc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_exportpolicyrule.go @@ -0,0 +1,22 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportPolicyRule struct { + AllowedClients *string `json:"allowedClients,omitempty"` + ChownMode *ChownMode `json:"chownMode,omitempty"` + Cifs *bool `json:"cifs,omitempty"` + HasRootAccess *bool `json:"hasRootAccess,omitempty"` + Kerberos5ReadOnly *bool `json:"kerberos5ReadOnly,omitempty"` + Kerberos5ReadWrite *bool `json:"kerberos5ReadWrite,omitempty"` + Kerberos5iReadOnly *bool `json:"kerberos5iReadOnly,omitempty"` + Kerberos5iReadWrite *bool `json:"kerberos5iReadWrite,omitempty"` + Kerberos5pReadOnly *bool `json:"kerberos5pReadOnly,omitempty"` + Kerberos5pReadWrite *bool `json:"kerberos5pReadWrite,omitempty"` + Nfsv3 *bool `json:"nfsv3,omitempty"` + Nfsv41 *bool `json:"nfsv41,omitempty"` + RuleIndex *int64 `json:"ruleIndex,omitempty"` + UnixReadOnly *bool `json:"unixReadOnly,omitempty"` + UnixReadWrite *bool `json:"unixReadWrite,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_mounttargetproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_mounttargetproperties.go new file mode 100644 index 00000000000..49f9f6f131a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_mounttargetproperties.go @@ -0,0 +1,11 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MountTargetProperties struct { + FileSystemId string `json:"fileSystemId"` + IPAddress *string `json:"ipAddress,omitempty"` + MountTargetId *string `json:"mountTargetId,omitempty"` + SmbServerFqdn *string `json:"smbServerFqdn,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_placementkeyvaluepairs.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_placementkeyvaluepairs.go new file mode 100644 index 00000000000..0d5756a7089 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_placementkeyvaluepairs.go @@ -0,0 +1,9 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlacementKeyValuePairs struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_remotepath.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_remotepath.go new file mode 100644 index 00000000000..15c1c316b42 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_remotepath.go @@ -0,0 +1,10 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePath struct { + ExternalHostName string `json:"externalHostName"` + ServerName string `json:"serverName"` + VolumeName string `json:"volumeName"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_replicationobject.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_replicationobject.go new file mode 100644 index 00000000000..9b3d69a13d1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_replicationobject.go @@ -0,0 +1,13 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationObject struct { + EndpointType *EndpointType `json:"endpointType,omitempty"` + RemotePath *RemotePath `json:"remotePath,omitempty"` + RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` + RemoteVolumeResourceId string `json:"remoteVolumeResourceId"` + ReplicationId *string `json:"replicationId,omitempty"` + ReplicationSchedule *ReplicationSchedule `json:"replicationSchedule,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_snapshotpolicyvolumelist.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_snapshotpolicyvolumelist.go new file mode 100644 index 00000000000..2d14e9596fe --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_snapshotpolicyvolumelist.go @@ -0,0 +1,8 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotPolicyVolumeList struct { + Value *[]Volume `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volume.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volume.go new file mode 100644 index 00000000000..36417f52891 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volume.go @@ -0,0 +1,21 @@ +package snapshotpolicylistvolumes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties VolumeProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumebackupproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumebackupproperties.go new file mode 100644 index 00000000000..be2a40ea08d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumebackupproperties.go @@ -0,0 +1,10 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeBackupProperties struct { + BackupPolicyId *string `json:"backupPolicyId,omitempty"` + BackupVaultId *string `json:"backupVaultId,omitempty"` + PolicyEnforced *bool `json:"policyEnforced,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumeproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumeproperties.go new file mode 100644 index 00000000000..78d6a260ba2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumeproperties.go @@ -0,0 +1,62 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeProperties struct { + ActualThroughputMibps *float64 `json:"actualThroughputMibps,omitempty"` + AvsDataStore *AvsDataStore `json:"avsDataStore,omitempty"` + BackupId *string `json:"backupId,omitempty"` + BaremetalTenantId *string `json:"baremetalTenantId,omitempty"` + CapacityPoolResourceId *string `json:"capacityPoolResourceId,omitempty"` + CloneProgress *int64 `json:"cloneProgress,omitempty"` + CoolAccess *bool `json:"coolAccess,omitempty"` + CoolAccessRetrievalPolicy *CoolAccessRetrievalPolicy `json:"coolAccessRetrievalPolicy,omitempty"` + CoolnessPeriod *int64 `json:"coolnessPeriod,omitempty"` + CreationToken string `json:"creationToken"` + DataProtection *VolumePropertiesDataProtection `json:"dataProtection,omitempty"` + DataStoreResourceId *[]string `json:"dataStoreResourceId,omitempty"` + DefaultGroupQuotaInKiBs *int64 `json:"defaultGroupQuotaInKiBs,omitempty"` + DefaultUserQuotaInKiBs *int64 `json:"defaultUserQuotaInKiBs,omitempty"` + DeleteBaseSnapshot *bool `json:"deleteBaseSnapshot,omitempty"` + EffectiveNetworkFeatures *NetworkFeatures `json:"effectiveNetworkFeatures,omitempty"` + EnableSubvolumes *EnableSubvolumes `json:"enableSubvolumes,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` + EncryptionKeySource *EncryptionKeySource `json:"encryptionKeySource,omitempty"` + ExportPolicy *VolumePropertiesExportPolicy `json:"exportPolicy,omitempty"` + FileAccessLogs *FileAccessLogs `json:"fileAccessLogs,omitempty"` + FileSystemId *string `json:"fileSystemId,omitempty"` + IsDefaultQuotaEnabled *bool `json:"isDefaultQuotaEnabled,omitempty"` + IsLargeVolume *bool `json:"isLargeVolume,omitempty"` + IsRestoring *bool `json:"isRestoring,omitempty"` + KerberosEnabled *bool `json:"kerberosEnabled,omitempty"` + KeyVaultPrivateEndpointResourceId *string `json:"keyVaultPrivateEndpointResourceId,omitempty"` + LdapEnabled *bool `json:"ldapEnabled,omitempty"` + MaximumNumberOfFiles *int64 `json:"maximumNumberOfFiles,omitempty"` + MountTargets *[]MountTargetProperties `json:"mountTargets,omitempty"` + NetworkFeatures *NetworkFeatures `json:"networkFeatures,omitempty"` + NetworkSiblingSetId *string `json:"networkSiblingSetId,omitempty"` + OriginatingResourceId *string `json:"originatingResourceId,omitempty"` + PlacementRules *[]PlacementKeyValuePairs `json:"placementRules,omitempty"` + ProtocolTypes *[]string `json:"protocolTypes,omitempty"` + ProvisionedAvailabilityZone *string `json:"provisionedAvailabilityZone,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroup *string `json:"proximityPlacementGroup,omitempty"` + SecurityStyle *SecurityStyle `json:"securityStyle,omitempty"` + ServiceLevel *ServiceLevel `json:"serviceLevel,omitempty"` + SmbAccessBasedEnumeration *SmbAccessBasedEnumeration `json:"smbAccessBasedEnumeration,omitempty"` + SmbContinuouslyAvailable *bool `json:"smbContinuouslyAvailable,omitempty"` + SmbEncryption *bool `json:"smbEncryption,omitempty"` + SmbNonBrowsable *SmbNonBrowsable `json:"smbNonBrowsable,omitempty"` + SnapshotDirectoryVisible *bool `json:"snapshotDirectoryVisible,omitempty"` + SnapshotId *string `json:"snapshotId,omitempty"` + StorageToNetworkProximity *VolumeStorageToNetworkProximity `json:"storageToNetworkProximity,omitempty"` + SubnetId string `json:"subnetId"` + T2Network *string `json:"t2Network,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` + UnixPermissions *string `json:"unixPermissions,omitempty"` + UsageThreshold int64 `json:"usageThreshold"` + VolumeGroupName *string `json:"volumeGroupName,omitempty"` + VolumeSpecName *string `json:"volumeSpecName,omitempty"` + VolumeType *string `json:"volumeType,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesdataprotection.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesdataprotection.go new file mode 100644 index 00000000000..bf5ff10761d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesdataprotection.go @@ -0,0 +1,11 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesDataProtection struct { + Backup *VolumeBackupProperties `json:"backup,omitempty"` + Replication *ReplicationObject `json:"replication,omitempty"` + Snapshot *VolumeSnapshotProperties `json:"snapshot,omitempty"` + VolumeRelocation *VolumeRelocationProperties `json:"volumeRelocation,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesexportpolicy.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesexportpolicy.go new file mode 100644 index 00000000000..1ad178d6e25 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumepropertiesexportpolicy.go @@ -0,0 +1,8 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesExportPolicy struct { + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumerelocationproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumerelocationproperties.go new file mode 100644 index 00000000000..26ffc8f0697 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumerelocationproperties.go @@ -0,0 +1,9 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeRelocationProperties struct { + ReadyToBeFinalized *bool `json:"readyToBeFinalized,omitempty"` + RelocationRequested *bool `json:"relocationRequested,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumesnapshotproperties.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumesnapshotproperties.go new file mode 100644 index 00000000000..e4915375144 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/model_volumesnapshotproperties.go @@ -0,0 +1,8 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeSnapshotProperties struct { + SnapshotPolicyId *string `json:"snapshotPolicyId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/version.go b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/version.go new file mode 100644 index 00000000000..7f244a8bf05 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshotpolicylistvolumes/version.go @@ -0,0 +1,10 @@ +package snapshotpolicylistvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/snapshotpolicylistvolumes/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/README.md b/resource-manager/netapp/2024-07-01/snapshots/README.md new file mode 100644 index 00000000000..2fae9e8564e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/snapshots` Documentation + +The `snapshots` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/snapshots" +``` + + +### Client Initialization + +```go +client := snapshots.NewSnapshotsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SnapshotsClient.Create` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") + +payload := snapshots.Snapshot{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SnapshotsClient.Delete` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SnapshotsClient.Get` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") + +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: `SnapshotsClient.List` + +```go +ctx := context.TODO() +id := snapshots.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotsClient.RestoreFiles` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") + +payload := snapshots.SnapshotRestoreFiles{ + // ... +} + + +if err := client.RestoreFilesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SnapshotsClient.Update` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") +var payload interface{} + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/snapshots/client.go b/resource-manager/netapp/2024-07-01/snapshots/client.go new file mode 100644 index 00000000000..678a64470aa --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/client.go @@ -0,0 +1,26 @@ +package snapshots + +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 SnapshotsClient struct { + Client *resourcemanager.Client +} + +func NewSnapshotsClientWithBaseURI(sdkApi sdkEnv.Api) (*SnapshotsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "snapshots", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SnapshotsClient: %+v", err) + } + + return &SnapshotsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/id_snapshot.go b/resource-manager/netapp/2024-07-01/snapshots/id_snapshot.go new file mode 100644 index 00000000000..2fe36d4f5a9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/id_snapshot.go @@ -0,0 +1,157 @@ +package snapshots + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SnapshotId{}) +} + +var _ resourceids.ResourceId = &SnapshotId{} + +// SnapshotId is a struct representing the Resource ID for a Snapshot +type SnapshotId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string + SnapshotName string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string, snapshotName string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + SnapshotName: snapshotName, + } +} + +// ParseSnapshotID parses 'input' into a SnapshotId +func ParseSnapshotID(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotIDInsensitively parses 'input' case-insensitively into a SnapshotId +// note: this method should only be used for API response data and not user input +func ParseSnapshotIDInsensitively(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + if id.SnapshotName, ok = input.Parsed["snapshotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotName", input) + } + + return nil +} + +// ValidateSnapshotID checks that 'input' can be parsed as a Snapshot ID +func ValidateSnapshotID(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 := ParseSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot ID +func (id SnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName, id.SnapshotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot ID +func (id SnapshotId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotName", "snapshotName"), + } +} + +// String returns a human-readable description of this Snapshot ID +func (id SnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + fmt.Sprintf("Snapshot Name: %q", id.SnapshotName), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/id_snapshot_test.go b/resource-manager/netapp/2024-07-01/snapshots/id_snapshot_test.go new file mode 100644 index 00000000000..1aae8e6ed5c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/id_snapshot_test.go @@ -0,0 +1,417 @@ +package snapshots + +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 = &SnapshotId{} + +func TestNewSnapshotID(t *testing.T) { + id := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } + + if id.SnapshotName != "snapshotName" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotName'", id.SnapshotName, "snapshotName") + } +} + +func TestFormatSnapshotID(t *testing.T) { + actual := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "snapshotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots/snapshotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots/snapshotName", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + SnapshotName: "snapshotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots/snapshotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.SnapshotName != v.Expected.SnapshotName { + t.Fatalf("Expected %q but got %q for SnapshotName", v.Expected.SnapshotName, actual.SnapshotName) + } + + } +} + +func TestParseSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots/snapshotName", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + SnapshotName: "snapshotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/snapshots/snapshotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sNaPsHoTs/sNaPsHoTnAmE", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + SnapshotName: "sNaPsHoTnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sNaPsHoTs/sNaPsHoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.SnapshotName != v.Expected.SnapshotName { + t.Fatalf("Expected %q but got %q for SnapshotName", v.Expected.SnapshotName, actual.SnapshotName) + } + + } +} + +func TestSegmentsForSnapshotId(t *testing.T) { + segments := SnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotId 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/netapp/2024-07-01/snapshots/id_volume.go b/resource-manager/netapp/2024-07-01/snapshots/id_volume.go new file mode 100644 index 00000000000..dcd1ab5e98b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/id_volume.go @@ -0,0 +1,148 @@ +package snapshots + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/id_volume_test.go b/resource-manager/netapp/2024-07-01/snapshots/id_volume_test.go new file mode 100644 index 00000000000..010624ba420 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/id_volume_test.go @@ -0,0 +1,372 @@ +package snapshots + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/snapshots/method_create.go b/resource-manager/netapp/2024-07-01/snapshots/method_create.go new file mode 100644 index 00000000000..6d6b9a4fbe2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_create.go @@ -0,0 +1,75 @@ +package snapshots + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// Create ... +func (c SnapshotsClient) Create(ctx context.Context, id SnapshotId, input Snapshot) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + }, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SnapshotsClient) CreateThenPoll(ctx context.Context, id SnapshotId, input Snapshot) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/method_delete.go b/resource-manager/netapp/2024-07-01/snapshots/method_delete.go new file mode 100644 index 00000000000..ef16480f860 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_delete.go @@ -0,0 +1,71 @@ +package snapshots + +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 SnapshotsClient) Delete(ctx context.Context, id SnapshotId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SnapshotsClient) DeleteThenPoll(ctx context.Context, id SnapshotId) 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/netapp/2024-07-01/snapshots/method_get.go b/resource-manager/netapp/2024-07-01/snapshots/method_get.go new file mode 100644 index 00000000000..68b676f0115 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_get.go @@ -0,0 +1,53 @@ +package snapshots + +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 *Snapshot +} + +// Get ... +func (c SnapshotsClient) Get(ctx context.Context, id SnapshotId) (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 + } + + var model Snapshot + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/method_list.go b/resource-manager/netapp/2024-07-01/snapshots/method_list.go new file mode 100644 index 00000000000..77c6da22159 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_list.go @@ -0,0 +1,54 @@ +package snapshots + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SnapshotsList +} + +// List ... +func (c SnapshotsClient) List(ctx context.Context, id VolumeId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", 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 + } + + var model SnapshotsList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/method_restorefiles.go b/resource-manager/netapp/2024-07-01/snapshots/method_restorefiles.go new file mode 100644 index 00000000000..685be44a5ff --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_restorefiles.go @@ -0,0 +1,74 @@ +package snapshots + +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 RestoreFilesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFiles ... +func (c SnapshotsClient) RestoreFiles(ctx context.Context, id SnapshotId, input SnapshotRestoreFiles) (result RestoreFilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFiles", 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 +} + +// RestoreFilesThenPoll performs RestoreFiles then polls until it's completed +func (c SnapshotsClient) RestoreFilesThenPoll(ctx context.Context, id SnapshotId, input SnapshotRestoreFiles) error { + result, err := c.RestoreFiles(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFiles: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFiles: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/method_update.go b/resource-manager/netapp/2024-07-01/snapshots/method_update.go new file mode 100644 index 00000000000..1e85e294ee5 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/method_update.go @@ -0,0 +1,75 @@ +package snapshots + +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 + Model *Snapshot +} + +// Update ... +func (c SnapshotsClient) Update(ctx context.Context, id SnapshotId, input interface{}) (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 SnapshotsClient) UpdateThenPoll(ctx context.Context, id SnapshotId, input interface{}) 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/netapp/2024-07-01/snapshots/model_snapshot.go b/resource-manager/netapp/2024-07-01/snapshots/model_snapshot.go new file mode 100644 index 00000000000..fe53e779a4c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/model_snapshot.go @@ -0,0 +1,17 @@ +package snapshots + +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 Snapshot struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/model_snapshotproperties.go b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotproperties.go new file mode 100644 index 00000000000..fe60537eaaa --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotproperties.go @@ -0,0 +1,28 @@ +package snapshots + +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 SnapshotProperties struct { + Created *string `json:"created,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + SnapshotId *string `json:"snapshotId,omitempty"` +} + +func (o *SnapshotProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *SnapshotProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/model_snapshotrestorefiles.go b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotrestorefiles.go new file mode 100644 index 00000000000..de80d971dcf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotrestorefiles.go @@ -0,0 +1,9 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreFiles struct { + DestinationPath *string `json:"destinationPath,omitempty"` + FilePaths []string `json:"filePaths"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/model_snapshotslist.go b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotslist.go new file mode 100644 index 00000000000..bf283b0d2ac --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/model_snapshotslist.go @@ -0,0 +1,8 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotsList struct { + Value *[]Snapshot `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/snapshots/version.go b/resource-manager/netapp/2024-07-01/snapshots/version.go new file mode 100644 index 00000000000..7ff9b9fbfe4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/snapshots/version.go @@ -0,0 +1,10 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/snapshots/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/README.md b/resource-manager/netapp/2024-07-01/subvolumes/README.md new file mode 100644 index 00000000000..1cde8016ff3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/subvolumes` Documentation + +The `subvolumes` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/subvolumes" +``` + + +### Client Initialization + +```go +client := subvolumes.NewSubVolumesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SubVolumesClient.Create` + +```go +ctx := context.TODO() +id := subvolumes.NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + +payload := subvolumes.SubvolumeInfo{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SubVolumesClient.Delete` + +```go +ctx := context.TODO() +id := subvolumes.NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SubVolumesClient.Get` + +```go +ctx := context.TODO() +id := subvolumes.NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + +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: `SubVolumesClient.GetMetadata` + +```go +ctx := context.TODO() +id := subvolumes.NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + +if err := client.GetMetadataThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SubVolumesClient.ListByVolume` + +```go +ctx := context.TODO() +id := subvolumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +// alternatively `client.ListByVolume(ctx, id)` can be used to do batched pagination +items, err := client.ListByVolumeComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SubVolumesClient.Update` + +```go +ctx := context.TODO() +id := subvolumes.NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + +payload := subvolumes.SubvolumePatchRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/subvolumes/client.go b/resource-manager/netapp/2024-07-01/subvolumes/client.go new file mode 100644 index 00000000000..051d1e4b2ba --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/client.go @@ -0,0 +1,26 @@ +package subvolumes + +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 SubVolumesClient struct { + Client *resourcemanager.Client +} + +func NewSubVolumesClientWithBaseURI(sdkApi sdkEnv.Api) (*SubVolumesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "subvolumes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubVolumesClient: %+v", err) + } + + return &SubVolumesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume.go b/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume.go new file mode 100644 index 00000000000..d9ceec6f9e6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume.go @@ -0,0 +1,157 @@ +package subvolumes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SubVolumeId{}) +} + +var _ resourceids.ResourceId = &SubVolumeId{} + +// SubVolumeId is a struct representing the Resource ID for a Sub Volume +type SubVolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string + SubVolumeName string +} + +// NewSubVolumeID returns a new SubVolumeId struct +func NewSubVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string, subVolumeName string) SubVolumeId { + return SubVolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + SubVolumeName: subVolumeName, + } +} + +// ParseSubVolumeID parses 'input' into a SubVolumeId +func ParseSubVolumeID(input string) (*SubVolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&SubVolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SubVolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSubVolumeIDInsensitively parses 'input' case-insensitively into a SubVolumeId +// note: this method should only be used for API response data and not user input +func ParseSubVolumeIDInsensitively(input string) (*SubVolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&SubVolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SubVolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SubVolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + if id.SubVolumeName, ok = input.Parsed["subVolumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subVolumeName", input) + } + + return nil +} + +// ValidateSubVolumeID checks that 'input' can be parsed as a Sub Volume ID +func ValidateSubVolumeID(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 := ParseSubVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sub Volume ID +func (id SubVolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s/subVolumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName, id.SubVolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sub Volume ID +func (id SubVolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + resourceids.StaticSegment("staticSubVolumes", "subVolumes", "subVolumes"), + resourceids.UserSpecifiedSegment("subVolumeName", "subVolumeName"), + } +} + +// String returns a human-readable description of this Sub Volume ID +func (id SubVolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + fmt.Sprintf("Sub Volume Name: %q", id.SubVolumeName), + } + return fmt.Sprintf("Sub Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume_test.go b/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume_test.go new file mode 100644 index 00000000000..c427629eb5d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/id_subvolume_test.go @@ -0,0 +1,417 @@ +package subvolumes + +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 = &SubVolumeId{} + +func TestNewSubVolumeID(t *testing.T) { + id := NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } + + if id.SubVolumeName != "subVolumeName" { + t.Fatalf("Expected %q but got %q for Segment 'SubVolumeName'", id.SubVolumeName, "subVolumeName") + } +} + +func TestFormatSubVolumeID(t *testing.T) { + actual := NewSubVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "subVolumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes/subVolumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSubVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SubVolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes/subVolumeName", + Expected: &SubVolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + SubVolumeName: "subVolumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes/subVolumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSubVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.SubVolumeName != v.Expected.SubVolumeName { + t.Fatalf("Expected %q but got %q for SubVolumeName", v.Expected.SubVolumeName, actual.SubVolumeName) + } + + } +} + +func TestParseSubVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SubVolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sUbVoLuMeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes/subVolumeName", + Expected: &SubVolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + SubVolumeName: "subVolumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/subVolumes/subVolumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sUbVoLuMeS/sUbVoLuMeNaMe", + Expected: &SubVolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + SubVolumeName: "sUbVoLuMeNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/sUbVoLuMeS/sUbVoLuMeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSubVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.SubVolumeName != v.Expected.SubVolumeName { + t.Fatalf("Expected %q but got %q for SubVolumeName", v.Expected.SubVolumeName, actual.SubVolumeName) + } + + } +} + +func TestSegmentsForSubVolumeId(t *testing.T) { + segments := SubVolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SubVolumeId 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/netapp/2024-07-01/subvolumes/id_volume.go b/resource-manager/netapp/2024-07-01/subvolumes/id_volume.go new file mode 100644 index 00000000000..1b621f47327 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/id_volume.go @@ -0,0 +1,148 @@ +package subvolumes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/id_volume_test.go b/resource-manager/netapp/2024-07-01/subvolumes/id_volume_test.go new file mode 100644 index 00000000000..31c7ff8fe02 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/id_volume_test.go @@ -0,0 +1,372 @@ +package subvolumes + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/subvolumes/method_create.go b/resource-manager/netapp/2024-07-01/subvolumes/method_create.go new file mode 100644 index 00000000000..bbfe4a236ba --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_create.go @@ -0,0 +1,76 @@ +package subvolumes + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SubvolumeInfo +} + +// Create ... +func (c SubVolumesClient) Create(ctx context.Context, id SubVolumeId, input SubvolumeInfo) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SubVolumesClient) CreateThenPoll(ctx context.Context, id SubVolumeId, input SubvolumeInfo) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/method_delete.go b/resource-manager/netapp/2024-07-01/subvolumes/method_delete.go new file mode 100644 index 00000000000..2f19ed22f0c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_delete.go @@ -0,0 +1,71 @@ +package subvolumes + +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 SubVolumesClient) Delete(ctx context.Context, id SubVolumeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SubVolumesClient) DeleteThenPoll(ctx context.Context, id SubVolumeId) 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/netapp/2024-07-01/subvolumes/method_get.go b/resource-manager/netapp/2024-07-01/subvolumes/method_get.go new file mode 100644 index 00000000000..20f1ee49120 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_get.go @@ -0,0 +1,53 @@ +package subvolumes + +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 *SubvolumeInfo +} + +// Get ... +func (c SubVolumesClient) Get(ctx context.Context, id SubVolumeId) (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 + } + + var model SubvolumeInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/method_getmetadata.go b/resource-manager/netapp/2024-07-01/subvolumes/method_getmetadata.go new file mode 100644 index 00000000000..08001acad27 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_getmetadata.go @@ -0,0 +1,71 @@ +package subvolumes + +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 GetMetadataOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SubvolumeModel +} + +// GetMetadata ... +func (c SubVolumesClient) GetMetadata(ctx context.Context, id SubVolumeId) (result GetMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getMetadata", 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 +} + +// GetMetadataThenPoll performs GetMetadata then polls until it's completed +func (c SubVolumesClient) GetMetadataThenPoll(ctx context.Context, id SubVolumeId) error { + result, err := c.GetMetadata(ctx, id) + if err != nil { + return fmt.Errorf("performing GetMetadata: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetMetadata: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/method_listbyvolume.go b/resource-manager/netapp/2024-07-01/subvolumes/method_listbyvolume.go new file mode 100644 index 00000000000..e6022de2ecf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_listbyvolume.go @@ -0,0 +1,105 @@ +package subvolumes + +import ( + "context" + "fmt" + "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 ListByVolumeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SubvolumeInfo +} + +type ListByVolumeCompleteResult struct { + LatestHttpResponse *http.Response + Items []SubvolumeInfo +} + +type ListByVolumeCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByVolumeCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByVolume ... +func (c SubVolumesClient) ListByVolume(ctx context.Context, id VolumeId) (result ListByVolumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByVolumeCustomPager{}, + Path: fmt.Sprintf("%s/subVolumes", 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 *[]SubvolumeInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByVolumeComplete retrieves all the results into a single object +func (c SubVolumesClient) ListByVolumeComplete(ctx context.Context, id VolumeId) (ListByVolumeCompleteResult, error) { + return c.ListByVolumeCompleteMatchingPredicate(ctx, id, SubvolumeInfoOperationPredicate{}) +} + +// ListByVolumeCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SubVolumesClient) ListByVolumeCompleteMatchingPredicate(ctx context.Context, id VolumeId, predicate SubvolumeInfoOperationPredicate) (result ListByVolumeCompleteResult, err error) { + items := make([]SubvolumeInfo, 0) + + resp, err := c.ListByVolume(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByVolumeCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/method_update.go b/resource-manager/netapp/2024-07-01/subvolumes/method_update.go new file mode 100644 index 00000000000..294ead80256 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/method_update.go @@ -0,0 +1,75 @@ +package subvolumes + +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 + Model *SubvolumeInfo +} + +// Update ... +func (c SubVolumesClient) Update(ctx context.Context, id SubVolumeId, input SubvolumePatchRequest) (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 SubVolumesClient) UpdateThenPoll(ctx context.Context, id SubVolumeId, input SubvolumePatchRequest) 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/netapp/2024-07-01/subvolumes/model_subvolumeinfo.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumeinfo.go new file mode 100644 index 00000000000..3adbcfc6002 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumeinfo.go @@ -0,0 +1,16 @@ +package subvolumes + +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 SubvolumeInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubvolumeProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodel.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodel.go new file mode 100644 index 00000000000..d15828e2987 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodel.go @@ -0,0 +1,11 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubvolumeModel struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubvolumeModelProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodelproperties.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodelproperties.go new file mode 100644 index 00000000000..26911c386fc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumemodelproperties.go @@ -0,0 +1,71 @@ +package subvolumes + +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 SubvolumeModelProperties struct { + AccessedTimeStamp *string `json:"accessedTimeStamp,omitempty"` + BytesUsed *int64 `json:"bytesUsed,omitempty"` + ChangedTimeStamp *string `json:"changedTimeStamp,omitempty"` + CreationTimeStamp *string `json:"creationTimeStamp,omitempty"` + ModifiedTimeStamp *string `json:"modifiedTimeStamp,omitempty"` + ParentPath *string `json:"parentPath,omitempty"` + Path *string `json:"path,omitempty"` + Permissions *string `json:"permissions,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Size *int64 `json:"size,omitempty"` +} + +func (o *SubvolumeModelProperties) GetAccessedTimeStampAsTime() (*time.Time, error) { + if o.AccessedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AccessedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *SubvolumeModelProperties) SetAccessedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AccessedTimeStamp = &formatted +} + +func (o *SubvolumeModelProperties) GetChangedTimeStampAsTime() (*time.Time, error) { + if o.ChangedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *SubvolumeModelProperties) SetChangedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTimeStamp = &formatted +} + +func (o *SubvolumeModelProperties) GetCreationTimeStampAsTime() (*time.Time, error) { + if o.CreationTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *SubvolumeModelProperties) SetCreationTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeStamp = &formatted +} + +func (o *SubvolumeModelProperties) GetModifiedTimeStampAsTime() (*time.Time, error) { + if o.ModifiedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *SubvolumeModelProperties) SetModifiedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTimeStamp = &formatted +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchparams.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchparams.go new file mode 100644 index 00000000000..02ea94ff0ac --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchparams.go @@ -0,0 +1,9 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubvolumePatchParams struct { + Path *string `json:"path,omitempty"` + Size *int64 `json:"size,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchrequest.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchrequest.go new file mode 100644 index 00000000000..0394a55073a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumepatchrequest.go @@ -0,0 +1,8 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubvolumePatchRequest struct { + Properties *SubvolumePatchParams `json:"properties,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumeproperties.go b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumeproperties.go new file mode 100644 index 00000000000..899e995183a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/model_subvolumeproperties.go @@ -0,0 +1,11 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubvolumeProperties struct { + ParentPath *string `json:"parentPath,omitempty"` + Path *string `json:"path,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Size *int64 `json:"size,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/subvolumes/predicates.go b/resource-manager/netapp/2024-07-01/subvolumes/predicates.go new file mode 100644 index 00000000000..af649a6bd08 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/predicates.go @@ -0,0 +1,27 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubvolumeInfoOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SubvolumeInfoOperationPredicate) Matches(input SubvolumeInfo) 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/netapp/2024-07-01/subvolumes/version.go b/resource-manager/netapp/2024-07-01/subvolumes/version.go new file mode 100644 index 00000000000..59bf9a4d04a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/subvolumes/version.go @@ -0,0 +1,10 @@ +package subvolumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/subvolumes/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/README.md b/resource-manager/netapp/2024-07-01/volumegroups/README.md new file mode 100644 index 00000000000..1abfa213e1b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/README.md @@ -0,0 +1,81 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumegroups` Documentation + +The `volumegroups` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumegroups" +``` + + +### Client Initialization + +```go +client := volumegroups.NewVolumeGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumeGroupsClient.Create` + +```go +ctx := context.TODO() +id := volumegroups.NewVolumeGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "volumeGroupName") + +payload := volumegroups.VolumeGroupDetails{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumeGroupsClient.Delete` + +```go +ctx := context.TODO() +id := volumegroups.NewVolumeGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "volumeGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumeGroupsClient.Get` + +```go +ctx := context.TODO() +id := volumegroups.NewVolumeGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "volumeGroupName") + +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: `VolumeGroupsClient.ListByNetAppAccount` + +```go +ctx := context.TODO() +id := volumegroups.NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + +read, err := client.ListByNetAppAccount(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumegroups/client.go b/resource-manager/netapp/2024-07-01/volumegroups/client.go new file mode 100644 index 00000000000..580e5ac9fb8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/client.go @@ -0,0 +1,26 @@ +package volumegroups + +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 VolumeGroupsClient struct { + Client *resourcemanager.Client +} + +func NewVolumeGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumeGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumegroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumeGroupsClient: %+v", err) + } + + return &VolumeGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/constants.go b/resource-manager/netapp/2024-07-01/volumegroups/constants.go new file mode 100644 index 00000000000..5a28a92bfa4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/constants.go @@ -0,0 +1,649 @@ +package volumegroups + +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 ApplicationType string + +const ( + ApplicationTypeORACLE ApplicationType = "ORACLE" + ApplicationTypeSAPNegativeHANA ApplicationType = "SAP-HANA" +) + +func PossibleValuesForApplicationType() []string { + return []string{ + string(ApplicationTypeORACLE), + string(ApplicationTypeSAPNegativeHANA), + } +} + +func (s *ApplicationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationType(input string) (*ApplicationType, error) { + vals := map[string]ApplicationType{ + "oracle": ApplicationTypeORACLE, + "sap-hana": ApplicationTypeSAPNegativeHANA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationType(input) + return &out, nil +} + +type AvsDataStore string + +const ( + AvsDataStoreDisabled AvsDataStore = "Disabled" + AvsDataStoreEnabled AvsDataStore = "Enabled" +) + +func PossibleValuesForAvsDataStore() []string { + return []string{ + string(AvsDataStoreDisabled), + string(AvsDataStoreEnabled), + } +} + +func (s *AvsDataStore) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAvsDataStore(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAvsDataStore(input string) (*AvsDataStore, error) { + vals := map[string]AvsDataStore{ + "disabled": AvsDataStoreDisabled, + "enabled": AvsDataStoreEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AvsDataStore(input) + return &out, nil +} + +type ChownMode string + +const ( + ChownModeRestricted ChownMode = "Restricted" + ChownModeUnrestricted ChownMode = "Unrestricted" +) + +func PossibleValuesForChownMode() []string { + return []string{ + string(ChownModeRestricted), + string(ChownModeUnrestricted), + } +} + +func (s *ChownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChownMode(input string) (*ChownMode, error) { + vals := map[string]ChownMode{ + "restricted": ChownModeRestricted, + "unrestricted": ChownModeUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChownMode(input) + return &out, nil +} + +type CoolAccessRetrievalPolicy string + +const ( + CoolAccessRetrievalPolicyDefault CoolAccessRetrievalPolicy = "Default" + CoolAccessRetrievalPolicyNever CoolAccessRetrievalPolicy = "Never" + CoolAccessRetrievalPolicyOnRead CoolAccessRetrievalPolicy = "OnRead" +) + +func PossibleValuesForCoolAccessRetrievalPolicy() []string { + return []string{ + string(CoolAccessRetrievalPolicyDefault), + string(CoolAccessRetrievalPolicyNever), + string(CoolAccessRetrievalPolicyOnRead), + } +} + +func (s *CoolAccessRetrievalPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoolAccessRetrievalPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoolAccessRetrievalPolicy(input string) (*CoolAccessRetrievalPolicy, error) { + vals := map[string]CoolAccessRetrievalPolicy{ + "default": CoolAccessRetrievalPolicyDefault, + "never": CoolAccessRetrievalPolicyNever, + "onread": CoolAccessRetrievalPolicyOnRead, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoolAccessRetrievalPolicy(input) + return &out, nil +} + +type EnableSubvolumes string + +const ( + EnableSubvolumesDisabled EnableSubvolumes = "Disabled" + EnableSubvolumesEnabled EnableSubvolumes = "Enabled" +) + +func PossibleValuesForEnableSubvolumes() []string { + return []string{ + string(EnableSubvolumesDisabled), + string(EnableSubvolumesEnabled), + } +} + +func (s *EnableSubvolumes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableSubvolumes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnableSubvolumes(input string) (*EnableSubvolumes, error) { + vals := map[string]EnableSubvolumes{ + "disabled": EnableSubvolumesDisabled, + "enabled": EnableSubvolumesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnableSubvolumes(input) + return &out, nil +} + +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftPointKeyVault EncryptionKeySource = "Microsoft.KeyVault" + EncryptionKeySourceMicrosoftPointNetApp EncryptionKeySource = "Microsoft.NetApp" +) + +func PossibleValuesForEncryptionKeySource() []string { + return []string{ + string(EncryptionKeySourceMicrosoftPointKeyVault), + string(EncryptionKeySourceMicrosoftPointNetApp), + } +} + +func (s *EncryptionKeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionKeySource(input string) (*EncryptionKeySource, error) { + vals := map[string]EncryptionKeySource{ + "microsoft.keyvault": EncryptionKeySourceMicrosoftPointKeyVault, + "microsoft.netapp": EncryptionKeySourceMicrosoftPointNetApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionKeySource(input) + return &out, nil +} + +type EndpointType string + +const ( + EndpointTypeDst EndpointType = "dst" + EndpointTypeSrc EndpointType = "src" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeDst), + string(EndpointTypeSrc), + } +} + +func (s *EndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "dst": EndpointTypeDst, + "src": EndpointTypeSrc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type FileAccessLogs string + +const ( + FileAccessLogsDisabled FileAccessLogs = "Disabled" + FileAccessLogsEnabled FileAccessLogs = "Enabled" +) + +func PossibleValuesForFileAccessLogs() []string { + return []string{ + string(FileAccessLogsDisabled), + string(FileAccessLogsEnabled), + } +} + +func (s *FileAccessLogs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFileAccessLogs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFileAccessLogs(input string) (*FileAccessLogs, error) { + vals := map[string]FileAccessLogs{ + "disabled": FileAccessLogsDisabled, + "enabled": FileAccessLogsEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileAccessLogs(input) + return &out, nil +} + +type NetworkFeatures string + +const ( + NetworkFeaturesBasic NetworkFeatures = "Basic" + NetworkFeaturesBasicStandard NetworkFeatures = "Basic_Standard" + NetworkFeaturesStandard NetworkFeatures = "Standard" + NetworkFeaturesStandardBasic NetworkFeatures = "Standard_Basic" +) + +func PossibleValuesForNetworkFeatures() []string { + return []string{ + string(NetworkFeaturesBasic), + string(NetworkFeaturesBasicStandard), + string(NetworkFeaturesStandard), + string(NetworkFeaturesStandardBasic), + } +} + +func (s *NetworkFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkFeatures(input string) (*NetworkFeatures, error) { + vals := map[string]NetworkFeatures{ + "basic": NetworkFeaturesBasic, + "basic_standard": NetworkFeaturesBasicStandard, + "standard": NetworkFeaturesStandard, + "standard_basic": NetworkFeaturesStandardBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkFeatures(input) + return &out, nil +} + +type ReplicationSchedule string + +const ( + ReplicationScheduleDaily ReplicationSchedule = "daily" + ReplicationScheduleHourly ReplicationSchedule = "hourly" + ReplicationScheduleOneZerominutely ReplicationSchedule = "_10minutely" +) + +func PossibleValuesForReplicationSchedule() []string { + return []string{ + string(ReplicationScheduleDaily), + string(ReplicationScheduleHourly), + string(ReplicationScheduleOneZerominutely), + } +} + +func (s *ReplicationSchedule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationSchedule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationSchedule(input string) (*ReplicationSchedule, error) { + vals := map[string]ReplicationSchedule{ + "daily": ReplicationScheduleDaily, + "hourly": ReplicationScheduleHourly, + "_10minutely": ReplicationScheduleOneZerominutely, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationSchedule(input) + return &out, nil +} + +type SecurityStyle string + +const ( + SecurityStyleNtfs SecurityStyle = "ntfs" + SecurityStyleUnix SecurityStyle = "unix" +) + +func PossibleValuesForSecurityStyle() []string { + return []string{ + string(SecurityStyleNtfs), + string(SecurityStyleUnix), + } +} + +func (s *SecurityStyle) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityStyle(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityStyle(input string) (*SecurityStyle, error) { + vals := map[string]SecurityStyle{ + "ntfs": SecurityStyleNtfs, + "unix": SecurityStyleUnix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityStyle(input) + return &out, nil +} + +type ServiceLevel string + +const ( + ServiceLevelPremium ServiceLevel = "Premium" + ServiceLevelStandard ServiceLevel = "Standard" + ServiceLevelStandardZRS ServiceLevel = "StandardZRS" + ServiceLevelUltra ServiceLevel = "Ultra" +) + +func PossibleValuesForServiceLevel() []string { + return []string{ + string(ServiceLevelPremium), + string(ServiceLevelStandard), + string(ServiceLevelStandardZRS), + string(ServiceLevelUltra), + } +} + +func (s *ServiceLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLevel(input string) (*ServiceLevel, error) { + vals := map[string]ServiceLevel{ + "premium": ServiceLevelPremium, + "standard": ServiceLevelStandard, + "standardzrs": ServiceLevelStandardZRS, + "ultra": ServiceLevelUltra, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLevel(input) + return &out, nil +} + +type SmbAccessBasedEnumeration string + +const ( + SmbAccessBasedEnumerationDisabled SmbAccessBasedEnumeration = "Disabled" + SmbAccessBasedEnumerationEnabled SmbAccessBasedEnumeration = "Enabled" +) + +func PossibleValuesForSmbAccessBasedEnumeration() []string { + return []string{ + string(SmbAccessBasedEnumerationDisabled), + string(SmbAccessBasedEnumerationEnabled), + } +} + +func (s *SmbAccessBasedEnumeration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbAccessBasedEnumeration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbAccessBasedEnumeration(input string) (*SmbAccessBasedEnumeration, error) { + vals := map[string]SmbAccessBasedEnumeration{ + "disabled": SmbAccessBasedEnumerationDisabled, + "enabled": SmbAccessBasedEnumerationEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbAccessBasedEnumeration(input) + return &out, nil +} + +type SmbNonBrowsable string + +const ( + SmbNonBrowsableDisabled SmbNonBrowsable = "Disabled" + SmbNonBrowsableEnabled SmbNonBrowsable = "Enabled" +) + +func PossibleValuesForSmbNonBrowsable() []string { + return []string{ + string(SmbNonBrowsableDisabled), + string(SmbNonBrowsableEnabled), + } +} + +func (s *SmbNonBrowsable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbNonBrowsable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbNonBrowsable(input string) (*SmbNonBrowsable, error) { + vals := map[string]SmbNonBrowsable{ + "disabled": SmbNonBrowsableDisabled, + "enabled": SmbNonBrowsableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbNonBrowsable(input) + return &out, nil +} + +type VolumeStorageToNetworkProximity string + +const ( + VolumeStorageToNetworkProximityAcrossTTwo VolumeStorageToNetworkProximity = "AcrossT2" + VolumeStorageToNetworkProximityDefault VolumeStorageToNetworkProximity = "Default" + VolumeStorageToNetworkProximityTOne VolumeStorageToNetworkProximity = "T1" + VolumeStorageToNetworkProximityTTwo VolumeStorageToNetworkProximity = "T2" +) + +func PossibleValuesForVolumeStorageToNetworkProximity() []string { + return []string{ + string(VolumeStorageToNetworkProximityAcrossTTwo), + string(VolumeStorageToNetworkProximityDefault), + string(VolumeStorageToNetworkProximityTOne), + string(VolumeStorageToNetworkProximityTTwo), + } +} + +func (s *VolumeStorageToNetworkProximity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeStorageToNetworkProximity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeStorageToNetworkProximity(input string) (*VolumeStorageToNetworkProximity, error) { + vals := map[string]VolumeStorageToNetworkProximity{ + "acrosst2": VolumeStorageToNetworkProximityAcrossTTwo, + "default": VolumeStorageToNetworkProximityDefault, + "t1": VolumeStorageToNetworkProximityTOne, + "t2": VolumeStorageToNetworkProximityTTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeStorageToNetworkProximity(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount.go b/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount.go new file mode 100644 index 00000000000..b76f8ad025d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount.go @@ -0,0 +1,130 @@ +package volumegroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetAppAccountId{}) +} + +var _ resourceids.ResourceId = &NetAppAccountId{} + +// NetAppAccountId is a struct representing the Resource ID for a Net App Account +type NetAppAccountId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string +} + +// NewNetAppAccountID returns a new NetAppAccountId struct +func NewNetAppAccountID(subscriptionId string, resourceGroupName string, netAppAccountName string) NetAppAccountId { + return NetAppAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + } +} + +// ParseNetAppAccountID parses 'input' into a NetAppAccountId +func ParseNetAppAccountID(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetAppAccountIDInsensitively parses 'input' case-insensitively into a NetAppAccountId +// note: this method should only be used for API response data and not user input +func ParseNetAppAccountIDInsensitively(input string) (*NetAppAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetAppAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetAppAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetAppAccountId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + return nil +} + +// ValidateNetAppAccountID checks that 'input' can be parsed as a Net App Account ID +func ValidateNetAppAccountID(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 := ParseNetAppAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Net App Account ID +func (id NetAppAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Net App Account ID +func (id NetAppAccountId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + } +} + +// String returns a human-readable description of this Net App Account ID +func (id NetAppAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + } + return fmt.Sprintf("Net App Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount_test.go b/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount_test.go new file mode 100644 index 00000000000..ea57dfac8fc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/id_netappaccount_test.go @@ -0,0 +1,282 @@ +package volumegroups + +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 = &NetAppAccountId{} + +func TestNewNetAppAccountID(t *testing.T) { + id := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } +} + +func TestFormatNetAppAccountID(t *testing.T) { + actual := NewNetAppAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetAppAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestParseNetAppAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetAppAccountId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Expected: &NetAppAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetAppAccountIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + } +} + +func TestSegmentsForNetAppAccountId(t *testing.T) { + segments := NetAppAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetAppAccountId 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/netapp/2024-07-01/volumegroups/id_volumegroup.go b/resource-manager/netapp/2024-07-01/volumegroups/id_volumegroup.go new file mode 100644 index 00000000000..2fbfb2b2133 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/id_volumegroup.go @@ -0,0 +1,139 @@ +package volumegroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeGroupId{}) +} + +var _ resourceids.ResourceId = &VolumeGroupId{} + +// VolumeGroupId is a struct representing the Resource ID for a Volume Group +type VolumeGroupId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + VolumeGroupName string +} + +// NewVolumeGroupID returns a new VolumeGroupId struct +func NewVolumeGroupID(subscriptionId string, resourceGroupName string, netAppAccountName string, volumeGroupName string) VolumeGroupId { + return VolumeGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + VolumeGroupName: volumeGroupName, + } +} + +// ParseVolumeGroupID parses 'input' into a VolumeGroupId +func ParseVolumeGroupID(input string) (*VolumeGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeGroupIDInsensitively parses 'input' case-insensitively into a VolumeGroupId +// note: this method should only be used for API response data and not user input +func ParseVolumeGroupIDInsensitively(input string) (*VolumeGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeGroupId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.VolumeGroupName, ok = input.Parsed["volumeGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeGroupName", input) + } + + return nil +} + +// ValidateVolumeGroupID checks that 'input' can be parsed as a Volume Group ID +func ValidateVolumeGroupID(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 := ParseVolumeGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume Group ID +func (id VolumeGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/volumeGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.VolumeGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume Group ID +func (id VolumeGroupId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticVolumeGroups", "volumeGroups", "volumeGroups"), + resourceids.UserSpecifiedSegment("volumeGroupName", "volumeGroupName"), + } +} + +// String returns a human-readable description of this Volume Group ID +func (id VolumeGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Volume Group Name: %q", id.VolumeGroupName), + } + return fmt.Sprintf("Volume Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/id_volumegroup_test.go b/resource-manager/netapp/2024-07-01/volumegroups/id_volumegroup_test.go new file mode 100644 index 00000000000..9a1dd20a884 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/id_volumegroup_test.go @@ -0,0 +1,327 @@ +package volumegroups + +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 = &VolumeGroupId{} + +func TestNewVolumeGroupID(t *testing.T) { + id := NewVolumeGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "volumeGroupName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.VolumeGroupName != "volumeGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeGroupName'", id.VolumeGroupName, "volumeGroupName") + } +} + +func TestFormatVolumeGroupID(t *testing.T) { + actual := NewVolumeGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "volumeGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups/volumeGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeGroupId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups/volumeGroupName", + Expected: &VolumeGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + VolumeGroupName: "volumeGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups/volumeGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeGroupID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.VolumeGroupName != v.Expected.VolumeGroupName { + t.Fatalf("Expected %q but got %q for VolumeGroupName", v.Expected.VolumeGroupName, actual.VolumeGroupName) + } + + } +} + +func TestParseVolumeGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeGroupId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/vOlUmEgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups/volumeGroupName", + Expected: &VolumeGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + VolumeGroupName: "volumeGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/volumeGroups/volumeGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/vOlUmEgRoUpS/vOlUmEgRoUpNaMe", + Expected: &VolumeGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + VolumeGroupName: "vOlUmEgRoUpNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/vOlUmEgRoUpS/vOlUmEgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeGroupIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.VolumeGroupName != v.Expected.VolumeGroupName { + t.Fatalf("Expected %q but got %q for VolumeGroupName", v.Expected.VolumeGroupName, actual.VolumeGroupName) + } + + } +} + +func TestSegmentsForVolumeGroupId(t *testing.T) { + segments := VolumeGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeGroupId 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/netapp/2024-07-01/volumegroups/method_create.go b/resource-manager/netapp/2024-07-01/volumegroups/method_create.go new file mode 100644 index 00000000000..20ea352a9b8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/method_create.go @@ -0,0 +1,74 @@ +package volumegroups + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VolumeGroupDetails +} + +// Create ... +func (c VolumeGroupsClient) Create(ctx context.Context, id VolumeGroupId, input VolumeGroupDetails) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c VolumeGroupsClient) CreateThenPoll(ctx context.Context, id VolumeGroupId, input VolumeGroupDetails) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/method_delete.go b/resource-manager/netapp/2024-07-01/volumegroups/method_delete.go new file mode 100644 index 00000000000..32e6c75b150 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/method_delete.go @@ -0,0 +1,71 @@ +package volumegroups + +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 VolumeGroupsClient) Delete(ctx context.Context, id VolumeGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 VolumeGroupsClient) DeleteThenPoll(ctx context.Context, id VolumeGroupId) 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/netapp/2024-07-01/volumegroups/method_get.go b/resource-manager/netapp/2024-07-01/volumegroups/method_get.go new file mode 100644 index 00000000000..59130918900 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/method_get.go @@ -0,0 +1,53 @@ +package volumegroups + +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 *VolumeGroupDetails +} + +// Get ... +func (c VolumeGroupsClient) Get(ctx context.Context, id VolumeGroupId) (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 + } + + var model VolumeGroupDetails + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/method_listbynetappaccount.go b/resource-manager/netapp/2024-07-01/volumegroups/method_listbynetappaccount.go new file mode 100644 index 00000000000..29dee764979 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/method_listbynetappaccount.go @@ -0,0 +1,54 @@ +package volumegroups + +import ( + "context" + "fmt" + "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 ListByNetAppAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VolumeGroupList +} + +// ListByNetAppAccount ... +func (c VolumeGroupsClient) ListByNetAppAccount(ctx context.Context, id NetAppAccountId) (result ListByNetAppAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/volumeGroups", 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 + } + + var model VolumeGroupList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_exportpolicyrule.go b/resource-manager/netapp/2024-07-01/volumegroups/model_exportpolicyrule.go new file mode 100644 index 00000000000..e17395ba1a7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_exportpolicyrule.go @@ -0,0 +1,22 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportPolicyRule struct { + AllowedClients *string `json:"allowedClients,omitempty"` + ChownMode *ChownMode `json:"chownMode,omitempty"` + Cifs *bool `json:"cifs,omitempty"` + HasRootAccess *bool `json:"hasRootAccess,omitempty"` + Kerberos5ReadOnly *bool `json:"kerberos5ReadOnly,omitempty"` + Kerberos5ReadWrite *bool `json:"kerberos5ReadWrite,omitempty"` + Kerberos5iReadOnly *bool `json:"kerberos5iReadOnly,omitempty"` + Kerberos5iReadWrite *bool `json:"kerberos5iReadWrite,omitempty"` + Kerberos5pReadOnly *bool `json:"kerberos5pReadOnly,omitempty"` + Kerberos5pReadWrite *bool `json:"kerberos5pReadWrite,omitempty"` + Nfsv3 *bool `json:"nfsv3,omitempty"` + Nfsv41 *bool `json:"nfsv41,omitempty"` + RuleIndex *int64 `json:"ruleIndex,omitempty"` + UnixReadOnly *bool `json:"unixReadOnly,omitempty"` + UnixReadWrite *bool `json:"unixReadWrite,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_mounttargetproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_mounttargetproperties.go new file mode 100644 index 00000000000..5844b80ce9d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_mounttargetproperties.go @@ -0,0 +1,11 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MountTargetProperties struct { + FileSystemId string `json:"fileSystemId"` + IPAddress *string `json:"ipAddress,omitempty"` + MountTargetId *string `json:"mountTargetId,omitempty"` + SmbServerFqdn *string `json:"smbServerFqdn,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_placementkeyvaluepairs.go b/resource-manager/netapp/2024-07-01/volumegroups/model_placementkeyvaluepairs.go new file mode 100644 index 00000000000..1714b1662a1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_placementkeyvaluepairs.go @@ -0,0 +1,9 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlacementKeyValuePairs struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_remotepath.go b/resource-manager/netapp/2024-07-01/volumegroups/model_remotepath.go new file mode 100644 index 00000000000..e1b941b3ea6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_remotepath.go @@ -0,0 +1,10 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePath struct { + ExternalHostName string `json:"externalHostName"` + ServerName string `json:"serverName"` + VolumeName string `json:"volumeName"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_replicationobject.go b/resource-manager/netapp/2024-07-01/volumegroups/model_replicationobject.go new file mode 100644 index 00000000000..9762765c472 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_replicationobject.go @@ -0,0 +1,13 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationObject struct { + EndpointType *EndpointType `json:"endpointType,omitempty"` + RemotePath *RemotePath `json:"remotePath,omitempty"` + RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` + RemoteVolumeResourceId string `json:"remoteVolumeResourceId"` + ReplicationId *string `json:"replicationId,omitempty"` + ReplicationSchedule *ReplicationSchedule `json:"replicationSchedule,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumebackupproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumebackupproperties.go new file mode 100644 index 00000000000..39ce5a2b79b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumebackupproperties.go @@ -0,0 +1,10 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeBackupProperties struct { + BackupPolicyId *string `json:"backupPolicyId,omitempty"` + BackupVaultId *string `json:"backupVaultId,omitempty"` + PolicyEnforced *bool `json:"policyEnforced,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroup.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroup.go new file mode 100644 index 00000000000..5e4df7bb9c0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroup.go @@ -0,0 +1,12 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroup struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VolumeGroupListProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupdetails.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupdetails.go new file mode 100644 index 00000000000..5f01af82c0f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupdetails.go @@ -0,0 +1,12 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupDetails struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VolumeGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplist.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplist.go new file mode 100644 index 00000000000..447c6e6e858 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplist.go @@ -0,0 +1,8 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupList struct { + Value *[]VolumeGroup `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplistproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplistproperties.go new file mode 100644 index 00000000000..5788ee516fc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegrouplistproperties.go @@ -0,0 +1,9 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupListProperties struct { + GroupMetaData *VolumeGroupMetaData `json:"groupMetaData,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupmetadata.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupmetadata.go new file mode 100644 index 00000000000..b9fa343690c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupmetadata.go @@ -0,0 +1,12 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupMetaData struct { + ApplicationIdentifier *string `json:"applicationIdentifier,omitempty"` + ApplicationType *ApplicationType `json:"applicationType,omitempty"` + GlobalPlacementRules *[]PlacementKeyValuePairs `json:"globalPlacementRules,omitempty"` + GroupDescription *string `json:"groupDescription,omitempty"` + VolumesCount *int64 `json:"volumesCount,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupproperties.go new file mode 100644 index 00000000000..0bab153b397 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupproperties.go @@ -0,0 +1,10 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupProperties struct { + GroupMetaData *VolumeGroupMetaData `json:"groupMetaData,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Volumes *[]VolumeGroupVolumeProperties `json:"volumes,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupvolumeproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupvolumeproperties.go new file mode 100644 index 00000000000..935a8a5f480 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumegroupvolumeproperties.go @@ -0,0 +1,17 @@ +package volumegroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeGroupVolumeProperties struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties VolumeProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumeproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumeproperties.go new file mode 100644 index 00000000000..de5f24fdc19 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumeproperties.go @@ -0,0 +1,62 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeProperties struct { + ActualThroughputMibps *float64 `json:"actualThroughputMibps,omitempty"` + AvsDataStore *AvsDataStore `json:"avsDataStore,omitempty"` + BackupId *string `json:"backupId,omitempty"` + BaremetalTenantId *string `json:"baremetalTenantId,omitempty"` + CapacityPoolResourceId *string `json:"capacityPoolResourceId,omitempty"` + CloneProgress *int64 `json:"cloneProgress,omitempty"` + CoolAccess *bool `json:"coolAccess,omitempty"` + CoolAccessRetrievalPolicy *CoolAccessRetrievalPolicy `json:"coolAccessRetrievalPolicy,omitempty"` + CoolnessPeriod *int64 `json:"coolnessPeriod,omitempty"` + CreationToken string `json:"creationToken"` + DataProtection *VolumePropertiesDataProtection `json:"dataProtection,omitempty"` + DataStoreResourceId *[]string `json:"dataStoreResourceId,omitempty"` + DefaultGroupQuotaInKiBs *int64 `json:"defaultGroupQuotaInKiBs,omitempty"` + DefaultUserQuotaInKiBs *int64 `json:"defaultUserQuotaInKiBs,omitempty"` + DeleteBaseSnapshot *bool `json:"deleteBaseSnapshot,omitempty"` + EffectiveNetworkFeatures *NetworkFeatures `json:"effectiveNetworkFeatures,omitempty"` + EnableSubvolumes *EnableSubvolumes `json:"enableSubvolumes,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` + EncryptionKeySource *EncryptionKeySource `json:"encryptionKeySource,omitempty"` + ExportPolicy *VolumePropertiesExportPolicy `json:"exportPolicy,omitempty"` + FileAccessLogs *FileAccessLogs `json:"fileAccessLogs,omitempty"` + FileSystemId *string `json:"fileSystemId,omitempty"` + IsDefaultQuotaEnabled *bool `json:"isDefaultQuotaEnabled,omitempty"` + IsLargeVolume *bool `json:"isLargeVolume,omitempty"` + IsRestoring *bool `json:"isRestoring,omitempty"` + KerberosEnabled *bool `json:"kerberosEnabled,omitempty"` + KeyVaultPrivateEndpointResourceId *string `json:"keyVaultPrivateEndpointResourceId,omitempty"` + LdapEnabled *bool `json:"ldapEnabled,omitempty"` + MaximumNumberOfFiles *int64 `json:"maximumNumberOfFiles,omitempty"` + MountTargets *[]MountTargetProperties `json:"mountTargets,omitempty"` + NetworkFeatures *NetworkFeatures `json:"networkFeatures,omitempty"` + NetworkSiblingSetId *string `json:"networkSiblingSetId,omitempty"` + OriginatingResourceId *string `json:"originatingResourceId,omitempty"` + PlacementRules *[]PlacementKeyValuePairs `json:"placementRules,omitempty"` + ProtocolTypes *[]string `json:"protocolTypes,omitempty"` + ProvisionedAvailabilityZone *string `json:"provisionedAvailabilityZone,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroup *string `json:"proximityPlacementGroup,omitempty"` + SecurityStyle *SecurityStyle `json:"securityStyle,omitempty"` + ServiceLevel *ServiceLevel `json:"serviceLevel,omitempty"` + SmbAccessBasedEnumeration *SmbAccessBasedEnumeration `json:"smbAccessBasedEnumeration,omitempty"` + SmbContinuouslyAvailable *bool `json:"smbContinuouslyAvailable,omitempty"` + SmbEncryption *bool `json:"smbEncryption,omitempty"` + SmbNonBrowsable *SmbNonBrowsable `json:"smbNonBrowsable,omitempty"` + SnapshotDirectoryVisible *bool `json:"snapshotDirectoryVisible,omitempty"` + SnapshotId *string `json:"snapshotId,omitempty"` + StorageToNetworkProximity *VolumeStorageToNetworkProximity `json:"storageToNetworkProximity,omitempty"` + SubnetId string `json:"subnetId"` + T2Network *string `json:"t2Network,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` + UnixPermissions *string `json:"unixPermissions,omitempty"` + UsageThreshold int64 `json:"usageThreshold"` + VolumeGroupName *string `json:"volumeGroupName,omitempty"` + VolumeSpecName *string `json:"volumeSpecName,omitempty"` + VolumeType *string `json:"volumeType,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesdataprotection.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesdataprotection.go new file mode 100644 index 00000000000..632e45e64b0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesdataprotection.go @@ -0,0 +1,11 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesDataProtection struct { + Backup *VolumeBackupProperties `json:"backup,omitempty"` + Replication *ReplicationObject `json:"replication,omitempty"` + Snapshot *VolumeSnapshotProperties `json:"snapshot,omitempty"` + VolumeRelocation *VolumeRelocationProperties `json:"volumeRelocation,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesexportpolicy.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesexportpolicy.go new file mode 100644 index 00000000000..227c8586d6f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumepropertiesexportpolicy.go @@ -0,0 +1,8 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesExportPolicy struct { + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumerelocationproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumerelocationproperties.go new file mode 100644 index 00000000000..4fea57c7396 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumerelocationproperties.go @@ -0,0 +1,9 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeRelocationProperties struct { + ReadyToBeFinalized *bool `json:"readyToBeFinalized,omitempty"` + RelocationRequested *bool `json:"relocationRequested,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/model_volumesnapshotproperties.go b/resource-manager/netapp/2024-07-01/volumegroups/model_volumesnapshotproperties.go new file mode 100644 index 00000000000..a3f5011da3b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/model_volumesnapshotproperties.go @@ -0,0 +1,8 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeSnapshotProperties struct { + SnapshotPolicyId *string `json:"snapshotPolicyId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumegroups/version.go b/resource-manager/netapp/2024-07-01/volumegroups/version.go new file mode 100644 index 00000000000..42e9162f972 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumegroups/version.go @@ -0,0 +1,10 @@ +package volumegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumegroups/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/README.md b/resource-manager/netapp/2024-07-01/volumequotarules/README.md new file mode 100644 index 00000000000..17bf3bef83a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/README.md @@ -0,0 +1,98 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumequotarules` Documentation + +The `volumequotarules` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumequotarules" +``` + + +### Client Initialization + +```go +client := volumequotarules.NewVolumeQuotaRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumeQuotaRulesClient.Create` + +```go +ctx := context.TODO() +id := volumequotarules.NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName") + +payload := volumequotarules.VolumeQuotaRule{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumeQuotaRulesClient.Delete` + +```go +ctx := context.TODO() +id := volumequotarules.NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumeQuotaRulesClient.Get` + +```go +ctx := context.TODO() +id := volumequotarules.NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName") + +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: `VolumeQuotaRulesClient.ListByVolume` + +```go +ctx := context.TODO() +id := volumequotarules.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.ListByVolume(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VolumeQuotaRulesClient.Update` + +```go +ctx := context.TODO() +id := volumequotarules.NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName") + +payload := volumequotarules.VolumeQuotaRulePatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/client.go b/resource-manager/netapp/2024-07-01/volumequotarules/client.go new file mode 100644 index 00000000000..b42efdd36e2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/client.go @@ -0,0 +1,26 @@ +package volumequotarules + +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 VolumeQuotaRulesClient struct { + Client *resourcemanager.Client +} + +func NewVolumeQuotaRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumeQuotaRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumequotarules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumeQuotaRulesClient: %+v", err) + } + + return &VolumeQuotaRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/constants.go b/resource-manager/netapp/2024-07-01/volumequotarules/constants.go new file mode 100644 index 00000000000..fb0e41e1afb --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/constants.go @@ -0,0 +1,113 @@ +package volumequotarules + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStatePatching ProvisioningState = "Patching" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStatePatching), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "patching": ProvisioningStatePatching, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Type string + +const ( + TypeDefaultGroupQuota Type = "DefaultGroupQuota" + TypeDefaultUserQuota Type = "DefaultUserQuota" + TypeIndividualGroupQuota Type = "IndividualGroupQuota" + TypeIndividualUserQuota Type = "IndividualUserQuota" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeDefaultGroupQuota), + string(TypeDefaultUserQuota), + string(TypeIndividualGroupQuota), + string(TypeIndividualUserQuota), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "defaultgroupquota": TypeDefaultGroupQuota, + "defaultuserquota": TypeDefaultUserQuota, + "individualgroupquota": TypeIndividualGroupQuota, + "individualuserquota": TypeIndividualUserQuota, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/id_volume.go b/resource-manager/netapp/2024-07-01/volumequotarules/id_volume.go new file mode 100644 index 00000000000..f3aab9f00df --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/id_volume.go @@ -0,0 +1,148 @@ +package volumequotarules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumequotarules/id_volume_test.go new file mode 100644 index 00000000000..c0acc543f9f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/id_volume_test.go @@ -0,0 +1,372 @@ +package volumequotarules + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumequotarules/id_volumequotarule.go b/resource-manager/netapp/2024-07-01/volumequotarules/id_volumequotarule.go new file mode 100644 index 00000000000..9007e1468ae --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/id_volumequotarule.go @@ -0,0 +1,157 @@ +package volumequotarules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeQuotaRuleId{}) +} + +var _ resourceids.ResourceId = &VolumeQuotaRuleId{} + +// VolumeQuotaRuleId is a struct representing the Resource ID for a Volume Quota Rule +type VolumeQuotaRuleId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string + VolumeQuotaRuleName string +} + +// NewVolumeQuotaRuleID returns a new VolumeQuotaRuleId struct +func NewVolumeQuotaRuleID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string, volumeQuotaRuleName string) VolumeQuotaRuleId { + return VolumeQuotaRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + VolumeQuotaRuleName: volumeQuotaRuleName, + } +} + +// ParseVolumeQuotaRuleID parses 'input' into a VolumeQuotaRuleId +func ParseVolumeQuotaRuleID(input string) (*VolumeQuotaRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeQuotaRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeQuotaRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeQuotaRuleIDInsensitively parses 'input' case-insensitively into a VolumeQuotaRuleId +// note: this method should only be used for API response data and not user input +func ParseVolumeQuotaRuleIDInsensitively(input string) (*VolumeQuotaRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeQuotaRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeQuotaRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeQuotaRuleId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + if id.VolumeQuotaRuleName, ok = input.Parsed["volumeQuotaRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeQuotaRuleName", input) + } + + return nil +} + +// ValidateVolumeQuotaRuleID checks that 'input' can be parsed as a Volume Quota Rule ID +func ValidateVolumeQuotaRuleID(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 := ParseVolumeQuotaRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume Quota Rule ID +func (id VolumeQuotaRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s/volumeQuotaRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName, id.VolumeQuotaRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume Quota Rule ID +func (id VolumeQuotaRuleId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + resourceids.StaticSegment("staticVolumeQuotaRules", "volumeQuotaRules", "volumeQuotaRules"), + resourceids.UserSpecifiedSegment("volumeQuotaRuleName", "volumeQuotaRuleName"), + } +} + +// String returns a human-readable description of this Volume Quota Rule ID +func (id VolumeQuotaRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + fmt.Sprintf("Volume Quota Rule Name: %q", id.VolumeQuotaRuleName), + } + return fmt.Sprintf("Volume Quota Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/id_volumequotarule_test.go b/resource-manager/netapp/2024-07-01/volumequotarules/id_volumequotarule_test.go new file mode 100644 index 00000000000..3b3ee84e25f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/id_volumequotarule_test.go @@ -0,0 +1,417 @@ +package volumequotarules + +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 = &VolumeQuotaRuleId{} + +func TestNewVolumeQuotaRuleID(t *testing.T) { + id := NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } + + if id.VolumeQuotaRuleName != "volumeQuotaRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeQuotaRuleName'", id.VolumeQuotaRuleName, "volumeQuotaRuleName") + } +} + +func TestFormatVolumeQuotaRuleID(t *testing.T) { + actual := NewVolumeQuotaRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName", "volumeQuotaRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules/volumeQuotaRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeQuotaRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeQuotaRuleId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules/volumeQuotaRuleName", + Expected: &VolumeQuotaRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + VolumeQuotaRuleName: "volumeQuotaRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules/volumeQuotaRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeQuotaRuleID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.VolumeQuotaRuleName != v.Expected.VolumeQuotaRuleName { + t.Fatalf("Expected %q but got %q for VolumeQuotaRuleName", v.Expected.VolumeQuotaRuleName, actual.VolumeQuotaRuleName) + } + + } +} + +func TestParseVolumeQuotaRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeQuotaRuleId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/vOlUmEqUoTaRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules/volumeQuotaRuleName", + Expected: &VolumeQuotaRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + VolumeQuotaRuleName: "volumeQuotaRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/volumeQuotaRules/volumeQuotaRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/vOlUmEqUoTaRuLeS/vOlUmEqUoTaRuLeNaMe", + Expected: &VolumeQuotaRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + VolumeQuotaRuleName: "vOlUmEqUoTaRuLeNaMe", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/vOlUmEqUoTaRuLeS/vOlUmEqUoTaRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeQuotaRuleIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + if actual.VolumeQuotaRuleName != v.Expected.VolumeQuotaRuleName { + t.Fatalf("Expected %q but got %q for VolumeQuotaRuleName", v.Expected.VolumeQuotaRuleName, actual.VolumeQuotaRuleName) + } + + } +} + +func TestSegmentsForVolumeQuotaRuleId(t *testing.T) { + segments := VolumeQuotaRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeQuotaRuleId 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/netapp/2024-07-01/volumequotarules/method_create.go b/resource-manager/netapp/2024-07-01/volumequotarules/method_create.go new file mode 100644 index 00000000000..4904525f7a0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/method_create.go @@ -0,0 +1,75 @@ +package volumequotarules + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VolumeQuotaRule +} + +// Create ... +func (c VolumeQuotaRulesClient) Create(ctx context.Context, id VolumeQuotaRuleId, input VolumeQuotaRule) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c VolumeQuotaRulesClient) CreateThenPoll(ctx context.Context, id VolumeQuotaRuleId, input VolumeQuotaRule) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/method_delete.go b/resource-manager/netapp/2024-07-01/volumequotarules/method_delete.go new file mode 100644 index 00000000000..59d6fbecf0a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/method_delete.go @@ -0,0 +1,71 @@ +package volumequotarules + +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 VolumeQuotaRulesClient) Delete(ctx context.Context, id VolumeQuotaRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 VolumeQuotaRulesClient) DeleteThenPoll(ctx context.Context, id VolumeQuotaRuleId) 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/netapp/2024-07-01/volumequotarules/method_get.go b/resource-manager/netapp/2024-07-01/volumequotarules/method_get.go new file mode 100644 index 00000000000..0c82ebc839b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/method_get.go @@ -0,0 +1,53 @@ +package volumequotarules + +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 *VolumeQuotaRule +} + +// Get ... +func (c VolumeQuotaRulesClient) Get(ctx context.Context, id VolumeQuotaRuleId) (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 + } + + var model VolumeQuotaRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/method_listbyvolume.go b/resource-manager/netapp/2024-07-01/volumequotarules/method_listbyvolume.go new file mode 100644 index 00000000000..87cd029de34 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/method_listbyvolume.go @@ -0,0 +1,54 @@ +package volumequotarules + +import ( + "context" + "fmt" + "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 ListByVolumeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VolumeQuotaRulesList +} + +// ListByVolume ... +func (c VolumeQuotaRulesClient) ListByVolume(ctx context.Context, id VolumeId) (result ListByVolumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/volumeQuotaRules", 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 + } + + var model VolumeQuotaRulesList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/method_update.go b/resource-manager/netapp/2024-07-01/volumequotarules/method_update.go new file mode 100644 index 00000000000..39d68a726c3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/method_update.go @@ -0,0 +1,75 @@ +package volumequotarules + +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 + Model *VolumeQuotaRule +} + +// Update ... +func (c VolumeQuotaRulesClient) Update(ctx context.Context, id VolumeQuotaRuleId, input VolumeQuotaRulePatch) (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 VolumeQuotaRulesClient) UpdateThenPoll(ctx context.Context, id VolumeQuotaRuleId, input VolumeQuotaRulePatch) 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/netapp/2024-07-01/volumequotarules/model_volumequotarule.go b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarule.go new file mode 100644 index 00000000000..9436f5c0008 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarule.go @@ -0,0 +1,18 @@ +package volumequotarules + +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 VolumeQuotaRule struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *VolumeQuotaRulesProperties `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/netapp/2024-07-01/volumequotarules/model_volumequotarulepatch.go b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarulepatch.go new file mode 100644 index 00000000000..fbf72546c43 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarulepatch.go @@ -0,0 +1,9 @@ +package volumequotarules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeQuotaRulePatch struct { + Properties *VolumeQuotaRulesProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotaruleslist.go b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotaruleslist.go new file mode 100644 index 00000000000..d9e15cf8035 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotaruleslist.go @@ -0,0 +1,8 @@ +package volumequotarules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeQuotaRulesList struct { + Value *[]VolumeQuotaRule `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarulesproperties.go b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarulesproperties.go new file mode 100644 index 00000000000..5ae037e0a23 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/model_volumequotarulesproperties.go @@ -0,0 +1,11 @@ +package volumequotarules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeQuotaRulesProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + QuotaSizeInKiBs *int64 `json:"quotaSizeInKiBs,omitempty"` + QuotaTarget *string `json:"quotaTarget,omitempty"` + QuotaType *Type `json:"quotaType,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumequotarules/version.go b/resource-manager/netapp/2024-07-01/volumequotarules/version.go new file mode 100644 index 00000000000..0a51dd7732c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumequotarules/version.go @@ -0,0 +1,10 @@ +package volumequotarules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumequotarules/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumes/README.md b/resource-manager/netapp/2024-07-01/volumes/README.md new file mode 100644 index 00000000000..e7fec0a78a4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumes` Documentation + +The `volumes` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumes" +``` + + +### Client Initialization + +```go +client := volumes.NewVolumesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := volumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumes.Volume{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesClient.Delete` + +```go +ctx := context.TODO() +id := volumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.DeleteThenPoll(ctx, id, volumes.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesClient.Get` + +```go +ctx := context.TODO() +id := volumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +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: `VolumesClient.List` + +```go +ctx := context.TODO() +id := volumes.NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + +// 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: `VolumesClient.PopulateAvailabilityZone` + +```go +ctx := context.TODO() +id := volumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.PopulateAvailabilityZoneThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesClient.Update` + +```go +ctx := context.TODO() +id := volumes.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumes.VolumePatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumes/client.go b/resource-manager/netapp/2024-07-01/volumes/client.go new file mode 100644 index 00000000000..6ead8cc3e7d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/client.go @@ -0,0 +1,26 @@ +package volumes + +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 VolumesClient struct { + Client *resourcemanager.Client +} + +func NewVolumesClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesClient: %+v", err) + } + + return &VolumesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumes/constants.go b/resource-manager/netapp/2024-07-01/volumes/constants.go new file mode 100644 index 00000000000..f3648628f02 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/constants.go @@ -0,0 +1,608 @@ +package volumes + +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 AvsDataStore string + +const ( + AvsDataStoreDisabled AvsDataStore = "Disabled" + AvsDataStoreEnabled AvsDataStore = "Enabled" +) + +func PossibleValuesForAvsDataStore() []string { + return []string{ + string(AvsDataStoreDisabled), + string(AvsDataStoreEnabled), + } +} + +func (s *AvsDataStore) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAvsDataStore(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAvsDataStore(input string) (*AvsDataStore, error) { + vals := map[string]AvsDataStore{ + "disabled": AvsDataStoreDisabled, + "enabled": AvsDataStoreEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AvsDataStore(input) + return &out, nil +} + +type ChownMode string + +const ( + ChownModeRestricted ChownMode = "Restricted" + ChownModeUnrestricted ChownMode = "Unrestricted" +) + +func PossibleValuesForChownMode() []string { + return []string{ + string(ChownModeRestricted), + string(ChownModeUnrestricted), + } +} + +func (s *ChownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChownMode(input string) (*ChownMode, error) { + vals := map[string]ChownMode{ + "restricted": ChownModeRestricted, + "unrestricted": ChownModeUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChownMode(input) + return &out, nil +} + +type CoolAccessRetrievalPolicy string + +const ( + CoolAccessRetrievalPolicyDefault CoolAccessRetrievalPolicy = "Default" + CoolAccessRetrievalPolicyNever CoolAccessRetrievalPolicy = "Never" + CoolAccessRetrievalPolicyOnRead CoolAccessRetrievalPolicy = "OnRead" +) + +func PossibleValuesForCoolAccessRetrievalPolicy() []string { + return []string{ + string(CoolAccessRetrievalPolicyDefault), + string(CoolAccessRetrievalPolicyNever), + string(CoolAccessRetrievalPolicyOnRead), + } +} + +func (s *CoolAccessRetrievalPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoolAccessRetrievalPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoolAccessRetrievalPolicy(input string) (*CoolAccessRetrievalPolicy, error) { + vals := map[string]CoolAccessRetrievalPolicy{ + "default": CoolAccessRetrievalPolicyDefault, + "never": CoolAccessRetrievalPolicyNever, + "onread": CoolAccessRetrievalPolicyOnRead, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoolAccessRetrievalPolicy(input) + return &out, nil +} + +type EnableSubvolumes string + +const ( + EnableSubvolumesDisabled EnableSubvolumes = "Disabled" + EnableSubvolumesEnabled EnableSubvolumes = "Enabled" +) + +func PossibleValuesForEnableSubvolumes() []string { + return []string{ + string(EnableSubvolumesDisabled), + string(EnableSubvolumesEnabled), + } +} + +func (s *EnableSubvolumes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableSubvolumes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnableSubvolumes(input string) (*EnableSubvolumes, error) { + vals := map[string]EnableSubvolumes{ + "disabled": EnableSubvolumesDisabled, + "enabled": EnableSubvolumesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnableSubvolumes(input) + return &out, nil +} + +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftPointKeyVault EncryptionKeySource = "Microsoft.KeyVault" + EncryptionKeySourceMicrosoftPointNetApp EncryptionKeySource = "Microsoft.NetApp" +) + +func PossibleValuesForEncryptionKeySource() []string { + return []string{ + string(EncryptionKeySourceMicrosoftPointKeyVault), + string(EncryptionKeySourceMicrosoftPointNetApp), + } +} + +func (s *EncryptionKeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionKeySource(input string) (*EncryptionKeySource, error) { + vals := map[string]EncryptionKeySource{ + "microsoft.keyvault": EncryptionKeySourceMicrosoftPointKeyVault, + "microsoft.netapp": EncryptionKeySourceMicrosoftPointNetApp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionKeySource(input) + return &out, nil +} + +type EndpointType string + +const ( + EndpointTypeDst EndpointType = "dst" + EndpointTypeSrc EndpointType = "src" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeDst), + string(EndpointTypeSrc), + } +} + +func (s *EndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "dst": EndpointTypeDst, + "src": EndpointTypeSrc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type FileAccessLogs string + +const ( + FileAccessLogsDisabled FileAccessLogs = "Disabled" + FileAccessLogsEnabled FileAccessLogs = "Enabled" +) + +func PossibleValuesForFileAccessLogs() []string { + return []string{ + string(FileAccessLogsDisabled), + string(FileAccessLogsEnabled), + } +} + +func (s *FileAccessLogs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFileAccessLogs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFileAccessLogs(input string) (*FileAccessLogs, error) { + vals := map[string]FileAccessLogs{ + "disabled": FileAccessLogsDisabled, + "enabled": FileAccessLogsEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileAccessLogs(input) + return &out, nil +} + +type NetworkFeatures string + +const ( + NetworkFeaturesBasic NetworkFeatures = "Basic" + NetworkFeaturesBasicStandard NetworkFeatures = "Basic_Standard" + NetworkFeaturesStandard NetworkFeatures = "Standard" + NetworkFeaturesStandardBasic NetworkFeatures = "Standard_Basic" +) + +func PossibleValuesForNetworkFeatures() []string { + return []string{ + string(NetworkFeaturesBasic), + string(NetworkFeaturesBasicStandard), + string(NetworkFeaturesStandard), + string(NetworkFeaturesStandardBasic), + } +} + +func (s *NetworkFeatures) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkFeatures(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkFeatures(input string) (*NetworkFeatures, error) { + vals := map[string]NetworkFeatures{ + "basic": NetworkFeaturesBasic, + "basic_standard": NetworkFeaturesBasicStandard, + "standard": NetworkFeaturesStandard, + "standard_basic": NetworkFeaturesStandardBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkFeatures(input) + return &out, nil +} + +type ReplicationSchedule string + +const ( + ReplicationScheduleDaily ReplicationSchedule = "daily" + ReplicationScheduleHourly ReplicationSchedule = "hourly" + ReplicationScheduleOneZerominutely ReplicationSchedule = "_10minutely" +) + +func PossibleValuesForReplicationSchedule() []string { + return []string{ + string(ReplicationScheduleDaily), + string(ReplicationScheduleHourly), + string(ReplicationScheduleOneZerominutely), + } +} + +func (s *ReplicationSchedule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationSchedule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationSchedule(input string) (*ReplicationSchedule, error) { + vals := map[string]ReplicationSchedule{ + "daily": ReplicationScheduleDaily, + "hourly": ReplicationScheduleHourly, + "_10minutely": ReplicationScheduleOneZerominutely, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationSchedule(input) + return &out, nil +} + +type SecurityStyle string + +const ( + SecurityStyleNtfs SecurityStyle = "ntfs" + SecurityStyleUnix SecurityStyle = "unix" +) + +func PossibleValuesForSecurityStyle() []string { + return []string{ + string(SecurityStyleNtfs), + string(SecurityStyleUnix), + } +} + +func (s *SecurityStyle) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityStyle(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityStyle(input string) (*SecurityStyle, error) { + vals := map[string]SecurityStyle{ + "ntfs": SecurityStyleNtfs, + "unix": SecurityStyleUnix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityStyle(input) + return &out, nil +} + +type ServiceLevel string + +const ( + ServiceLevelPremium ServiceLevel = "Premium" + ServiceLevelStandard ServiceLevel = "Standard" + ServiceLevelStandardZRS ServiceLevel = "StandardZRS" + ServiceLevelUltra ServiceLevel = "Ultra" +) + +func PossibleValuesForServiceLevel() []string { + return []string{ + string(ServiceLevelPremium), + string(ServiceLevelStandard), + string(ServiceLevelStandardZRS), + string(ServiceLevelUltra), + } +} + +func (s *ServiceLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLevel(input string) (*ServiceLevel, error) { + vals := map[string]ServiceLevel{ + "premium": ServiceLevelPremium, + "standard": ServiceLevelStandard, + "standardzrs": ServiceLevelStandardZRS, + "ultra": ServiceLevelUltra, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLevel(input) + return &out, nil +} + +type SmbAccessBasedEnumeration string + +const ( + SmbAccessBasedEnumerationDisabled SmbAccessBasedEnumeration = "Disabled" + SmbAccessBasedEnumerationEnabled SmbAccessBasedEnumeration = "Enabled" +) + +func PossibleValuesForSmbAccessBasedEnumeration() []string { + return []string{ + string(SmbAccessBasedEnumerationDisabled), + string(SmbAccessBasedEnumerationEnabled), + } +} + +func (s *SmbAccessBasedEnumeration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbAccessBasedEnumeration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbAccessBasedEnumeration(input string) (*SmbAccessBasedEnumeration, error) { + vals := map[string]SmbAccessBasedEnumeration{ + "disabled": SmbAccessBasedEnumerationDisabled, + "enabled": SmbAccessBasedEnumerationEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbAccessBasedEnumeration(input) + return &out, nil +} + +type SmbNonBrowsable string + +const ( + SmbNonBrowsableDisabled SmbNonBrowsable = "Disabled" + SmbNonBrowsableEnabled SmbNonBrowsable = "Enabled" +) + +func PossibleValuesForSmbNonBrowsable() []string { + return []string{ + string(SmbNonBrowsableDisabled), + string(SmbNonBrowsableEnabled), + } +} + +func (s *SmbNonBrowsable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSmbNonBrowsable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSmbNonBrowsable(input string) (*SmbNonBrowsable, error) { + vals := map[string]SmbNonBrowsable{ + "disabled": SmbNonBrowsableDisabled, + "enabled": SmbNonBrowsableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SmbNonBrowsable(input) + return &out, nil +} + +type VolumeStorageToNetworkProximity string + +const ( + VolumeStorageToNetworkProximityAcrossTTwo VolumeStorageToNetworkProximity = "AcrossT2" + VolumeStorageToNetworkProximityDefault VolumeStorageToNetworkProximity = "Default" + VolumeStorageToNetworkProximityTOne VolumeStorageToNetworkProximity = "T1" + VolumeStorageToNetworkProximityTTwo VolumeStorageToNetworkProximity = "T2" +) + +func PossibleValuesForVolumeStorageToNetworkProximity() []string { + return []string{ + string(VolumeStorageToNetworkProximityAcrossTTwo), + string(VolumeStorageToNetworkProximityDefault), + string(VolumeStorageToNetworkProximityTOne), + string(VolumeStorageToNetworkProximityTTwo), + } +} + +func (s *VolumeStorageToNetworkProximity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeStorageToNetworkProximity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeStorageToNetworkProximity(input string) (*VolumeStorageToNetworkProximity, error) { + vals := map[string]VolumeStorageToNetworkProximity{ + "acrosst2": VolumeStorageToNetworkProximityAcrossTTwo, + "default": VolumeStorageToNetworkProximityDefault, + "t1": VolumeStorageToNetworkProximityTOne, + "t2": VolumeStorageToNetworkProximityTTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeStorageToNetworkProximity(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumes/id_capacitypool.go b/resource-manager/netapp/2024-07-01/volumes/id_capacitypool.go new file mode 100644 index 00000000000..4a5cb95b3e2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/id_capacitypool.go @@ -0,0 +1,139 @@ +package volumes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CapacityPoolId{}) +} + +var _ resourceids.ResourceId = &CapacityPoolId{} + +// CapacityPoolId is a struct representing the Resource ID for a Capacity Pool +type CapacityPoolId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string +} + +// NewCapacityPoolID returns a new CapacityPoolId struct +func NewCapacityPoolID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string) CapacityPoolId { + return CapacityPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + } +} + +// ParseCapacityPoolID parses 'input' into a CapacityPoolId +func ParseCapacityPoolID(input string) (*CapacityPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCapacityPoolIDInsensitively parses 'input' case-insensitively into a CapacityPoolId +// note: this method should only be used for API response data and not user input +func ParseCapacityPoolIDInsensitively(input string) (*CapacityPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&CapacityPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CapacityPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CapacityPoolId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + return nil +} + +// ValidateCapacityPoolID checks that 'input' can be parsed as a Capacity Pool ID +func ValidateCapacityPoolID(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 := ParseCapacityPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Capacity Pool ID +func (id CapacityPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Capacity Pool ID +func (id CapacityPoolId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + } +} + +// String returns a human-readable description of this Capacity Pool ID +func (id CapacityPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + } + return fmt.Sprintf("Capacity Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumes/id_capacitypool_test.go b/resource-manager/netapp/2024-07-01/volumes/id_capacitypool_test.go new file mode 100644 index 00000000000..c84c57d8196 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/id_capacitypool_test.go @@ -0,0 +1,327 @@ +package volumes + +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 = &CapacityPoolId{} + +func TestNewCapacityPoolID(t *testing.T) { + id := NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } +} + +func TestFormatCapacityPoolID(t *testing.T) { + actual := NewCapacityPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCapacityPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityPoolId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityPoolID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + } +} + +func TestParseCapacityPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CapacityPoolId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Expected: &CapacityPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCapacityPoolIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + } +} + +func TestSegmentsForCapacityPoolId(t *testing.T) { + segments := CapacityPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CapacityPoolId 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/netapp/2024-07-01/volumes/id_volume.go b/resource-manager/netapp/2024-07-01/volumes/id_volume.go new file mode 100644 index 00000000000..9335df28621 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/id_volume.go @@ -0,0 +1,148 @@ +package volumes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumes/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumes/id_volume_test.go new file mode 100644 index 00000000000..a08cc9318a1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/id_volume_test.go @@ -0,0 +1,372 @@ +package volumes + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumes/method_createorupdate.go b/resource-manager/netapp/2024-07-01/volumes/method_createorupdate.go new file mode 100644 index 00000000000..fe291f378c8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_createorupdate.go @@ -0,0 +1,76 @@ +package volumes + +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 + Model *Volume +} + +// CreateOrUpdate ... +func (c VolumesClient) CreateOrUpdate(ctx context.Context, id VolumeId, input Volume) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 VolumesClient) CreateOrUpdateThenPoll(ctx context.Context, id VolumeId, input Volume) 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/netapp/2024-07-01/volumes/method_delete.go b/resource-manager/netapp/2024-07-01/volumes/method_delete.go new file mode 100644 index 00000000000..c449fa7d2b8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_delete.go @@ -0,0 +1,99 @@ +package volumes + +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 +} + +type DeleteOperationOptions struct { + ForceDelete *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDelete != nil { + out.Append("forceDelete", fmt.Sprintf("%v", *o.ForceDelete)) + } + return &out +} + +// Delete ... +func (c VolumesClient) Delete(ctx context.Context, id VolumeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 VolumesClient) DeleteThenPoll(ctx context.Context, id VolumeId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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/netapp/2024-07-01/volumes/method_get.go b/resource-manager/netapp/2024-07-01/volumes/method_get.go new file mode 100644 index 00000000000..1f99d951818 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_get.go @@ -0,0 +1,53 @@ +package volumes + +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 *Volume +} + +// Get ... +func (c VolumesClient) Get(ctx context.Context, id VolumeId) (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 + } + + var model Volume + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumes/method_list.go b/resource-manager/netapp/2024-07-01/volumes/method_list.go new file mode 100644 index 00000000000..443ce94a02d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_list.go @@ -0,0 +1,105 @@ +package volumes + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Volume +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Volume +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VolumesClient) List(ctx context.Context, id CapacityPoolId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/volumes", 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 *[]Volume `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 VolumesClient) ListComplete(ctx context.Context, id CapacityPoolId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VolumeOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VolumesClient) ListCompleteMatchingPredicate(ctx context.Context, id CapacityPoolId, predicate VolumeOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Volume, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/netapp/2024-07-01/volumes/method_populateavailabilityzone.go b/resource-manager/netapp/2024-07-01/volumes/method_populateavailabilityzone.go new file mode 100644 index 00000000000..052b13f3fd6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_populateavailabilityzone.go @@ -0,0 +1,71 @@ +package volumes + +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 PopulateAvailabilityZoneOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Volume +} + +// PopulateAvailabilityZone ... +func (c VolumesClient) PopulateAvailabilityZone(ctx context.Context, id VolumeId) (result PopulateAvailabilityZoneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/populateAvailabilityZone", 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 +} + +// PopulateAvailabilityZoneThenPoll performs PopulateAvailabilityZone then polls until it's completed +func (c VolumesClient) PopulateAvailabilityZoneThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.PopulateAvailabilityZone(ctx, id) + if err != nil { + return fmt.Errorf("performing PopulateAvailabilityZone: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PopulateAvailabilityZone: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumes/method_update.go b/resource-manager/netapp/2024-07-01/volumes/method_update.go new file mode 100644 index 00000000000..8a9aedb619c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/method_update.go @@ -0,0 +1,75 @@ +package volumes + +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 + Model *Volume +} + +// Update ... +func (c VolumesClient) Update(ctx context.Context, id VolumeId, input VolumePatch) (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 VolumesClient) UpdateThenPoll(ctx context.Context, id VolumeId, input VolumePatch) 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/netapp/2024-07-01/volumes/model_exportpolicyrule.go b/resource-manager/netapp/2024-07-01/volumes/model_exportpolicyrule.go new file mode 100644 index 00000000000..9b059c74757 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_exportpolicyrule.go @@ -0,0 +1,22 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportPolicyRule struct { + AllowedClients *string `json:"allowedClients,omitempty"` + ChownMode *ChownMode `json:"chownMode,omitempty"` + Cifs *bool `json:"cifs,omitempty"` + HasRootAccess *bool `json:"hasRootAccess,omitempty"` + Kerberos5ReadOnly *bool `json:"kerberos5ReadOnly,omitempty"` + Kerberos5ReadWrite *bool `json:"kerberos5ReadWrite,omitempty"` + Kerberos5iReadOnly *bool `json:"kerberos5iReadOnly,omitempty"` + Kerberos5iReadWrite *bool `json:"kerberos5iReadWrite,omitempty"` + Kerberos5pReadOnly *bool `json:"kerberos5pReadOnly,omitempty"` + Kerberos5pReadWrite *bool `json:"kerberos5pReadWrite,omitempty"` + Nfsv3 *bool `json:"nfsv3,omitempty"` + Nfsv41 *bool `json:"nfsv41,omitempty"` + RuleIndex *int64 `json:"ruleIndex,omitempty"` + UnixReadOnly *bool `json:"unixReadOnly,omitempty"` + UnixReadWrite *bool `json:"unixReadWrite,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_mounttargetproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_mounttargetproperties.go new file mode 100644 index 00000000000..7f5c238183c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_mounttargetproperties.go @@ -0,0 +1,11 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MountTargetProperties struct { + FileSystemId string `json:"fileSystemId"` + IPAddress *string `json:"ipAddress,omitempty"` + MountTargetId *string `json:"mountTargetId,omitempty"` + SmbServerFqdn *string `json:"smbServerFqdn,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_placementkeyvaluepairs.go b/resource-manager/netapp/2024-07-01/volumes/model_placementkeyvaluepairs.go new file mode 100644 index 00000000000..588e9729c1e --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_placementkeyvaluepairs.go @@ -0,0 +1,9 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlacementKeyValuePairs struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_remotepath.go b/resource-manager/netapp/2024-07-01/volumes/model_remotepath.go new file mode 100644 index 00000000000..b283879aae7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_remotepath.go @@ -0,0 +1,10 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePath struct { + ExternalHostName string `json:"externalHostName"` + ServerName string `json:"serverName"` + VolumeName string `json:"volumeName"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_replicationobject.go b/resource-manager/netapp/2024-07-01/volumes/model_replicationobject.go new file mode 100644 index 00000000000..724f0c50bd0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_replicationobject.go @@ -0,0 +1,13 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationObject struct { + EndpointType *EndpointType `json:"endpointType,omitempty"` + RemotePath *RemotePath `json:"remotePath,omitempty"` + RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` + RemoteVolumeResourceId string `json:"remoteVolumeResourceId"` + ReplicationId *string `json:"replicationId,omitempty"` + ReplicationSchedule *ReplicationSchedule `json:"replicationSchedule,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volume.go b/resource-manager/netapp/2024-07-01/volumes/model_volume.go new file mode 100644 index 00000000000..1679818444b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volume.go @@ -0,0 +1,21 @@ +package volumes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties VolumeProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumebackupproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_volumebackupproperties.go new file mode 100644 index 00000000000..a74e6fd4d16 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumebackupproperties.go @@ -0,0 +1,10 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeBackupProperties struct { + BackupPolicyId *string `json:"backupPolicyId,omitempty"` + BackupVaultId *string `json:"backupVaultId,omitempty"` + PolicyEnforced *bool `json:"policyEnforced,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepatch.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepatch.go new file mode 100644 index 00000000000..b39ea01aee8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepatch.go @@ -0,0 +1,13 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePatch struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VolumePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepatchproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchproperties.go new file mode 100644 index 00000000000..716cd8f9697 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchproperties.go @@ -0,0 +1,23 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePatchProperties struct { + CoolAccess *bool `json:"coolAccess,omitempty"` + CoolAccessRetrievalPolicy *CoolAccessRetrievalPolicy `json:"coolAccessRetrievalPolicy,omitempty"` + CoolnessPeriod *int64 `json:"coolnessPeriod,omitempty"` + DataProtection *VolumePatchPropertiesDataProtection `json:"dataProtection,omitempty"` + DefaultGroupQuotaInKiBs *int64 `json:"defaultGroupQuotaInKiBs,omitempty"` + DefaultUserQuotaInKiBs *int64 `json:"defaultUserQuotaInKiBs,omitempty"` + ExportPolicy *VolumePatchPropertiesExportPolicy `json:"exportPolicy,omitempty"` + IsDefaultQuotaEnabled *bool `json:"isDefaultQuotaEnabled,omitempty"` + ProtocolTypes *[]string `json:"protocolTypes,omitempty"` + ServiceLevel *ServiceLevel `json:"serviceLevel,omitempty"` + SmbAccessBasedEnumeration *SmbAccessBasedEnumeration `json:"smbAccessBasedEnumeration,omitempty"` + SmbNonBrowsable *SmbNonBrowsable `json:"smbNonBrowsable,omitempty"` + SnapshotDirectoryVisible *bool `json:"snapshotDirectoryVisible,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` + UnixPermissions *string `json:"unixPermissions,omitempty"` + UsageThreshold *int64 `json:"usageThreshold,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesdataprotection.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesdataprotection.go new file mode 100644 index 00000000000..8c9edc10ff7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesdataprotection.go @@ -0,0 +1,9 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePatchPropertiesDataProtection struct { + Backup *VolumeBackupProperties `json:"backup,omitempty"` + Snapshot *VolumeSnapshotProperties `json:"snapshot,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesexportpolicy.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesexportpolicy.go new file mode 100644 index 00000000000..ae83a5fc1b4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepatchpropertiesexportpolicy.go @@ -0,0 +1,8 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePatchPropertiesExportPolicy struct { + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumeproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_volumeproperties.go new file mode 100644 index 00000000000..fc55e2acdae --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumeproperties.go @@ -0,0 +1,62 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeProperties struct { + ActualThroughputMibps *float64 `json:"actualThroughputMibps,omitempty"` + AvsDataStore *AvsDataStore `json:"avsDataStore,omitempty"` + BackupId *string `json:"backupId,omitempty"` + BaremetalTenantId *string `json:"baremetalTenantId,omitempty"` + CapacityPoolResourceId *string `json:"capacityPoolResourceId,omitempty"` + CloneProgress *int64 `json:"cloneProgress,omitempty"` + CoolAccess *bool `json:"coolAccess,omitempty"` + CoolAccessRetrievalPolicy *CoolAccessRetrievalPolicy `json:"coolAccessRetrievalPolicy,omitempty"` + CoolnessPeriod *int64 `json:"coolnessPeriod,omitempty"` + CreationToken string `json:"creationToken"` + DataProtection *VolumePropertiesDataProtection `json:"dataProtection,omitempty"` + DataStoreResourceId *[]string `json:"dataStoreResourceId,omitempty"` + DefaultGroupQuotaInKiBs *int64 `json:"defaultGroupQuotaInKiBs,omitempty"` + DefaultUserQuotaInKiBs *int64 `json:"defaultUserQuotaInKiBs,omitempty"` + DeleteBaseSnapshot *bool `json:"deleteBaseSnapshot,omitempty"` + EffectiveNetworkFeatures *NetworkFeatures `json:"effectiveNetworkFeatures,omitempty"` + EnableSubvolumes *EnableSubvolumes `json:"enableSubvolumes,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` + EncryptionKeySource *EncryptionKeySource `json:"encryptionKeySource,omitempty"` + ExportPolicy *VolumePropertiesExportPolicy `json:"exportPolicy,omitempty"` + FileAccessLogs *FileAccessLogs `json:"fileAccessLogs,omitempty"` + FileSystemId *string `json:"fileSystemId,omitempty"` + IsDefaultQuotaEnabled *bool `json:"isDefaultQuotaEnabled,omitempty"` + IsLargeVolume *bool `json:"isLargeVolume,omitempty"` + IsRestoring *bool `json:"isRestoring,omitempty"` + KerberosEnabled *bool `json:"kerberosEnabled,omitempty"` + KeyVaultPrivateEndpointResourceId *string `json:"keyVaultPrivateEndpointResourceId,omitempty"` + LdapEnabled *bool `json:"ldapEnabled,omitempty"` + MaximumNumberOfFiles *int64 `json:"maximumNumberOfFiles,omitempty"` + MountTargets *[]MountTargetProperties `json:"mountTargets,omitempty"` + NetworkFeatures *NetworkFeatures `json:"networkFeatures,omitempty"` + NetworkSiblingSetId *string `json:"networkSiblingSetId,omitempty"` + OriginatingResourceId *string `json:"originatingResourceId,omitempty"` + PlacementRules *[]PlacementKeyValuePairs `json:"placementRules,omitempty"` + ProtocolTypes *[]string `json:"protocolTypes,omitempty"` + ProvisionedAvailabilityZone *string `json:"provisionedAvailabilityZone,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroup *string `json:"proximityPlacementGroup,omitempty"` + SecurityStyle *SecurityStyle `json:"securityStyle,omitempty"` + ServiceLevel *ServiceLevel `json:"serviceLevel,omitempty"` + SmbAccessBasedEnumeration *SmbAccessBasedEnumeration `json:"smbAccessBasedEnumeration,omitempty"` + SmbContinuouslyAvailable *bool `json:"smbContinuouslyAvailable,omitempty"` + SmbEncryption *bool `json:"smbEncryption,omitempty"` + SmbNonBrowsable *SmbNonBrowsable `json:"smbNonBrowsable,omitempty"` + SnapshotDirectoryVisible *bool `json:"snapshotDirectoryVisible,omitempty"` + SnapshotId *string `json:"snapshotId,omitempty"` + StorageToNetworkProximity *VolumeStorageToNetworkProximity `json:"storageToNetworkProximity,omitempty"` + SubnetId string `json:"subnetId"` + T2Network *string `json:"t2Network,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` + UnixPermissions *string `json:"unixPermissions,omitempty"` + UsageThreshold int64 `json:"usageThreshold"` + VolumeGroupName *string `json:"volumeGroupName,omitempty"` + VolumeSpecName *string `json:"volumeSpecName,omitempty"` + VolumeType *string `json:"volumeType,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesdataprotection.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesdataprotection.go new file mode 100644 index 00000000000..fcf952952d2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesdataprotection.go @@ -0,0 +1,11 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesDataProtection struct { + Backup *VolumeBackupProperties `json:"backup,omitempty"` + Replication *ReplicationObject `json:"replication,omitempty"` + Snapshot *VolumeSnapshotProperties `json:"snapshot,omitempty"` + VolumeRelocation *VolumeRelocationProperties `json:"volumeRelocation,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesexportpolicy.go b/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesexportpolicy.go new file mode 100644 index 00000000000..fda5f4739de --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumepropertiesexportpolicy.go @@ -0,0 +1,8 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePropertiesExportPolicy struct { + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumerelocationproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_volumerelocationproperties.go new file mode 100644 index 00000000000..23274832779 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumerelocationproperties.go @@ -0,0 +1,9 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeRelocationProperties struct { + ReadyToBeFinalized *bool `json:"readyToBeFinalized,omitempty"` + RelocationRequested *bool `json:"relocationRequested,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/model_volumesnapshotproperties.go b/resource-manager/netapp/2024-07-01/volumes/model_volumesnapshotproperties.go new file mode 100644 index 00000000000..48aba2acce0 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/model_volumesnapshotproperties.go @@ -0,0 +1,8 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeSnapshotProperties struct { + SnapshotPolicyId *string `json:"snapshotPolicyId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumes/predicates.go b/resource-manager/netapp/2024-07-01/volumes/predicates.go new file mode 100644 index 00000000000..fcc54ae5e26 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/predicates.go @@ -0,0 +1,37 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VolumeOperationPredicate) Matches(input Volume) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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/netapp/2024-07-01/volumes/version.go b/resource-manager/netapp/2024-07-01/volumes/version.go new file mode 100644 index 00000000000..c68a0c805ad --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumes/version.go @@ -0,0 +1,10 @@ +package volumes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumes/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/README.md b/resource-manager/netapp/2024-07-01/volumesonpremmigration/README.md new file mode 100644 index 00000000000..453e8975f47 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/README.md @@ -0,0 +1,61 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesonpremmigration` Documentation + +The `volumesonpremmigration` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumesonpremmigration" +``` + + +### Client Initialization + +```go +client := volumesonpremmigration.NewVolumesOnPremMigrationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumesOnPremMigrationClient.VolumesAuthorizeExternalReplication` + +```go +ctx := context.TODO() +id := volumesonpremmigration.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesAuthorizeExternalReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesOnPremMigrationClient.VolumesPeerExternalCluster` + +```go +ctx := context.TODO() +id := volumesonpremmigration.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesonpremmigration.PeerClusterForVolumeMigrationRequest{ + // ... +} + + +if err := client.VolumesPeerExternalClusterThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesOnPremMigrationClient.VolumesPerformReplicationTransfer` + +```go +ctx := context.TODO() +id := volumesonpremmigration.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesPerformReplicationTransferThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/client.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/client.go new file mode 100644 index 00000000000..b858bb952cd --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/client.go @@ -0,0 +1,26 @@ +package volumesonpremmigration + +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 VolumesOnPremMigrationClient struct { + Client *resourcemanager.Client +} + +func NewVolumesOnPremMigrationClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesOnPremMigrationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumesonpremmigration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesOnPremMigrationClient: %+v", err) + } + + return &VolumesOnPremMigrationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume.go new file mode 100644 index 00000000000..6dcc938a6b7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume.go @@ -0,0 +1,148 @@ +package volumesonpremmigration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume_test.go new file mode 100644 index 00000000000..7222936b0d8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/id_volume_test.go @@ -0,0 +1,372 @@ +package volumesonpremmigration + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumesonpremmigration/method_volumesauthorizeexternalreplication.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumesauthorizeexternalreplication.go new file mode 100644 index 00000000000..45c0de7126f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumesauthorizeexternalreplication.go @@ -0,0 +1,71 @@ +package volumesonpremmigration + +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 VolumesAuthorizeExternalReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SVMPeerCommandResponse +} + +// VolumesAuthorizeExternalReplication ... +func (c VolumesOnPremMigrationClient) VolumesAuthorizeExternalReplication(ctx context.Context, id VolumeId) (result VolumesAuthorizeExternalReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/authorizeExternalReplication", 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 +} + +// VolumesAuthorizeExternalReplicationThenPoll performs VolumesAuthorizeExternalReplication then polls until it's completed +func (c VolumesOnPremMigrationClient) VolumesAuthorizeExternalReplicationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesAuthorizeExternalReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesAuthorizeExternalReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesAuthorizeExternalReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumespeerexternalcluster.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumespeerexternalcluster.go new file mode 100644 index 00000000000..e92a82727bf --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumespeerexternalcluster.go @@ -0,0 +1,75 @@ +package volumesonpremmigration + +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 VolumesPeerExternalClusterOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterPeerCommandResponse +} + +// VolumesPeerExternalCluster ... +func (c VolumesOnPremMigrationClient) VolumesPeerExternalCluster(ctx context.Context, id VolumeId, input PeerClusterForVolumeMigrationRequest) (result VolumesPeerExternalClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/peerExternalCluster", 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 +} + +// VolumesPeerExternalClusterThenPoll performs VolumesPeerExternalCluster then polls until it's completed +func (c VolumesOnPremMigrationClient) VolumesPeerExternalClusterThenPoll(ctx context.Context, id VolumeId, input PeerClusterForVolumeMigrationRequest) error { + result, err := c.VolumesPeerExternalCluster(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesPeerExternalCluster: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesPeerExternalCluster: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumesperformreplicationtransfer.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumesperformreplicationtransfer.go new file mode 100644 index 00000000000..0ba727cd4ac --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/method_volumesperformreplicationtransfer.go @@ -0,0 +1,69 @@ +package volumesonpremmigration + +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 VolumesPerformReplicationTransferOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesPerformReplicationTransfer ... +func (c VolumesOnPremMigrationClient) VolumesPerformReplicationTransfer(ctx context.Context, id VolumeId) (result VolumesPerformReplicationTransferOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/performReplicationTransfer", 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 +} + +// VolumesPerformReplicationTransferThenPoll performs VolumesPerformReplicationTransfer then polls until it's completed +func (c VolumesOnPremMigrationClient) VolumesPerformReplicationTransferThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesPerformReplicationTransfer(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesPerformReplicationTransfer: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesPerformReplicationTransfer: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_clusterpeercommandresponse.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_clusterpeercommandresponse.go new file mode 100644 index 00000000000..2f146170417 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_clusterpeercommandresponse.go @@ -0,0 +1,8 @@ +package volumesonpremmigration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPeerCommandResponse struct { + PeerAcceptCommand *string `json:"peerAcceptCommand,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_peerclusterforvolumemigrationrequest.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_peerclusterforvolumemigrationrequest.go new file mode 100644 index 00000000000..fe63a83424c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_peerclusterforvolumemigrationrequest.go @@ -0,0 +1,8 @@ +package volumesonpremmigration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerClusterForVolumeMigrationRequest struct { + PeerIPAddresses []string `json:"peerIpAddresses"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_svmpeercommandresponse.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_svmpeercommandresponse.go new file mode 100644 index 00000000000..1578dcb9dcc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/model_svmpeercommandresponse.go @@ -0,0 +1,8 @@ +package volumesonpremmigration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SVMPeerCommandResponse struct { + SVMPeeringCommand *string `json:"svmPeeringCommand,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigration/version.go b/resource-manager/netapp/2024-07-01/volumesonpremmigration/version.go new file mode 100644 index 00000000000..1e0784861f2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigration/version.go @@ -0,0 +1,10 @@ +package volumesonpremmigration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumesonpremmigration/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/client.go b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/client.go new file mode 100644 index 00000000000..2b54b0579fc --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/client.go @@ -0,0 +1,26 @@ +package volumesonpremmigrationfinalize + +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 VolumesOnPremMigrationFinalizeClient struct { + Client *resourcemanager.Client +} + +func NewVolumesOnPremMigrationFinalizeClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesOnPremMigrationFinalizeClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumesonpremmigrationfinalize", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesOnPremMigrationFinalizeClient: %+v", err) + } + + return &VolumesOnPremMigrationFinalizeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume.go b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume.go new file mode 100644 index 00000000000..1edbc85826f --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume.go @@ -0,0 +1,148 @@ +package volumesonpremmigrationfinalize + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume_test.go new file mode 100644 index 00000000000..a0362282f55 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/id_volume_test.go @@ -0,0 +1,372 @@ +package volumesonpremmigrationfinalize + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumesonpremmigrationfinalize/method_volumesfinalizeexternalreplication.go b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/method_volumesfinalizeexternalreplication.go new file mode 100644 index 00000000000..9f8b478e476 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/method_volumesfinalizeexternalreplication.go @@ -0,0 +1,69 @@ +package volumesonpremmigrationfinalize + +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 VolumesFinalizeExternalReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesFinalizeExternalReplication ... +func (c VolumesOnPremMigrationFinalizeClient) VolumesFinalizeExternalReplication(ctx context.Context, id VolumeId) (result VolumesFinalizeExternalReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/finalizeExternalReplication", 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 +} + +// VolumesFinalizeExternalReplicationThenPoll performs VolumesFinalizeExternalReplication then polls until it's completed +func (c VolumesOnPremMigrationFinalizeClient) VolumesFinalizeExternalReplicationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesFinalizeExternalReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesFinalizeExternalReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesFinalizeExternalReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/version.go b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/version.go new file mode 100644 index 00000000000..4eef82722ed --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesonpremmigrationfinalize/version.go @@ -0,0 +1,10 @@ +package volumesonpremmigrationfinalize + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumesonpremmigrationfinalize/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/README.md b/resource-manager/netapp/2024-07-01/volumesrelocation/README.md new file mode 100644 index 00000000000..bfee2d8766b --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/README.md @@ -0,0 +1,61 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesrelocation` Documentation + +The `volumesrelocation` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumesrelocation" +``` + + +### Client Initialization + +```go +client := volumesrelocation.NewVolumesRelocationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumesRelocationClient.VolumesFinalizeRelocation` + +```go +ctx := context.TODO() +id := volumesrelocation.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesFinalizeRelocationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesRelocationClient.VolumesRelocate` + +```go +ctx := context.TODO() +id := volumesrelocation.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesrelocation.RelocateVolumeRequest{ + // ... +} + + +if err := client.VolumesRelocateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesRelocationClient.VolumesRevertRelocation` + +```go +ctx := context.TODO() +id := volumesrelocation.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesRevertRelocationThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/client.go b/resource-manager/netapp/2024-07-01/volumesrelocation/client.go new file mode 100644 index 00000000000..468673aa176 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/client.go @@ -0,0 +1,26 @@ +package volumesrelocation + +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 VolumesRelocationClient struct { + Client *resourcemanager.Client +} + +func NewVolumesRelocationClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesRelocationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumesrelocation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesRelocationClient: %+v", err) + } + + return &VolumesRelocationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume.go b/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume.go new file mode 100644 index 00000000000..113162da6d7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume.go @@ -0,0 +1,148 @@ +package volumesrelocation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume_test.go new file mode 100644 index 00000000000..6a87e3c4d06 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/id_volume_test.go @@ -0,0 +1,372 @@ +package volumesrelocation + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumesrelocation/method_volumesfinalizerelocation.go b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesfinalizerelocation.go new file mode 100644 index 00000000000..8bc1cc1b39a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesfinalizerelocation.go @@ -0,0 +1,70 @@ +package volumesrelocation + +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 VolumesFinalizeRelocationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesFinalizeRelocation ... +func (c VolumesRelocationClient) VolumesFinalizeRelocation(ctx context.Context, id VolumeId) (result VolumesFinalizeRelocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/finalizeRelocation", 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 +} + +// VolumesFinalizeRelocationThenPoll performs VolumesFinalizeRelocation then polls until it's completed +func (c VolumesRelocationClient) VolumesFinalizeRelocationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesFinalizeRelocation(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesFinalizeRelocation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesFinalizeRelocation: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrelocate.go b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrelocate.go new file mode 100644 index 00000000000..1207d489ed4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrelocate.go @@ -0,0 +1,74 @@ +package volumesrelocation + +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 VolumesRelocateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesRelocate ... +func (c VolumesRelocationClient) VolumesRelocate(ctx context.Context, id VolumeId, input RelocateVolumeRequest) (result VolumesRelocateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/relocate", 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 +} + +// VolumesRelocateThenPoll performs VolumesRelocate then polls until it's completed +func (c VolumesRelocationClient) VolumesRelocateThenPoll(ctx context.Context, id VolumeId, input RelocateVolumeRequest) error { + result, err := c.VolumesRelocate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesRelocate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesRelocate: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrevertrelocation.go b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrevertrelocation.go new file mode 100644 index 00000000000..0091b1304fd --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/method_volumesrevertrelocation.go @@ -0,0 +1,70 @@ +package volumesrelocation + +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 VolumesRevertRelocationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesRevertRelocation ... +func (c VolumesRelocationClient) VolumesRevertRelocation(ctx context.Context, id VolumeId) (result VolumesRevertRelocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/revertRelocation", 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 +} + +// VolumesRevertRelocationThenPoll performs VolumesRevertRelocation then polls until it's completed +func (c VolumesRelocationClient) VolumesRevertRelocationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesRevertRelocation(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesRevertRelocation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesRevertRelocation: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/model_relocatevolumerequest.go b/resource-manager/netapp/2024-07-01/volumesrelocation/model_relocatevolumerequest.go new file mode 100644 index 00000000000..25cb3a56801 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/model_relocatevolumerequest.go @@ -0,0 +1,8 @@ +package volumesrelocation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelocateVolumeRequest struct { + CreationToken *string `json:"creationToken,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesrelocation/version.go b/resource-manager/netapp/2024-07-01/volumesrelocation/version.go new file mode 100644 index 00000000000..0f8af60fc59 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrelocation/version.go @@ -0,0 +1,10 @@ +package volumesrelocation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumesrelocation/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/README.md b/resource-manager/netapp/2024-07-01/volumesreplication/README.md new file mode 100644 index 00000000000..a2b07a63bbd --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/README.md @@ -0,0 +1,139 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesreplication` Documentation + +The `volumesreplication` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumesreplication" +``` + + +### Client Initialization + +```go +client := volumesreplication.NewVolumesReplicationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumesReplicationClient.VolumesAuthorizeReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesreplication.AuthorizeRequest{ + // ... +} + + +if err := client.VolumesAuthorizeReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesBreakReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesreplication.BreakReplicationRequest{ + // ... +} + + +if err := client.VolumesBreakReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesDeleteReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesDeleteReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesListReplications` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.VolumesListReplications(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesReInitializeReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesReInitializeReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesReestablishReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesreplication.ReestablishReplicationRequest{ + // ... +} + + +if err := client.VolumesReestablishReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesReplicationStatus` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +read, err := client.VolumesReplicationStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VolumesReplicationClient.VolumesResyncReplication` + +```go +ctx := context.TODO() +id := volumesreplication.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +if err := client.VolumesResyncReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/client.go b/resource-manager/netapp/2024-07-01/volumesreplication/client.go new file mode 100644 index 00000000000..092e04c0a0d --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/client.go @@ -0,0 +1,26 @@ +package volumesreplication + +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 VolumesReplicationClient struct { + Client *resourcemanager.Client +} + +func NewVolumesReplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesReplicationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumesreplication", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesReplicationClient: %+v", err) + } + + return &VolumesReplicationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/constants.go b/resource-manager/netapp/2024-07-01/volumesreplication/constants.go new file mode 100644 index 00000000000..2e5196391b7 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/constants.go @@ -0,0 +1,180 @@ +package volumesreplication + +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 EndpointType string + +const ( + EndpointTypeDst EndpointType = "dst" + EndpointTypeSrc EndpointType = "src" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeDst), + string(EndpointTypeSrc), + } +} + +func (s *EndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "dst": EndpointTypeDst, + "src": EndpointTypeSrc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type MirrorState string + +const ( + MirrorStateBroken MirrorState = "Broken" + MirrorStateMirrored MirrorState = "Mirrored" + MirrorStateUninitialized MirrorState = "Uninitialized" +) + +func PossibleValuesForMirrorState() []string { + return []string{ + string(MirrorStateBroken), + string(MirrorStateMirrored), + string(MirrorStateUninitialized), + } +} + +func (s *MirrorState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMirrorState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMirrorState(input string) (*MirrorState, error) { + vals := map[string]MirrorState{ + "broken": MirrorStateBroken, + "mirrored": MirrorStateMirrored, + "uninitialized": MirrorStateUninitialized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MirrorState(input) + return &out, nil +} + +type RelationshipStatus string + +const ( + RelationshipStatusIdle RelationshipStatus = "Idle" + RelationshipStatusTransferring RelationshipStatus = "Transferring" +) + +func PossibleValuesForRelationshipStatus() []string { + return []string{ + string(RelationshipStatusIdle), + string(RelationshipStatusTransferring), + } +} + +func (s *RelationshipStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelationshipStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRelationshipStatus(input string) (*RelationshipStatus, error) { + vals := map[string]RelationshipStatus{ + "idle": RelationshipStatusIdle, + "transferring": RelationshipStatusTransferring, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RelationshipStatus(input) + return &out, nil +} + +type ReplicationSchedule string + +const ( + ReplicationScheduleDaily ReplicationSchedule = "daily" + ReplicationScheduleHourly ReplicationSchedule = "hourly" + ReplicationScheduleOneZerominutely ReplicationSchedule = "_10minutely" +) + +func PossibleValuesForReplicationSchedule() []string { + return []string{ + string(ReplicationScheduleDaily), + string(ReplicationScheduleHourly), + string(ReplicationScheduleOneZerominutely), + } +} + +func (s *ReplicationSchedule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationSchedule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationSchedule(input string) (*ReplicationSchedule, error) { + vals := map[string]ReplicationSchedule{ + "daily": ReplicationScheduleDaily, + "hourly": ReplicationScheduleHourly, + "_10minutely": ReplicationScheduleOneZerominutely, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationSchedule(input) + return &out, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/id_volume.go b/resource-manager/netapp/2024-07-01/volumesreplication/id_volume.go new file mode 100644 index 00000000000..f4997248ba1 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/id_volume.go @@ -0,0 +1,148 @@ +package volumesreplication + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumesreplication/id_volume_test.go new file mode 100644 index 00000000000..51db68a7df6 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/id_volume_test.go @@ -0,0 +1,372 @@ +package volumesreplication + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumesreplication/method_volumesauthorizereplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesauthorizereplication.go new file mode 100644 index 00000000000..591d7c626ab --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesauthorizereplication.go @@ -0,0 +1,74 @@ +package volumesreplication + +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 VolumesAuthorizeReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesAuthorizeReplication ... +func (c VolumesReplicationClient) VolumesAuthorizeReplication(ctx context.Context, id VolumeId, input AuthorizeRequest) (result VolumesAuthorizeReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/authorizeReplication", 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 +} + +// VolumesAuthorizeReplicationThenPoll performs VolumesAuthorizeReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesAuthorizeReplicationThenPoll(ctx context.Context, id VolumeId, input AuthorizeRequest) error { + result, err := c.VolumesAuthorizeReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesAuthorizeReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesAuthorizeReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesbreakreplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesbreakreplication.go new file mode 100644 index 00000000000..280008e8175 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesbreakreplication.go @@ -0,0 +1,74 @@ +package volumesreplication + +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 VolumesBreakReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesBreakReplication ... +func (c VolumesReplicationClient) VolumesBreakReplication(ctx context.Context, id VolumeId, input BreakReplicationRequest) (result VolumesBreakReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/breakReplication", 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 +} + +// VolumesBreakReplicationThenPoll performs VolumesBreakReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesBreakReplicationThenPoll(ctx context.Context, id VolumeId, input BreakReplicationRequest) error { + result, err := c.VolumesBreakReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesBreakReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesBreakReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesdeletereplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesdeletereplication.go new file mode 100644 index 00000000000..cda9737c512 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesdeletereplication.go @@ -0,0 +1,70 @@ +package volumesreplication + +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 VolumesDeleteReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesDeleteReplication ... +func (c VolumesReplicationClient) VolumesDeleteReplication(ctx context.Context, id VolumeId) (result VolumesDeleteReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteReplication", 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 +} + +// VolumesDeleteReplicationThenPoll performs VolumesDeleteReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesDeleteReplicationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesDeleteReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesDeleteReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesDeleteReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumeslistreplications.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumeslistreplications.go new file mode 100644 index 00000000000..bed3dfeb672 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumeslistreplications.go @@ -0,0 +1,54 @@ +package volumesreplication + +import ( + "context" + "fmt" + "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 VolumesListReplicationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListReplications +} + +// VolumesListReplications ... +func (c VolumesReplicationClient) VolumesListReplications(ctx context.Context, id VolumeId) (result VolumesListReplicationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listReplications", 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 + } + + var model ListReplications + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreestablishreplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreestablishreplication.go new file mode 100644 index 00000000000..047fc04a7f9 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreestablishreplication.go @@ -0,0 +1,73 @@ +package volumesreplication + +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 VolumesReestablishReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesReestablishReplication ... +func (c VolumesReplicationClient) VolumesReestablishReplication(ctx context.Context, id VolumeId, input ReestablishReplicationRequest) (result VolumesReestablishReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reestablishReplication", 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 +} + +// VolumesReestablishReplicationThenPoll performs VolumesReestablishReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesReestablishReplicationThenPoll(ctx context.Context, id VolumeId, input ReestablishReplicationRequest) error { + result, err := c.VolumesReestablishReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesReestablishReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesReestablishReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreinitializereplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreinitializereplication.go new file mode 100644 index 00000000000..3f479bf637a --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreinitializereplication.go @@ -0,0 +1,70 @@ +package volumesreplication + +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 VolumesReInitializeReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesReInitializeReplication ... +func (c VolumesReplicationClient) VolumesReInitializeReplication(ctx context.Context, id VolumeId) (result VolumesReInitializeReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reinitializeReplication", 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 +} + +// VolumesReInitializeReplicationThenPoll performs VolumesReInitializeReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesReInitializeReplicationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesReInitializeReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesReInitializeReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesReInitializeReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreplicationstatus.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreplicationstatus.go new file mode 100644 index 00000000000..2f626c60847 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesreplicationstatus.go @@ -0,0 +1,54 @@ +package volumesreplication + +import ( + "context" + "fmt" + "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 VolumesReplicationStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationStatus +} + +// VolumesReplicationStatus ... +func (c VolumesReplicationClient) VolumesReplicationStatus(ctx context.Context, id VolumeId) (result VolumesReplicationStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationStatus", 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 + } + + var model ReplicationStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesresyncreplication.go b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesresyncreplication.go new file mode 100644 index 00000000000..23e1a66f518 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/method_volumesresyncreplication.go @@ -0,0 +1,70 @@ +package volumesreplication + +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 VolumesResyncReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesResyncReplication ... +func (c VolumesReplicationClient) VolumesResyncReplication(ctx context.Context, id VolumeId) (result VolumesResyncReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resyncReplication", 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 +} + +// VolumesResyncReplicationThenPoll performs VolumesResyncReplication then polls until it's completed +func (c VolumesReplicationClient) VolumesResyncReplicationThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesResyncReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesResyncReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesResyncReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_authorizerequest.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_authorizerequest.go new file mode 100644 index 00000000000..ff1cefa31ef --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_authorizerequest.go @@ -0,0 +1,8 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthorizeRequest struct { + RemoteVolumeResourceId *string `json:"remoteVolumeResourceId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_breakreplicationrequest.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_breakreplicationrequest.go new file mode 100644 index 00000000000..b6a0a179a9c --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_breakreplicationrequest.go @@ -0,0 +1,8 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BreakReplicationRequest struct { + ForceBreakReplication *bool `json:"forceBreakReplication,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_listreplications.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_listreplications.go new file mode 100644 index 00000000000..7929ea4ace4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_listreplications.go @@ -0,0 +1,8 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListReplications struct { + Value *[]Replication `json:"value,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_reestablishreplicationrequest.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_reestablishreplicationrequest.go new file mode 100644 index 00000000000..193b71f1490 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_reestablishreplicationrequest.go @@ -0,0 +1,8 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReestablishReplicationRequest struct { + SourceVolumeId *string `json:"sourceVolumeId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_replication.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_replication.go new file mode 100644 index 00000000000..ff1273507a2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_replication.go @@ -0,0 +1,12 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replication struct { + EndpointType *EndpointType `json:"endpointType,omitempty"` + RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` + RemoteVolumeResourceId string `json:"remoteVolumeResourceId"` + ReplicationId *string `json:"replicationId,omitempty"` + ReplicationSchedule *ReplicationSchedule `json:"replicationSchedule,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/model_replicationstatus.go b/resource-manager/netapp/2024-07-01/volumesreplication/model_replicationstatus.go new file mode 100644 index 00000000000..2a79dddf7a4 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/model_replicationstatus.go @@ -0,0 +1,12 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationStatus struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Healthy *bool `json:"healthy,omitempty"` + MirrorState *MirrorState `json:"mirrorState,omitempty"` + RelationshipStatus *RelationshipStatus `json:"relationshipStatus,omitempty"` + TotalProgress *string `json:"totalProgress,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesreplication/version.go b/resource-manager/netapp/2024-07-01/volumesreplication/version.go new file mode 100644 index 00000000000..1f51c796264 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesreplication/version.go @@ -0,0 +1,10 @@ +package volumesreplication + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumesreplication/2024-07-01" +} diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/README.md b/resource-manager/netapp/2024-07-01/volumesrevert/README.md new file mode 100644 index 00000000000..1c8df6afff2 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2024-07-01/volumesrevert` Documentation + +The `volumesrevert` SDK allows for interaction with Azure Resource Manager `netapp` (API Version `2024-07-01`). + +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/netapp/2024-07-01/volumesrevert" +``` + + +### Client Initialization + +```go +client := volumesrevert.NewVolumesRevertClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VolumesRevertClient.VolumesRevert` + +```go +ctx := context.TODO() +id := volumesrevert.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + +payload := volumesrevert.VolumeRevert{ + // ... +} + + +if err := client.VolumesRevertThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/client.go b/resource-manager/netapp/2024-07-01/volumesrevert/client.go new file mode 100644 index 00000000000..353b7571904 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/client.go @@ -0,0 +1,26 @@ +package volumesrevert + +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 VolumesRevertClient struct { + Client *resourcemanager.Client +} + +func NewVolumesRevertClientWithBaseURI(sdkApi sdkEnv.Api) (*VolumesRevertClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "volumesrevert", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VolumesRevertClient: %+v", err) + } + + return &VolumesRevertClient{ + Client: client, + }, nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/id_volume.go b/resource-manager/netapp/2024-07-01/volumesrevert/id_volume.go new file mode 100644 index 00000000000..e61cfcfca50 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/id_volume.go @@ -0,0 +1,148 @@ +package volumesrevert + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + NetAppAccountName string + CapacityPoolName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, netAppAccountName string, capacityPoolName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetAppAccountName: netAppAccountName, + CapacityPoolName: capacityPoolName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.NetAppAccountName, ok = input.Parsed["netAppAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "netAppAccountName", input) + } + + if id.CapacityPoolName, ok = input.Parsed["capacityPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "capacityPoolName", input) + } + + if id.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetApp/netAppAccounts/%s/capacityPools/%s/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetApp", "Microsoft.NetApp", "Microsoft.NetApp"), + resourceids.StaticSegment("staticNetAppAccounts", "netAppAccounts", "netAppAccounts"), + resourceids.UserSpecifiedSegment("netAppAccountName", "netAppAccountName"), + resourceids.StaticSegment("staticCapacityPools", "capacityPools", "capacityPools"), + resourceids.UserSpecifiedSegment("capacityPoolName", "capacityPoolName"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Net App Account Name: %q", id.NetAppAccountName), + fmt.Sprintf("Capacity Pool Name: %q", id.CapacityPoolName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/id_volume_test.go b/resource-manager/netapp/2024-07-01/volumesrevert/id_volume_test.go new file mode 100644 index 00000000000..f26bf43ecc3 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/id_volume_test.go @@ -0,0 +1,372 @@ +package volumesrevert + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName") + + 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.NetAppAccountName != "netAppAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'NetAppAccountName'", id.NetAppAccountName, "netAppAccountName") + } + + if id.CapacityPoolName != "capacityPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'CapacityPoolName'", id.CapacityPoolName, "capacityPoolName") + } + + if id.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "netAppAccountName", "capacityPoolName", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetApp", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetAppAccountName: "netAppAccountName", + CapacityPoolName: "capacityPoolName", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetApp/netAppAccounts/netAppAccountName/capacityPools/capacityPoolName/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetAppAccountName: "nEtApPaCcOuNtNaMe", + CapacityPoolName: "cApAcItYpOoLnAmE", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtApP/nEtApPaCcOuNtS/nEtApPaCcOuNtNaMe/cApAcItYpOoLs/cApAcItYpOoLnAmE/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.NetAppAccountName != v.Expected.NetAppAccountName { + t.Fatalf("Expected %q but got %q for NetAppAccountName", v.Expected.NetAppAccountName, actual.NetAppAccountName) + } + + if actual.CapacityPoolName != v.Expected.CapacityPoolName { + t.Fatalf("Expected %q but got %q for CapacityPoolName", v.Expected.CapacityPoolName, actual.CapacityPoolName) + } + + if actual.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/netapp/2024-07-01/volumesrevert/method_volumesrevert.go b/resource-manager/netapp/2024-07-01/volumesrevert/method_volumesrevert.go new file mode 100644 index 00000000000..0be129fdd47 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/method_volumesrevert.go @@ -0,0 +1,74 @@ +package volumesrevert + +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 VolumesRevertOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesRevert ... +func (c VolumesRevertClient) VolumesRevert(ctx context.Context, id VolumeId, input VolumeRevert) (result VolumesRevertOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/revert", 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 +} + +// VolumesRevertThenPoll performs VolumesRevert then polls until it's completed +func (c VolumesRevertClient) VolumesRevertThenPoll(ctx context.Context, id VolumeId, input VolumeRevert) error { + result, err := c.VolumesRevert(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesRevert: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesRevert: %+v", err) + } + + return nil +} diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/model_volumerevert.go b/resource-manager/netapp/2024-07-01/volumesrevert/model_volumerevert.go new file mode 100644 index 00000000000..c5adf461cf8 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/model_volumerevert.go @@ -0,0 +1,8 @@ +package volumesrevert + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeRevert struct { + SnapshotId *string `json:"snapshotId,omitempty"` +} diff --git a/resource-manager/netapp/2024-07-01/volumesrevert/version.go b/resource-manager/netapp/2024-07-01/volumesrevert/version.go new file mode 100644 index 00000000000..4d03b161373 --- /dev/null +++ b/resource-manager/netapp/2024-07-01/volumesrevert/version.go @@ -0,0 +1,10 @@ +package volumesrevert + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/volumesrevert/2024-07-01" +} diff --git a/resource-manager/networkcloud/2024-07-01/client.go b/resource-manager/networkcloud/2024-07-01/client.go new file mode 100644 index 00000000000..e2989b08ca7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/client.go @@ -0,0 +1,28 @@ +package v2024_07_01 + +// 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/networkcloud/2024-07-01/networkclouds" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Networkclouds *networkclouds.NetworkcloudsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + networkcloudsClient, err := networkclouds.NewNetworkcloudsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Networkclouds client: %+v", err) + } + configureFunc(networkcloudsClient.Client) + + return &Client{ + Networkclouds: networkcloudsClient, + }, nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/README.md b/resource-manager/networkcloud/2024-07-01/networkclouds/README.md new file mode 100644 index 00000000000..24cdc5bdc25 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/README.md @@ -0,0 +1,2017 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/networkcloud/2024-07-01/networkclouds` Documentation + +The `networkclouds` SDK allows for interaction with Azure Resource Manager `networkcloud` (API Version `2024-07-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/networkcloud/2024-07-01/networkclouds" +``` + + +### Client Initialization + +```go +client := networkclouds.NewNetworkcloudsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkcloudsClient.AgentPoolsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName") + +payload := networkclouds.AgentPool{ + // ... +} + + +if err := client.AgentPoolsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.AgentPoolsDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName") + +if err := client.AgentPoolsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.AgentPoolsGet` + +```go +ctx := context.TODO() +id := networkclouds.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName") + +read, err := client.AgentPoolsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.AgentPoolsListByKubernetesCluster` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +// alternatively `client.AgentPoolsListByKubernetesCluster(ctx, id)` can be used to do batched pagination +items, err := client.AgentPoolsListByKubernetesClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.AgentPoolsUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName") + +payload := networkclouds.AgentPoolPatchParameters{ + // ... +} + + +if err := client.AgentPoolsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachineKeySetsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName") + +payload := networkclouds.BareMetalMachineKeySet{ + // ... +} + + +if err := client.BareMetalMachineKeySetsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachineKeySetsDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName") + +if err := client.BareMetalMachineKeySetsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachineKeySetsGet` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName") + +read, err := client.BareMetalMachineKeySetsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachineKeySetsListByCluster` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.BareMetalMachineKeySetsListByCluster(ctx, id)` can be used to do batched pagination +items, err := client.BareMetalMachineKeySetsListByClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachineKeySetsUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName") + +payload := networkclouds.BareMetalMachineKeySetPatchParameters{ + // ... +} + + +if err := client.BareMetalMachineKeySetsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesCordon` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachineCordonParameters{ + // ... +} + + +if err := client.BareMetalMachinesCordonThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachine{ + // ... +} + + +if err := client.BareMetalMachinesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +if err := client.BareMetalMachinesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +read, err := client.BareMetalMachinesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.BareMetalMachinesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.BareMetalMachinesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.BareMetalMachinesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.BareMetalMachinesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesPowerOff` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachinePowerOffParameters{ + // ... +} + + +if err := client.BareMetalMachinesPowerOffThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesReimage` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +if err := client.BareMetalMachinesReimageThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesReplace` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachineReplaceParameters{ + // ... +} + + +if err := client.BareMetalMachinesReplaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesRestart` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +if err := client.BareMetalMachinesRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesRunCommand` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachineRunCommandParameters{ + // ... +} + + +if err := client.BareMetalMachinesRunCommandThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesRunDataExtracts` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachineRunDataExtractsParameters{ + // ... +} + + +if err := client.BareMetalMachinesRunDataExtractsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesRunReadCommands` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachineRunReadCommandsParameters{ + // ... +} + + +if err := client.BareMetalMachinesRunReadCommandsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesStart` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +if err := client.BareMetalMachinesStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesUncordon` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +if err := client.BareMetalMachinesUncordonThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BareMetalMachinesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + +payload := networkclouds.BareMetalMachinePatchParameters{ + // ... +} + + +if err := client.BareMetalMachinesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BmcKeySetsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName") + +payload := networkclouds.BmcKeySet{ + // ... +} + + +if err := client.BmcKeySetsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BmcKeySetsDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName") + +if err := client.BmcKeySetsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.BmcKeySetsGet` + +```go +ctx := context.TODO() +id := networkclouds.NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName") + +read, err := client.BmcKeySetsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.BmcKeySetsListByCluster` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.BmcKeySetsListByCluster(ctx, id)` can be used to do batched pagination +items, err := client.BmcKeySetsListByClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.BmcKeySetsUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName") + +payload := networkclouds.BmcKeySetPatchParameters{ + // ... +} + + +if err := client.BmcKeySetsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName") + +payload := networkclouds.CloudServicesNetwork{ + // ... +} + + +if err := client.CloudServicesNetworksCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName") + +if err := client.CloudServicesNetworksDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksGet` + +```go +ctx := context.TODO() +id := networkclouds.NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName") + +read, err := client.CloudServicesNetworksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.CloudServicesNetworksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.CloudServicesNetworksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.CloudServicesNetworksListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.CloudServicesNetworksListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.CloudServicesNetworksUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName") + +payload := networkclouds.CloudServicesNetworkPatchParameters{ + // ... +} + + +if err := client.CloudServicesNetworksUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName") + +payload := networkclouds.ClusterManager{ + // ... +} + + +if err := client.ClusterManagersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName") + +if err := client.ClusterManagersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersGet` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName") + +read, err := client.ClusterManagersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ClusterManagersListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ClusterManagersListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ClusterManagersListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ClusterManagersListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.ClusterManagersUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName") + +payload := networkclouds.ClusterManagerPatchParameters{ + // ... +} + + +read, err := client.ClusterManagersUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersContinueUpdateVersion` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.ClusterContinueUpdateVersionParameters{ + // ... +} + + +if err := client.ClustersContinueUpdateVersionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.Cluster{ + // ... +} + + +if err := client.ClustersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.ClustersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersDeploy` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.ClusterDeployParameters{ + // ... +} + + +if err := client.ClustersDeployThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersGet` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.ClustersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ClustersListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ClustersListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ClustersListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ClustersListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersScanRuntime` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.ClusterScanRuntimeParameters{ + // ... +} + + +if err := client.ClustersScanRuntimeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.ClusterPatchParameters{ + // ... +} + + +if err := client.ClustersUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ClustersUpdateVersion` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := networkclouds.ClusterUpdateVersionParameters{ + // ... +} + + +if err := client.ClustersUpdateVersionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ConsolesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName") + +payload := networkclouds.Console{ + // ... +} + + +if err := client.ConsolesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ConsolesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName") + +if err := client.ConsolesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.ConsolesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName") + +read, err := client.ConsolesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.ConsolesListByVirtualMachine` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +// alternatively `client.ConsolesListByVirtualMachine(ctx, id)` can be used to do batched pagination +items, err := client.ConsolesListByVirtualMachineComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.ConsolesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName") + +payload := networkclouds.ConsolePatchParameters{ + // ... +} + + +if err := client.ConsolesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClusterFeaturesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName") + +payload := networkclouds.KubernetesClusterFeature{ + // ... +} + + +if err := client.KubernetesClusterFeaturesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClusterFeaturesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName") + +if err := client.KubernetesClusterFeaturesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClusterFeaturesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName") + +read, err := client.KubernetesClusterFeaturesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClusterFeaturesListByKubernetesCluster` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +// alternatively `client.KubernetesClusterFeaturesListByKubernetesCluster(ctx, id)` can be used to do batched pagination +items, err := client.KubernetesClusterFeaturesListByKubernetesClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClusterFeaturesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName") + +payload := networkclouds.KubernetesClusterFeaturePatchParameters{ + // ... +} + + +if err := client.KubernetesClusterFeaturesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +payload := networkclouds.KubernetesCluster{ + // ... +} + + +if err := client.KubernetesClustersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +if err := client.KubernetesClustersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersGet` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +read, err := client.KubernetesClustersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.KubernetesClustersListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.KubernetesClustersListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.KubernetesClustersListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.KubernetesClustersListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersRestartNode` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +payload := networkclouds.KubernetesClusterRestartNodeParameters{ + // ... +} + + +if err := client.KubernetesClustersRestartNodeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.KubernetesClustersUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + +payload := networkclouds.KubernetesClusterPatchParameters{ + // ... +} + + +if err := client.KubernetesClustersUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName") + +payload := networkclouds.L2Network{ + // ... +} + + +if err := client.L2NetworksCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName") + +if err := client.L2NetworksDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksGet` + +```go +ctx := context.TODO() +id := networkclouds.NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName") + +read, err := client.L2NetworksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.L2NetworksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.L2NetworksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.L2NetworksListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.L2NetworksListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.L2NetworksUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName") + +payload := networkclouds.L2NetworkPatchParameters{ + // ... +} + + +read, err := client.L2NetworksUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName") + +payload := networkclouds.L3Network{ + // ... +} + + +if err := client.L3NetworksCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName") + +if err := client.L3NetworksDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksGet` + +```go +ctx := context.TODO() +id := networkclouds.NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName") + +read, err := client.L3NetworksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.L3NetworksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.L3NetworksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.L3NetworksListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.L3NetworksListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.L3NetworksUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName") + +payload := networkclouds.L3NetworkPatchParameters{ + // ... +} + + +read, err := client.L3NetworksUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.MetricsConfigurationsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName") + +payload := networkclouds.ClusterMetricsConfiguration{ + // ... +} + + +if err := client.MetricsConfigurationsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.MetricsConfigurationsDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName") + +if err := client.MetricsConfigurationsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.MetricsConfigurationsGet` + +```go +ctx := context.TODO() +id := networkclouds.NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName") + +read, err := client.MetricsConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.MetricsConfigurationsListByCluster` + +```go +ctx := context.TODO() +id := networkclouds.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.MetricsConfigurationsListByCluster(ctx, id)` can be used to do batched pagination +items, err := client.MetricsConfigurationsListByClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.MetricsConfigurationsUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName") + +payload := networkclouds.ClusterMetricsConfigurationPatchParameters{ + // ... +} + + +if err := client.MetricsConfigurationsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.RackSkusGet` + +```go +ctx := context.TODO() +id := networkclouds.NewRackSkuID("12345678-1234-9876-4563-123456789012", "rackSkuName") + +read, err := client.RackSkusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.RackSkusListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.RackSkusListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.RackSkusListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName") + +payload := networkclouds.Rack{ + // ... +} + + +if err := client.RacksCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName") + +if err := client.RacksDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksGet` + +```go +ctx := context.TODO() +id := networkclouds.NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName") + +read, err := client.RacksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.RacksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.RacksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.RacksListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.RacksListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.RacksUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName") + +payload := networkclouds.RackPatchParameters{ + // ... +} + + +if err := client.RacksUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +payload := networkclouds.StorageAppliance{ + // ... +} + + +if err := client.StorageAppliancesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +if err := client.StorageAppliancesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesDisableRemoteVendorManagement` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +if err := client.StorageAppliancesDisableRemoteVendorManagementThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesEnableRemoteVendorManagement` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +payload := networkclouds.StorageApplianceEnableRemoteVendorManagementParameters{ + // ... +} + + +if err := client.StorageAppliancesEnableRemoteVendorManagementThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +read, err := client.StorageAppliancesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.StorageAppliancesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.StorageAppliancesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.StorageAppliancesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.StorageAppliancesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.StorageAppliancesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + +payload := networkclouds.StorageAppliancePatchParameters{ + // ... +} + + +if err := client.StorageAppliancesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName") + +payload := networkclouds.TrunkedNetwork{ + // ... +} + + +if err := client.TrunkedNetworksCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName") + +if err := client.TrunkedNetworksDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksGet` + +```go +ctx := context.TODO() +id := networkclouds.NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName") + +read, err := client.TrunkedNetworksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.TrunkedNetworksListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.TrunkedNetworksListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.TrunkedNetworksListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.TrunkedNetworksListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.TrunkedNetworksUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName") + +payload := networkclouds.TrunkedNetworkPatchParameters{ + // ... +} + + +read, err := client.TrunkedNetworksUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +payload := networkclouds.VirtualMachine{ + // ... +} + + +if err := client.VirtualMachinesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +if err := client.VirtualMachinesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +read, err := client.VirtualMachinesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VirtualMachinesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VirtualMachinesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VirtualMachinesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.VirtualMachinesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesPowerOff` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +payload := networkclouds.VirtualMachinePowerOffParameters{ + // ... +} + + +if err := client.VirtualMachinesPowerOffThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesReimage` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +if err := client.VirtualMachinesReimageThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesRestart` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +if err := client.VirtualMachinesRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesStart` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +if err := client.VirtualMachinesStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VirtualMachinesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +payload := networkclouds.VirtualMachinePatchParameters{ + // ... +} + + +if err := client.VirtualMachinesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName") + +payload := networkclouds.Volume{ + // ... +} + + +if err := client.VolumesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesDelete` + +```go +ctx := context.TODO() +id := networkclouds.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName") + +if err := client.VolumesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesGet` + +```go +ctx := context.TODO() +id := networkclouds.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName") + +read, err := client.VolumesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VolumesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VolumesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VolumesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.VolumesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkcloudsClient.VolumesUpdate` + +```go +ctx := context.TODO() +id := networkclouds.NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName") + +payload := networkclouds.VolumePatchParameters{ + // ... +} + + +read, err := client.VolumesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/client.go b/resource-manager/networkcloud/2024-07-01/networkclouds/client.go new file mode 100644 index 00000000000..3b942669cef --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/client.go @@ -0,0 +1,26 @@ +package networkclouds + +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 NetworkcloudsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkcloudsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkcloudsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkclouds", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkcloudsClient: %+v", err) + } + + return &NetworkcloudsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/constants.go b/resource-manager/networkcloud/2024-07-01/networkclouds/constants.go new file mode 100644 index 00000000000..5bd59d0ce72 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/constants.go @@ -0,0 +1,4426 @@ +package networkclouds + +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 AdvertiseToFabric string + +const ( + AdvertiseToFabricFalse AdvertiseToFabric = "False" + AdvertiseToFabricTrue AdvertiseToFabric = "True" +) + +func PossibleValuesForAdvertiseToFabric() []string { + return []string{ + string(AdvertiseToFabricFalse), + string(AdvertiseToFabricTrue), + } +} + +func (s *AdvertiseToFabric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertiseToFabric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertiseToFabric(input string) (*AdvertiseToFabric, error) { + vals := map[string]AdvertiseToFabric{ + "false": AdvertiseToFabricFalse, + "true": AdvertiseToFabricTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertiseToFabric(input) + return &out, nil +} + +type AgentPoolDetailedStatus string + +const ( + AgentPoolDetailedStatusAvailable AgentPoolDetailedStatus = "Available" + AgentPoolDetailedStatusError AgentPoolDetailedStatus = "Error" + AgentPoolDetailedStatusProvisioning AgentPoolDetailedStatus = "Provisioning" +) + +func PossibleValuesForAgentPoolDetailedStatus() []string { + return []string{ + string(AgentPoolDetailedStatusAvailable), + string(AgentPoolDetailedStatusError), + string(AgentPoolDetailedStatusProvisioning), + } +} + +func (s *AgentPoolDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolDetailedStatus(input string) (*AgentPoolDetailedStatus, error) { + vals := map[string]AgentPoolDetailedStatus{ + "available": AgentPoolDetailedStatusAvailable, + "error": AgentPoolDetailedStatusError, + "provisioning": AgentPoolDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolDetailedStatus(input) + return &out, nil +} + +type AgentPoolMode string + +const ( + AgentPoolModeNotApplicable AgentPoolMode = "NotApplicable" + AgentPoolModeSystem AgentPoolMode = "System" + AgentPoolModeUser AgentPoolMode = "User" +) + +func PossibleValuesForAgentPoolMode() []string { + return []string{ + string(AgentPoolModeNotApplicable), + string(AgentPoolModeSystem), + string(AgentPoolModeUser), + } +} + +func (s *AgentPoolMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolMode(input string) (*AgentPoolMode, error) { + vals := map[string]AgentPoolMode{ + "notapplicable": AgentPoolModeNotApplicable, + "system": AgentPoolModeSystem, + "user": AgentPoolModeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolMode(input) + return &out, nil +} + +type AgentPoolProvisioningState string + +const ( + AgentPoolProvisioningStateAccepted AgentPoolProvisioningState = "Accepted" + AgentPoolProvisioningStateCanceled AgentPoolProvisioningState = "Canceled" + AgentPoolProvisioningStateDeleting AgentPoolProvisioningState = "Deleting" + AgentPoolProvisioningStateFailed AgentPoolProvisioningState = "Failed" + AgentPoolProvisioningStateInProgress AgentPoolProvisioningState = "InProgress" + AgentPoolProvisioningStateSucceeded AgentPoolProvisioningState = "Succeeded" + AgentPoolProvisioningStateUpdating AgentPoolProvisioningState = "Updating" +) + +func PossibleValuesForAgentPoolProvisioningState() []string { + return []string{ + string(AgentPoolProvisioningStateAccepted), + string(AgentPoolProvisioningStateCanceled), + string(AgentPoolProvisioningStateDeleting), + string(AgentPoolProvisioningStateFailed), + string(AgentPoolProvisioningStateInProgress), + string(AgentPoolProvisioningStateSucceeded), + string(AgentPoolProvisioningStateUpdating), + } +} + +func (s *AgentPoolProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolProvisioningState(input string) (*AgentPoolProvisioningState, error) { + vals := map[string]AgentPoolProvisioningState{ + "accepted": AgentPoolProvisioningStateAccepted, + "canceled": AgentPoolProvisioningStateCanceled, + "deleting": AgentPoolProvisioningStateDeleting, + "failed": AgentPoolProvisioningStateFailed, + "inprogress": AgentPoolProvisioningStateInProgress, + "succeeded": AgentPoolProvisioningStateSucceeded, + "updating": AgentPoolProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolProvisioningState(input) + return &out, nil +} + +type AvailabilityLifecycle string + +const ( + AvailabilityLifecycleGenerallyAvailable AvailabilityLifecycle = "GenerallyAvailable" + AvailabilityLifecyclePreview AvailabilityLifecycle = "Preview" +) + +func PossibleValuesForAvailabilityLifecycle() []string { + return []string{ + string(AvailabilityLifecycleGenerallyAvailable), + string(AvailabilityLifecyclePreview), + } +} + +func (s *AvailabilityLifecycle) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAvailabilityLifecycle(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAvailabilityLifecycle(input string) (*AvailabilityLifecycle, error) { + vals := map[string]AvailabilityLifecycle{ + "generallyavailable": AvailabilityLifecycleGenerallyAvailable, + "preview": AvailabilityLifecyclePreview, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AvailabilityLifecycle(input) + return &out, nil +} + +type BareMetalMachineCordonStatus string + +const ( + BareMetalMachineCordonStatusCordoned BareMetalMachineCordonStatus = "Cordoned" + BareMetalMachineCordonStatusUncordoned BareMetalMachineCordonStatus = "Uncordoned" +) + +func PossibleValuesForBareMetalMachineCordonStatus() []string { + return []string{ + string(BareMetalMachineCordonStatusCordoned), + string(BareMetalMachineCordonStatusUncordoned), + } +} + +func (s *BareMetalMachineCordonStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineCordonStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineCordonStatus(input string) (*BareMetalMachineCordonStatus, error) { + vals := map[string]BareMetalMachineCordonStatus{ + "cordoned": BareMetalMachineCordonStatusCordoned, + "uncordoned": BareMetalMachineCordonStatusUncordoned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineCordonStatus(input) + return &out, nil +} + +type BareMetalMachineDetailedStatus string + +const ( + BareMetalMachineDetailedStatusAvailable BareMetalMachineDetailedStatus = "Available" + BareMetalMachineDetailedStatusDeprovisioning BareMetalMachineDetailedStatus = "Deprovisioning" + BareMetalMachineDetailedStatusError BareMetalMachineDetailedStatus = "Error" + BareMetalMachineDetailedStatusPreparing BareMetalMachineDetailedStatus = "Preparing" + BareMetalMachineDetailedStatusProvisioned BareMetalMachineDetailedStatus = "Provisioned" + BareMetalMachineDetailedStatusProvisioning BareMetalMachineDetailedStatus = "Provisioning" +) + +func PossibleValuesForBareMetalMachineDetailedStatus() []string { + return []string{ + string(BareMetalMachineDetailedStatusAvailable), + string(BareMetalMachineDetailedStatusDeprovisioning), + string(BareMetalMachineDetailedStatusError), + string(BareMetalMachineDetailedStatusPreparing), + string(BareMetalMachineDetailedStatusProvisioned), + string(BareMetalMachineDetailedStatusProvisioning), + } +} + +func (s *BareMetalMachineDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineDetailedStatus(input string) (*BareMetalMachineDetailedStatus, error) { + vals := map[string]BareMetalMachineDetailedStatus{ + "available": BareMetalMachineDetailedStatusAvailable, + "deprovisioning": BareMetalMachineDetailedStatusDeprovisioning, + "error": BareMetalMachineDetailedStatusError, + "preparing": BareMetalMachineDetailedStatusPreparing, + "provisioned": BareMetalMachineDetailedStatusProvisioned, + "provisioning": BareMetalMachineDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineDetailedStatus(input) + return &out, nil +} + +type BareMetalMachineEvacuate string + +const ( + BareMetalMachineEvacuateFalse BareMetalMachineEvacuate = "False" + BareMetalMachineEvacuateTrue BareMetalMachineEvacuate = "True" +) + +func PossibleValuesForBareMetalMachineEvacuate() []string { + return []string{ + string(BareMetalMachineEvacuateFalse), + string(BareMetalMachineEvacuateTrue), + } +} + +func (s *BareMetalMachineEvacuate) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineEvacuate(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineEvacuate(input string) (*BareMetalMachineEvacuate, error) { + vals := map[string]BareMetalMachineEvacuate{ + "false": BareMetalMachineEvacuateFalse, + "true": BareMetalMachineEvacuateTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineEvacuate(input) + return &out, nil +} + +type BareMetalMachineHardwareValidationResult string + +const ( + BareMetalMachineHardwareValidationResultFail BareMetalMachineHardwareValidationResult = "Fail" + BareMetalMachineHardwareValidationResultPass BareMetalMachineHardwareValidationResult = "Pass" +) + +func PossibleValuesForBareMetalMachineHardwareValidationResult() []string { + return []string{ + string(BareMetalMachineHardwareValidationResultFail), + string(BareMetalMachineHardwareValidationResultPass), + } +} + +func (s *BareMetalMachineHardwareValidationResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineHardwareValidationResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineHardwareValidationResult(input string) (*BareMetalMachineHardwareValidationResult, error) { + vals := map[string]BareMetalMachineHardwareValidationResult{ + "fail": BareMetalMachineHardwareValidationResultFail, + "pass": BareMetalMachineHardwareValidationResultPass, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineHardwareValidationResult(input) + return &out, nil +} + +type BareMetalMachineKeySetDetailedStatus string + +const ( + BareMetalMachineKeySetDetailedStatusAllActive BareMetalMachineKeySetDetailedStatus = "AllActive" + BareMetalMachineKeySetDetailedStatusAllInvalid BareMetalMachineKeySetDetailedStatus = "AllInvalid" + BareMetalMachineKeySetDetailedStatusSomeInvalid BareMetalMachineKeySetDetailedStatus = "SomeInvalid" + BareMetalMachineKeySetDetailedStatusValidating BareMetalMachineKeySetDetailedStatus = "Validating" +) + +func PossibleValuesForBareMetalMachineKeySetDetailedStatus() []string { + return []string{ + string(BareMetalMachineKeySetDetailedStatusAllActive), + string(BareMetalMachineKeySetDetailedStatusAllInvalid), + string(BareMetalMachineKeySetDetailedStatusSomeInvalid), + string(BareMetalMachineKeySetDetailedStatusValidating), + } +} + +func (s *BareMetalMachineKeySetDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineKeySetDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineKeySetDetailedStatus(input string) (*BareMetalMachineKeySetDetailedStatus, error) { + vals := map[string]BareMetalMachineKeySetDetailedStatus{ + "allactive": BareMetalMachineKeySetDetailedStatusAllActive, + "allinvalid": BareMetalMachineKeySetDetailedStatusAllInvalid, + "someinvalid": BareMetalMachineKeySetDetailedStatusSomeInvalid, + "validating": BareMetalMachineKeySetDetailedStatusValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineKeySetDetailedStatus(input) + return &out, nil +} + +type BareMetalMachineKeySetPrivilegeLevel string + +const ( + BareMetalMachineKeySetPrivilegeLevelStandard BareMetalMachineKeySetPrivilegeLevel = "Standard" + BareMetalMachineKeySetPrivilegeLevelSuperuser BareMetalMachineKeySetPrivilegeLevel = "Superuser" +) + +func PossibleValuesForBareMetalMachineKeySetPrivilegeLevel() []string { + return []string{ + string(BareMetalMachineKeySetPrivilegeLevelStandard), + string(BareMetalMachineKeySetPrivilegeLevelSuperuser), + } +} + +func (s *BareMetalMachineKeySetPrivilegeLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineKeySetPrivilegeLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineKeySetPrivilegeLevel(input string) (*BareMetalMachineKeySetPrivilegeLevel, error) { + vals := map[string]BareMetalMachineKeySetPrivilegeLevel{ + "standard": BareMetalMachineKeySetPrivilegeLevelStandard, + "superuser": BareMetalMachineKeySetPrivilegeLevelSuperuser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineKeySetPrivilegeLevel(input) + return &out, nil +} + +type BareMetalMachineKeySetProvisioningState string + +const ( + BareMetalMachineKeySetProvisioningStateAccepted BareMetalMachineKeySetProvisioningState = "Accepted" + BareMetalMachineKeySetProvisioningStateCanceled BareMetalMachineKeySetProvisioningState = "Canceled" + BareMetalMachineKeySetProvisioningStateFailed BareMetalMachineKeySetProvisioningState = "Failed" + BareMetalMachineKeySetProvisioningStateProvisioning BareMetalMachineKeySetProvisioningState = "Provisioning" + BareMetalMachineKeySetProvisioningStateSucceeded BareMetalMachineKeySetProvisioningState = "Succeeded" +) + +func PossibleValuesForBareMetalMachineKeySetProvisioningState() []string { + return []string{ + string(BareMetalMachineKeySetProvisioningStateAccepted), + string(BareMetalMachineKeySetProvisioningStateCanceled), + string(BareMetalMachineKeySetProvisioningStateFailed), + string(BareMetalMachineKeySetProvisioningStateProvisioning), + string(BareMetalMachineKeySetProvisioningStateSucceeded), + } +} + +func (s *BareMetalMachineKeySetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineKeySetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineKeySetProvisioningState(input string) (*BareMetalMachineKeySetProvisioningState, error) { + vals := map[string]BareMetalMachineKeySetProvisioningState{ + "accepted": BareMetalMachineKeySetProvisioningStateAccepted, + "canceled": BareMetalMachineKeySetProvisioningStateCanceled, + "failed": BareMetalMachineKeySetProvisioningStateFailed, + "provisioning": BareMetalMachineKeySetProvisioningStateProvisioning, + "succeeded": BareMetalMachineKeySetProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineKeySetProvisioningState(input) + return &out, nil +} + +type BareMetalMachineKeySetUserSetupStatus string + +const ( + BareMetalMachineKeySetUserSetupStatusActive BareMetalMachineKeySetUserSetupStatus = "Active" + BareMetalMachineKeySetUserSetupStatusInvalid BareMetalMachineKeySetUserSetupStatus = "Invalid" +) + +func PossibleValuesForBareMetalMachineKeySetUserSetupStatus() []string { + return []string{ + string(BareMetalMachineKeySetUserSetupStatusActive), + string(BareMetalMachineKeySetUserSetupStatusInvalid), + } +} + +func (s *BareMetalMachineKeySetUserSetupStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineKeySetUserSetupStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineKeySetUserSetupStatus(input string) (*BareMetalMachineKeySetUserSetupStatus, error) { + vals := map[string]BareMetalMachineKeySetUserSetupStatus{ + "active": BareMetalMachineKeySetUserSetupStatusActive, + "invalid": BareMetalMachineKeySetUserSetupStatusInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineKeySetUserSetupStatus(input) + return &out, nil +} + +type BareMetalMachinePowerState string + +const ( + BareMetalMachinePowerStateOff BareMetalMachinePowerState = "Off" + BareMetalMachinePowerStateOn BareMetalMachinePowerState = "On" +) + +func PossibleValuesForBareMetalMachinePowerState() []string { + return []string{ + string(BareMetalMachinePowerStateOff), + string(BareMetalMachinePowerStateOn), + } +} + +func (s *BareMetalMachinePowerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachinePowerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachinePowerState(input string) (*BareMetalMachinePowerState, error) { + vals := map[string]BareMetalMachinePowerState{ + "off": BareMetalMachinePowerStateOff, + "on": BareMetalMachinePowerStateOn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachinePowerState(input) + return &out, nil +} + +type BareMetalMachineProvisioningState string + +const ( + BareMetalMachineProvisioningStateAccepted BareMetalMachineProvisioningState = "Accepted" + BareMetalMachineProvisioningStateCanceled BareMetalMachineProvisioningState = "Canceled" + BareMetalMachineProvisioningStateFailed BareMetalMachineProvisioningState = "Failed" + BareMetalMachineProvisioningStateProvisioning BareMetalMachineProvisioningState = "Provisioning" + BareMetalMachineProvisioningStateSucceeded BareMetalMachineProvisioningState = "Succeeded" +) + +func PossibleValuesForBareMetalMachineProvisioningState() []string { + return []string{ + string(BareMetalMachineProvisioningStateAccepted), + string(BareMetalMachineProvisioningStateCanceled), + string(BareMetalMachineProvisioningStateFailed), + string(BareMetalMachineProvisioningStateProvisioning), + string(BareMetalMachineProvisioningStateSucceeded), + } +} + +func (s *BareMetalMachineProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineProvisioningState(input string) (*BareMetalMachineProvisioningState, error) { + vals := map[string]BareMetalMachineProvisioningState{ + "accepted": BareMetalMachineProvisioningStateAccepted, + "canceled": BareMetalMachineProvisioningStateCanceled, + "failed": BareMetalMachineProvisioningStateFailed, + "provisioning": BareMetalMachineProvisioningStateProvisioning, + "succeeded": BareMetalMachineProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineProvisioningState(input) + return &out, nil +} + +type BareMetalMachineReadyState string + +const ( + BareMetalMachineReadyStateFalse BareMetalMachineReadyState = "False" + BareMetalMachineReadyStateTrue BareMetalMachineReadyState = "True" +) + +func PossibleValuesForBareMetalMachineReadyState() []string { + return []string{ + string(BareMetalMachineReadyStateFalse), + string(BareMetalMachineReadyStateTrue), + } +} + +func (s *BareMetalMachineReadyState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineReadyState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineReadyState(input string) (*BareMetalMachineReadyState, error) { + vals := map[string]BareMetalMachineReadyState{ + "false": BareMetalMachineReadyStateFalse, + "true": BareMetalMachineReadyStateTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineReadyState(input) + return &out, nil +} + +type BareMetalMachineSkipShutdown string + +const ( + BareMetalMachineSkipShutdownFalse BareMetalMachineSkipShutdown = "False" + BareMetalMachineSkipShutdownTrue BareMetalMachineSkipShutdown = "True" +) + +func PossibleValuesForBareMetalMachineSkipShutdown() []string { + return []string{ + string(BareMetalMachineSkipShutdownFalse), + string(BareMetalMachineSkipShutdownTrue), + } +} + +func (s *BareMetalMachineSkipShutdown) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBareMetalMachineSkipShutdown(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBareMetalMachineSkipShutdown(input string) (*BareMetalMachineSkipShutdown, error) { + vals := map[string]BareMetalMachineSkipShutdown{ + "false": BareMetalMachineSkipShutdownFalse, + "true": BareMetalMachineSkipShutdownTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BareMetalMachineSkipShutdown(input) + return &out, nil +} + +type BfdEnabled string + +const ( + BfdEnabledFalse BfdEnabled = "False" + BfdEnabledTrue BfdEnabled = "True" +) + +func PossibleValuesForBfdEnabled() []string { + return []string{ + string(BfdEnabledFalse), + string(BfdEnabledTrue), + } +} + +func (s *BfdEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBfdEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBfdEnabled(input string) (*BfdEnabled, error) { + vals := map[string]BfdEnabled{ + "false": BfdEnabledFalse, + "true": BfdEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BfdEnabled(input) + return &out, nil +} + +type BgpMultiHop string + +const ( + BgpMultiHopFalse BgpMultiHop = "False" + BgpMultiHopTrue BgpMultiHop = "True" +) + +func PossibleValuesForBgpMultiHop() []string { + return []string{ + string(BgpMultiHopFalse), + string(BgpMultiHopTrue), + } +} + +func (s *BgpMultiHop) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBgpMultiHop(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBgpMultiHop(input string) (*BgpMultiHop, error) { + vals := map[string]BgpMultiHop{ + "false": BgpMultiHopFalse, + "true": BgpMultiHopTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BgpMultiHop(input) + return &out, nil +} + +type BmcKeySetDetailedStatus string + +const ( + BmcKeySetDetailedStatusAllActive BmcKeySetDetailedStatus = "AllActive" + BmcKeySetDetailedStatusAllInvalid BmcKeySetDetailedStatus = "AllInvalid" + BmcKeySetDetailedStatusSomeInvalid BmcKeySetDetailedStatus = "SomeInvalid" + BmcKeySetDetailedStatusValidating BmcKeySetDetailedStatus = "Validating" +) + +func PossibleValuesForBmcKeySetDetailedStatus() []string { + return []string{ + string(BmcKeySetDetailedStatusAllActive), + string(BmcKeySetDetailedStatusAllInvalid), + string(BmcKeySetDetailedStatusSomeInvalid), + string(BmcKeySetDetailedStatusValidating), + } +} + +func (s *BmcKeySetDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBmcKeySetDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBmcKeySetDetailedStatus(input string) (*BmcKeySetDetailedStatus, error) { + vals := map[string]BmcKeySetDetailedStatus{ + "allactive": BmcKeySetDetailedStatusAllActive, + "allinvalid": BmcKeySetDetailedStatusAllInvalid, + "someinvalid": BmcKeySetDetailedStatusSomeInvalid, + "validating": BmcKeySetDetailedStatusValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BmcKeySetDetailedStatus(input) + return &out, nil +} + +type BmcKeySetPrivilegeLevel string + +const ( + BmcKeySetPrivilegeLevelAdministrator BmcKeySetPrivilegeLevel = "Administrator" + BmcKeySetPrivilegeLevelReadOnly BmcKeySetPrivilegeLevel = "ReadOnly" +) + +func PossibleValuesForBmcKeySetPrivilegeLevel() []string { + return []string{ + string(BmcKeySetPrivilegeLevelAdministrator), + string(BmcKeySetPrivilegeLevelReadOnly), + } +} + +func (s *BmcKeySetPrivilegeLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBmcKeySetPrivilegeLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBmcKeySetPrivilegeLevel(input string) (*BmcKeySetPrivilegeLevel, error) { + vals := map[string]BmcKeySetPrivilegeLevel{ + "administrator": BmcKeySetPrivilegeLevelAdministrator, + "readonly": BmcKeySetPrivilegeLevelReadOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BmcKeySetPrivilegeLevel(input) + return &out, nil +} + +type BmcKeySetProvisioningState string + +const ( + BmcKeySetProvisioningStateAccepted BmcKeySetProvisioningState = "Accepted" + BmcKeySetProvisioningStateCanceled BmcKeySetProvisioningState = "Canceled" + BmcKeySetProvisioningStateFailed BmcKeySetProvisioningState = "Failed" + BmcKeySetProvisioningStateProvisioning BmcKeySetProvisioningState = "Provisioning" + BmcKeySetProvisioningStateSucceeded BmcKeySetProvisioningState = "Succeeded" +) + +func PossibleValuesForBmcKeySetProvisioningState() []string { + return []string{ + string(BmcKeySetProvisioningStateAccepted), + string(BmcKeySetProvisioningStateCanceled), + string(BmcKeySetProvisioningStateFailed), + string(BmcKeySetProvisioningStateProvisioning), + string(BmcKeySetProvisioningStateSucceeded), + } +} + +func (s *BmcKeySetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBmcKeySetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBmcKeySetProvisioningState(input string) (*BmcKeySetProvisioningState, error) { + vals := map[string]BmcKeySetProvisioningState{ + "accepted": BmcKeySetProvisioningStateAccepted, + "canceled": BmcKeySetProvisioningStateCanceled, + "failed": BmcKeySetProvisioningStateFailed, + "provisioning": BmcKeySetProvisioningStateProvisioning, + "succeeded": BmcKeySetProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BmcKeySetProvisioningState(input) + return &out, nil +} + +type BootstrapProtocol string + +const ( + BootstrapProtocolPXE BootstrapProtocol = "PXE" +) + +func PossibleValuesForBootstrapProtocol() []string { + return []string{ + string(BootstrapProtocolPXE), + } +} + +func (s *BootstrapProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBootstrapProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBootstrapProtocol(input string) (*BootstrapProtocol, error) { + vals := map[string]BootstrapProtocol{ + "pxe": BootstrapProtocolPXE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BootstrapProtocol(input) + return &out, nil +} + +type CloudServicesNetworkDetailedStatus string + +const ( + CloudServicesNetworkDetailedStatusAvailable CloudServicesNetworkDetailedStatus = "Available" + CloudServicesNetworkDetailedStatusError CloudServicesNetworkDetailedStatus = "Error" + CloudServicesNetworkDetailedStatusProvisioning CloudServicesNetworkDetailedStatus = "Provisioning" +) + +func PossibleValuesForCloudServicesNetworkDetailedStatus() []string { + return []string{ + string(CloudServicesNetworkDetailedStatusAvailable), + string(CloudServicesNetworkDetailedStatusError), + string(CloudServicesNetworkDetailedStatusProvisioning), + } +} + +func (s *CloudServicesNetworkDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudServicesNetworkDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudServicesNetworkDetailedStatus(input string) (*CloudServicesNetworkDetailedStatus, error) { + vals := map[string]CloudServicesNetworkDetailedStatus{ + "available": CloudServicesNetworkDetailedStatusAvailable, + "error": CloudServicesNetworkDetailedStatusError, + "provisioning": CloudServicesNetworkDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudServicesNetworkDetailedStatus(input) + return &out, nil +} + +type CloudServicesNetworkEnableDefaultEgressEndpoints string + +const ( + CloudServicesNetworkEnableDefaultEgressEndpointsFalse CloudServicesNetworkEnableDefaultEgressEndpoints = "False" + CloudServicesNetworkEnableDefaultEgressEndpointsTrue CloudServicesNetworkEnableDefaultEgressEndpoints = "True" +) + +func PossibleValuesForCloudServicesNetworkEnableDefaultEgressEndpoints() []string { + return []string{ + string(CloudServicesNetworkEnableDefaultEgressEndpointsFalse), + string(CloudServicesNetworkEnableDefaultEgressEndpointsTrue), + } +} + +func (s *CloudServicesNetworkEnableDefaultEgressEndpoints) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudServicesNetworkEnableDefaultEgressEndpoints(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudServicesNetworkEnableDefaultEgressEndpoints(input string) (*CloudServicesNetworkEnableDefaultEgressEndpoints, error) { + vals := map[string]CloudServicesNetworkEnableDefaultEgressEndpoints{ + "false": CloudServicesNetworkEnableDefaultEgressEndpointsFalse, + "true": CloudServicesNetworkEnableDefaultEgressEndpointsTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudServicesNetworkEnableDefaultEgressEndpoints(input) + return &out, nil +} + +type CloudServicesNetworkProvisioningState string + +const ( + CloudServicesNetworkProvisioningStateAccepted CloudServicesNetworkProvisioningState = "Accepted" + CloudServicesNetworkProvisioningStateCanceled CloudServicesNetworkProvisioningState = "Canceled" + CloudServicesNetworkProvisioningStateFailed CloudServicesNetworkProvisioningState = "Failed" + CloudServicesNetworkProvisioningStateProvisioning CloudServicesNetworkProvisioningState = "Provisioning" + CloudServicesNetworkProvisioningStateSucceeded CloudServicesNetworkProvisioningState = "Succeeded" +) + +func PossibleValuesForCloudServicesNetworkProvisioningState() []string { + return []string{ + string(CloudServicesNetworkProvisioningStateAccepted), + string(CloudServicesNetworkProvisioningStateCanceled), + string(CloudServicesNetworkProvisioningStateFailed), + string(CloudServicesNetworkProvisioningStateProvisioning), + string(CloudServicesNetworkProvisioningStateSucceeded), + } +} + +func (s *CloudServicesNetworkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudServicesNetworkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudServicesNetworkProvisioningState(input string) (*CloudServicesNetworkProvisioningState, error) { + vals := map[string]CloudServicesNetworkProvisioningState{ + "accepted": CloudServicesNetworkProvisioningStateAccepted, + "canceled": CloudServicesNetworkProvisioningStateCanceled, + "failed": CloudServicesNetworkProvisioningStateFailed, + "provisioning": CloudServicesNetworkProvisioningStateProvisioning, + "succeeded": CloudServicesNetworkProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudServicesNetworkProvisioningState(input) + return &out, nil +} + +type ClusterConnectionStatus string + +const ( + ClusterConnectionStatusConnected ClusterConnectionStatus = "Connected" + ClusterConnectionStatusDisconnected ClusterConnectionStatus = "Disconnected" + ClusterConnectionStatusTimeout ClusterConnectionStatus = "Timeout" + ClusterConnectionStatusUndefined ClusterConnectionStatus = "Undefined" +) + +func PossibleValuesForClusterConnectionStatus() []string { + return []string{ + string(ClusterConnectionStatusConnected), + string(ClusterConnectionStatusDisconnected), + string(ClusterConnectionStatusTimeout), + string(ClusterConnectionStatusUndefined), + } +} + +func (s *ClusterConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterConnectionStatus(input string) (*ClusterConnectionStatus, error) { + vals := map[string]ClusterConnectionStatus{ + "connected": ClusterConnectionStatusConnected, + "disconnected": ClusterConnectionStatusDisconnected, + "timeout": ClusterConnectionStatusTimeout, + "undefined": ClusterConnectionStatusUndefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterConnectionStatus(input) + return &out, nil +} + +type ClusterContinueUpdateVersionMachineGroupTargetingMode string + +const ( + ClusterContinueUpdateVersionMachineGroupTargetingModeAlphaByRack ClusterContinueUpdateVersionMachineGroupTargetingMode = "AlphaByRack" +) + +func PossibleValuesForClusterContinueUpdateVersionMachineGroupTargetingMode() []string { + return []string{ + string(ClusterContinueUpdateVersionMachineGroupTargetingModeAlphaByRack), + } +} + +func (s *ClusterContinueUpdateVersionMachineGroupTargetingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterContinueUpdateVersionMachineGroupTargetingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterContinueUpdateVersionMachineGroupTargetingMode(input string) (*ClusterContinueUpdateVersionMachineGroupTargetingMode, error) { + vals := map[string]ClusterContinueUpdateVersionMachineGroupTargetingMode{ + "alphabyrack": ClusterContinueUpdateVersionMachineGroupTargetingModeAlphaByRack, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterContinueUpdateVersionMachineGroupTargetingMode(input) + return &out, nil +} + +type ClusterDetailedStatus string + +const ( + ClusterDetailedStatusDegraded ClusterDetailedStatus = "Degraded" + ClusterDetailedStatusDeleting ClusterDetailedStatus = "Deleting" + ClusterDetailedStatusDeploying ClusterDetailedStatus = "Deploying" + ClusterDetailedStatusDisconnected ClusterDetailedStatus = "Disconnected" + ClusterDetailedStatusFailed ClusterDetailedStatus = "Failed" + ClusterDetailedStatusPendingDeployment ClusterDetailedStatus = "PendingDeployment" + ClusterDetailedStatusRunning ClusterDetailedStatus = "Running" + ClusterDetailedStatusUpdatePaused ClusterDetailedStatus = "UpdatePaused" + ClusterDetailedStatusUpdating ClusterDetailedStatus = "Updating" +) + +func PossibleValuesForClusterDetailedStatus() []string { + return []string{ + string(ClusterDetailedStatusDegraded), + string(ClusterDetailedStatusDeleting), + string(ClusterDetailedStatusDeploying), + string(ClusterDetailedStatusDisconnected), + string(ClusterDetailedStatusFailed), + string(ClusterDetailedStatusPendingDeployment), + string(ClusterDetailedStatusRunning), + string(ClusterDetailedStatusUpdatePaused), + string(ClusterDetailedStatusUpdating), + } +} + +func (s *ClusterDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterDetailedStatus(input string) (*ClusterDetailedStatus, error) { + vals := map[string]ClusterDetailedStatus{ + "degraded": ClusterDetailedStatusDegraded, + "deleting": ClusterDetailedStatusDeleting, + "deploying": ClusterDetailedStatusDeploying, + "disconnected": ClusterDetailedStatusDisconnected, + "failed": ClusterDetailedStatusFailed, + "pendingdeployment": ClusterDetailedStatusPendingDeployment, + "running": ClusterDetailedStatusRunning, + "updatepaused": ClusterDetailedStatusUpdatePaused, + "updating": ClusterDetailedStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterDetailedStatus(input) + return &out, nil +} + +type ClusterManagerConnectionStatus string + +const ( + ClusterManagerConnectionStatusConnected ClusterManagerConnectionStatus = "Connected" + ClusterManagerConnectionStatusUnreachable ClusterManagerConnectionStatus = "Unreachable" +) + +func PossibleValuesForClusterManagerConnectionStatus() []string { + return []string{ + string(ClusterManagerConnectionStatusConnected), + string(ClusterManagerConnectionStatusUnreachable), + } +} + +func (s *ClusterManagerConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterManagerConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterManagerConnectionStatus(input string) (*ClusterManagerConnectionStatus, error) { + vals := map[string]ClusterManagerConnectionStatus{ + "connected": ClusterManagerConnectionStatusConnected, + "unreachable": ClusterManagerConnectionStatusUnreachable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterManagerConnectionStatus(input) + return &out, nil +} + +type ClusterManagerDetailedStatus string + +const ( + ClusterManagerDetailedStatusAvailable ClusterManagerDetailedStatus = "Available" + ClusterManagerDetailedStatusError ClusterManagerDetailedStatus = "Error" + ClusterManagerDetailedStatusProvisioning ClusterManagerDetailedStatus = "Provisioning" + ClusterManagerDetailedStatusProvisioningFailed ClusterManagerDetailedStatus = "ProvisioningFailed" + ClusterManagerDetailedStatusUpdateFailed ClusterManagerDetailedStatus = "UpdateFailed" + ClusterManagerDetailedStatusUpdating ClusterManagerDetailedStatus = "Updating" +) + +func PossibleValuesForClusterManagerDetailedStatus() []string { + return []string{ + string(ClusterManagerDetailedStatusAvailable), + string(ClusterManagerDetailedStatusError), + string(ClusterManagerDetailedStatusProvisioning), + string(ClusterManagerDetailedStatusProvisioningFailed), + string(ClusterManagerDetailedStatusUpdateFailed), + string(ClusterManagerDetailedStatusUpdating), + } +} + +func (s *ClusterManagerDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterManagerDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterManagerDetailedStatus(input string) (*ClusterManagerDetailedStatus, error) { + vals := map[string]ClusterManagerDetailedStatus{ + "available": ClusterManagerDetailedStatusAvailable, + "error": ClusterManagerDetailedStatusError, + "provisioning": ClusterManagerDetailedStatusProvisioning, + "provisioningfailed": ClusterManagerDetailedStatusProvisioningFailed, + "updatefailed": ClusterManagerDetailedStatusUpdateFailed, + "updating": ClusterManagerDetailedStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterManagerDetailedStatus(input) + return &out, nil +} + +type ClusterManagerProvisioningState string + +const ( + ClusterManagerProvisioningStateAccepted ClusterManagerProvisioningState = "Accepted" + ClusterManagerProvisioningStateCanceled ClusterManagerProvisioningState = "Canceled" + ClusterManagerProvisioningStateFailed ClusterManagerProvisioningState = "Failed" + ClusterManagerProvisioningStateProvisioning ClusterManagerProvisioningState = "Provisioning" + ClusterManagerProvisioningStateSucceeded ClusterManagerProvisioningState = "Succeeded" + ClusterManagerProvisioningStateUpdating ClusterManagerProvisioningState = "Updating" +) + +func PossibleValuesForClusterManagerProvisioningState() []string { + return []string{ + string(ClusterManagerProvisioningStateAccepted), + string(ClusterManagerProvisioningStateCanceled), + string(ClusterManagerProvisioningStateFailed), + string(ClusterManagerProvisioningStateProvisioning), + string(ClusterManagerProvisioningStateSucceeded), + string(ClusterManagerProvisioningStateUpdating), + } +} + +func (s *ClusterManagerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterManagerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterManagerProvisioningState(input string) (*ClusterManagerProvisioningState, error) { + vals := map[string]ClusterManagerProvisioningState{ + "accepted": ClusterManagerProvisioningStateAccepted, + "canceled": ClusterManagerProvisioningStateCanceled, + "failed": ClusterManagerProvisioningStateFailed, + "provisioning": ClusterManagerProvisioningStateProvisioning, + "succeeded": ClusterManagerProvisioningStateSucceeded, + "updating": ClusterManagerProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterManagerProvisioningState(input) + return &out, nil +} + +type ClusterMetricsConfigurationDetailedStatus string + +const ( + ClusterMetricsConfigurationDetailedStatusApplied ClusterMetricsConfigurationDetailedStatus = "Applied" + ClusterMetricsConfigurationDetailedStatusError ClusterMetricsConfigurationDetailedStatus = "Error" + ClusterMetricsConfigurationDetailedStatusProcessing ClusterMetricsConfigurationDetailedStatus = "Processing" +) + +func PossibleValuesForClusterMetricsConfigurationDetailedStatus() []string { + return []string{ + string(ClusterMetricsConfigurationDetailedStatusApplied), + string(ClusterMetricsConfigurationDetailedStatusError), + string(ClusterMetricsConfigurationDetailedStatusProcessing), + } +} + +func (s *ClusterMetricsConfigurationDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterMetricsConfigurationDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterMetricsConfigurationDetailedStatus(input string) (*ClusterMetricsConfigurationDetailedStatus, error) { + vals := map[string]ClusterMetricsConfigurationDetailedStatus{ + "applied": ClusterMetricsConfigurationDetailedStatusApplied, + "error": ClusterMetricsConfigurationDetailedStatusError, + "processing": ClusterMetricsConfigurationDetailedStatusProcessing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterMetricsConfigurationDetailedStatus(input) + return &out, nil +} + +type ClusterMetricsConfigurationProvisioningState string + +const ( + ClusterMetricsConfigurationProvisioningStateAccepted ClusterMetricsConfigurationProvisioningState = "Accepted" + ClusterMetricsConfigurationProvisioningStateCanceled ClusterMetricsConfigurationProvisioningState = "Canceled" + ClusterMetricsConfigurationProvisioningStateFailed ClusterMetricsConfigurationProvisioningState = "Failed" + ClusterMetricsConfigurationProvisioningStateProvisioning ClusterMetricsConfigurationProvisioningState = "Provisioning" + ClusterMetricsConfigurationProvisioningStateSucceeded ClusterMetricsConfigurationProvisioningState = "Succeeded" +) + +func PossibleValuesForClusterMetricsConfigurationProvisioningState() []string { + return []string{ + string(ClusterMetricsConfigurationProvisioningStateAccepted), + string(ClusterMetricsConfigurationProvisioningStateCanceled), + string(ClusterMetricsConfigurationProvisioningStateFailed), + string(ClusterMetricsConfigurationProvisioningStateProvisioning), + string(ClusterMetricsConfigurationProvisioningStateSucceeded), + } +} + +func (s *ClusterMetricsConfigurationProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterMetricsConfigurationProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterMetricsConfigurationProvisioningState(input string) (*ClusterMetricsConfigurationProvisioningState, error) { + vals := map[string]ClusterMetricsConfigurationProvisioningState{ + "accepted": ClusterMetricsConfigurationProvisioningStateAccepted, + "canceled": ClusterMetricsConfigurationProvisioningStateCanceled, + "failed": ClusterMetricsConfigurationProvisioningStateFailed, + "provisioning": ClusterMetricsConfigurationProvisioningStateProvisioning, + "succeeded": ClusterMetricsConfigurationProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterMetricsConfigurationProvisioningState(input) + return &out, nil +} + +type ClusterProvisioningState string + +const ( + ClusterProvisioningStateAccepted ClusterProvisioningState = "Accepted" + ClusterProvisioningStateCanceled ClusterProvisioningState = "Canceled" + ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" + ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" + ClusterProvisioningStateUpdating ClusterProvisioningState = "Updating" + ClusterProvisioningStateValidating ClusterProvisioningState = "Validating" +) + +func PossibleValuesForClusterProvisioningState() []string { + return []string{ + string(ClusterProvisioningStateAccepted), + string(ClusterProvisioningStateCanceled), + string(ClusterProvisioningStateFailed), + string(ClusterProvisioningStateSucceeded), + string(ClusterProvisioningStateUpdating), + string(ClusterProvisioningStateValidating), + } +} + +func (s *ClusterProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterProvisioningState(input string) (*ClusterProvisioningState, error) { + vals := map[string]ClusterProvisioningState{ + "accepted": ClusterProvisioningStateAccepted, + "canceled": ClusterProvisioningStateCanceled, + "failed": ClusterProvisioningStateFailed, + "succeeded": ClusterProvisioningStateSucceeded, + "updating": ClusterProvisioningStateUpdating, + "validating": ClusterProvisioningStateValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterProvisioningState(input) + return &out, nil +} + +type ClusterScanRuntimeParametersScanActivity string + +const ( + ClusterScanRuntimeParametersScanActivityScan ClusterScanRuntimeParametersScanActivity = "Scan" + ClusterScanRuntimeParametersScanActivitySkip ClusterScanRuntimeParametersScanActivity = "Skip" +) + +func PossibleValuesForClusterScanRuntimeParametersScanActivity() []string { + return []string{ + string(ClusterScanRuntimeParametersScanActivityScan), + string(ClusterScanRuntimeParametersScanActivitySkip), + } +} + +func (s *ClusterScanRuntimeParametersScanActivity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterScanRuntimeParametersScanActivity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterScanRuntimeParametersScanActivity(input string) (*ClusterScanRuntimeParametersScanActivity, error) { + vals := map[string]ClusterScanRuntimeParametersScanActivity{ + "scan": ClusterScanRuntimeParametersScanActivityScan, + "skip": ClusterScanRuntimeParametersScanActivitySkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterScanRuntimeParametersScanActivity(input) + return &out, nil +} + +type ClusterSecretArchiveEnabled string + +const ( + ClusterSecretArchiveEnabledFalse ClusterSecretArchiveEnabled = "False" + ClusterSecretArchiveEnabledTrue ClusterSecretArchiveEnabled = "True" +) + +func PossibleValuesForClusterSecretArchiveEnabled() []string { + return []string{ + string(ClusterSecretArchiveEnabledFalse), + string(ClusterSecretArchiveEnabledTrue), + } +} + +func (s *ClusterSecretArchiveEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterSecretArchiveEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterSecretArchiveEnabled(input string) (*ClusterSecretArchiveEnabled, error) { + vals := map[string]ClusterSecretArchiveEnabled{ + "false": ClusterSecretArchiveEnabledFalse, + "true": ClusterSecretArchiveEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterSecretArchiveEnabled(input) + return &out, nil +} + +type ClusterType string + +const ( + ClusterTypeMultiRack ClusterType = "MultiRack" + ClusterTypeSingleRack ClusterType = "SingleRack" +) + +func PossibleValuesForClusterType() []string { + return []string{ + string(ClusterTypeMultiRack), + string(ClusterTypeSingleRack), + } +} + +func (s *ClusterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterType(input string) (*ClusterType, error) { + vals := map[string]ClusterType{ + "multirack": ClusterTypeMultiRack, + "singlerack": ClusterTypeSingleRack, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterType(input) + return &out, nil +} + +type ClusterUpdateStrategyType string + +const ( + ClusterUpdateStrategyTypePauseAfterRack ClusterUpdateStrategyType = "PauseAfterRack" + ClusterUpdateStrategyTypeRack ClusterUpdateStrategyType = "Rack" +) + +func PossibleValuesForClusterUpdateStrategyType() []string { + return []string{ + string(ClusterUpdateStrategyTypePauseAfterRack), + string(ClusterUpdateStrategyTypeRack), + } +} + +func (s *ClusterUpdateStrategyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpdateStrategyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterUpdateStrategyType(input string) (*ClusterUpdateStrategyType, error) { + vals := map[string]ClusterUpdateStrategyType{ + "pauseafterrack": ClusterUpdateStrategyTypePauseAfterRack, + "rack": ClusterUpdateStrategyTypeRack, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterUpdateStrategyType(input) + return &out, nil +} + +type ConsoleDetailedStatus string + +const ( + ConsoleDetailedStatusError ConsoleDetailedStatus = "Error" + ConsoleDetailedStatusReady ConsoleDetailedStatus = "Ready" +) + +func PossibleValuesForConsoleDetailedStatus() []string { + return []string{ + string(ConsoleDetailedStatusError), + string(ConsoleDetailedStatusReady), + } +} + +func (s *ConsoleDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConsoleDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConsoleDetailedStatus(input string) (*ConsoleDetailedStatus, error) { + vals := map[string]ConsoleDetailedStatus{ + "error": ConsoleDetailedStatusError, + "ready": ConsoleDetailedStatusReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConsoleDetailedStatus(input) + return &out, nil +} + +type ConsoleEnabled string + +const ( + ConsoleEnabledFalse ConsoleEnabled = "False" + ConsoleEnabledTrue ConsoleEnabled = "True" +) + +func PossibleValuesForConsoleEnabled() []string { + return []string{ + string(ConsoleEnabledFalse), + string(ConsoleEnabledTrue), + } +} + +func (s *ConsoleEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConsoleEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConsoleEnabled(input string) (*ConsoleEnabled, error) { + vals := map[string]ConsoleEnabled{ + "false": ConsoleEnabledFalse, + "true": ConsoleEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConsoleEnabled(input) + return &out, nil +} + +type ConsoleProvisioningState string + +const ( + ConsoleProvisioningStateAccepted ConsoleProvisioningState = "Accepted" + ConsoleProvisioningStateCanceled ConsoleProvisioningState = "Canceled" + ConsoleProvisioningStateFailed ConsoleProvisioningState = "Failed" + ConsoleProvisioningStateProvisioning ConsoleProvisioningState = "Provisioning" + ConsoleProvisioningStateSucceeded ConsoleProvisioningState = "Succeeded" +) + +func PossibleValuesForConsoleProvisioningState() []string { + return []string{ + string(ConsoleProvisioningStateAccepted), + string(ConsoleProvisioningStateCanceled), + string(ConsoleProvisioningStateFailed), + string(ConsoleProvisioningStateProvisioning), + string(ConsoleProvisioningStateSucceeded), + } +} + +func (s *ConsoleProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConsoleProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConsoleProvisioningState(input string) (*ConsoleProvisioningState, error) { + vals := map[string]ConsoleProvisioningState{ + "accepted": ConsoleProvisioningStateAccepted, + "canceled": ConsoleProvisioningStateCanceled, + "failed": ConsoleProvisioningStateFailed, + "provisioning": ConsoleProvisioningStateProvisioning, + "succeeded": ConsoleProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConsoleProvisioningState(input) + return &out, nil +} + +type ControlImpact string + +const ( + ControlImpactFalse ControlImpact = "False" + ControlImpactTrue ControlImpact = "True" +) + +func PossibleValuesForControlImpact() []string { + return []string{ + string(ControlImpactFalse), + string(ControlImpactTrue), + } +} + +func (s *ControlImpact) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseControlImpact(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseControlImpact(input string) (*ControlImpact, error) { + vals := map[string]ControlImpact{ + "false": ControlImpactFalse, + "true": ControlImpactTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ControlImpact(input) + return &out, nil +} + +type DefaultGateway string + +const ( + DefaultGatewayFalse DefaultGateway = "False" + DefaultGatewayTrue DefaultGateway = "True" +) + +func PossibleValuesForDefaultGateway() []string { + return []string{ + string(DefaultGatewayFalse), + string(DefaultGatewayTrue), + } +} + +func (s *DefaultGateway) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultGateway(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultGateway(input string) (*DefaultGateway, error) { + vals := map[string]DefaultGateway{ + "false": DefaultGatewayFalse, + "true": DefaultGatewayTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultGateway(input) + return &out, nil +} + +type DeviceConnectionType string + +const ( + DeviceConnectionTypePCI DeviceConnectionType = "PCI" +) + +func PossibleValuesForDeviceConnectionType() []string { + return []string{ + string(DeviceConnectionTypePCI), + } +} + +func (s *DeviceConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeviceConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeviceConnectionType(input string) (*DeviceConnectionType, error) { + vals := map[string]DeviceConnectionType{ + "pci": DeviceConnectionTypePCI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeviceConnectionType(input) + return &out, nil +} + +type DiskType string + +const ( + DiskTypeHDD DiskType = "HDD" + DiskTypeSSD DiskType = "SSD" +) + +func PossibleValuesForDiskType() []string { + return []string{ + string(DiskTypeHDD), + string(DiskTypeSSD), + } +} + +func (s *DiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskType(input string) (*DiskType, error) { + vals := map[string]DiskType{ + "hdd": DiskTypeHDD, + "ssd": DiskTypeSSD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskType(input) + return &out, nil +} + +type FabricPeeringEnabled string + +const ( + FabricPeeringEnabledFalse FabricPeeringEnabled = "False" + FabricPeeringEnabledTrue FabricPeeringEnabled = "True" +) + +func PossibleValuesForFabricPeeringEnabled() []string { + return []string{ + string(FabricPeeringEnabledFalse), + string(FabricPeeringEnabledTrue), + } +} + +func (s *FabricPeeringEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFabricPeeringEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFabricPeeringEnabled(input string) (*FabricPeeringEnabled, error) { + vals := map[string]FabricPeeringEnabled{ + "false": FabricPeeringEnabledFalse, + "true": FabricPeeringEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FabricPeeringEnabled(input) + return &out, nil +} + +type FeatureDetailedStatus string + +const ( + FeatureDetailedStatusFailed FeatureDetailedStatus = "Failed" + FeatureDetailedStatusRunning FeatureDetailedStatus = "Running" + FeatureDetailedStatusUnknown FeatureDetailedStatus = "Unknown" +) + +func PossibleValuesForFeatureDetailedStatus() []string { + return []string{ + string(FeatureDetailedStatusFailed), + string(FeatureDetailedStatusRunning), + string(FeatureDetailedStatusUnknown), + } +} + +func (s *FeatureDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureDetailedStatus(input string) (*FeatureDetailedStatus, error) { + vals := map[string]FeatureDetailedStatus{ + "failed": FeatureDetailedStatusFailed, + "running": FeatureDetailedStatusRunning, + "unknown": FeatureDetailedStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureDetailedStatus(input) + return &out, nil +} + +type HugepagesSize string + +const ( + HugepagesSizeOneG HugepagesSize = "1G" + HugepagesSizeTwoM HugepagesSize = "2M" +) + +func PossibleValuesForHugepagesSize() []string { + return []string{ + string(HugepagesSizeOneG), + string(HugepagesSizeTwoM), + } +} + +func (s *HugepagesSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHugepagesSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHugepagesSize(input string) (*HugepagesSize, error) { + vals := map[string]HugepagesSize{ + "1g": HugepagesSizeOneG, + "2m": HugepagesSizeTwoM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HugepagesSize(input) + return &out, nil +} + +type HybridAksIPamEnabled string + +const ( + HybridAksIPamEnabledFalse HybridAksIPamEnabled = "False" + HybridAksIPamEnabledTrue HybridAksIPamEnabled = "True" +) + +func PossibleValuesForHybridAksIPamEnabled() []string { + return []string{ + string(HybridAksIPamEnabledFalse), + string(HybridAksIPamEnabledTrue), + } +} + +func (s *HybridAksIPamEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHybridAksIPamEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHybridAksIPamEnabled(input string) (*HybridAksIPamEnabled, error) { + vals := map[string]HybridAksIPamEnabled{ + "false": HybridAksIPamEnabledFalse, + "true": HybridAksIPamEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HybridAksIPamEnabled(input) + return &out, nil +} + +type HybridAksPluginType string + +const ( + HybridAksPluginTypeDPDK HybridAksPluginType = "DPDK" + HybridAksPluginTypeOSDevice HybridAksPluginType = "OSDevice" + HybridAksPluginTypeSRIOV HybridAksPluginType = "SRIOV" +) + +func PossibleValuesForHybridAksPluginType() []string { + return []string{ + string(HybridAksPluginTypeDPDK), + string(HybridAksPluginTypeOSDevice), + string(HybridAksPluginTypeSRIOV), + } +} + +func (s *HybridAksPluginType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHybridAksPluginType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHybridAksPluginType(input string) (*HybridAksPluginType, error) { + vals := map[string]HybridAksPluginType{ + "dpdk": HybridAksPluginTypeDPDK, + "osdevice": HybridAksPluginTypeOSDevice, + "sriov": HybridAksPluginTypeSRIOV, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HybridAksPluginType(input) + return &out, nil +} + +type IPAllocationType string + +const ( + IPAllocationTypeDualStack IPAllocationType = "DualStack" + IPAllocationTypeIPVFour IPAllocationType = "IPV4" + IPAllocationTypeIPVSix IPAllocationType = "IPV6" +) + +func PossibleValuesForIPAllocationType() []string { + return []string{ + string(IPAllocationTypeDualStack), + string(IPAllocationTypeIPVFour), + string(IPAllocationTypeIPVSix), + } +} + +func (s *IPAllocationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationType(input string) (*IPAllocationType, error) { + vals := map[string]IPAllocationType{ + "dualstack": IPAllocationTypeDualStack, + "ipv4": IPAllocationTypeIPVFour, + "ipv6": IPAllocationTypeIPVSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationType(input) + return &out, nil +} + +type KubernetesClusterDetailedStatus string + +const ( + KubernetesClusterDetailedStatusAvailable KubernetesClusterDetailedStatus = "Available" + KubernetesClusterDetailedStatusError KubernetesClusterDetailedStatus = "Error" + KubernetesClusterDetailedStatusProvisioning KubernetesClusterDetailedStatus = "Provisioning" +) + +func PossibleValuesForKubernetesClusterDetailedStatus() []string { + return []string{ + string(KubernetesClusterDetailedStatusAvailable), + string(KubernetesClusterDetailedStatusError), + string(KubernetesClusterDetailedStatusProvisioning), + } +} + +func (s *KubernetesClusterDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterDetailedStatus(input string) (*KubernetesClusterDetailedStatus, error) { + vals := map[string]KubernetesClusterDetailedStatus{ + "available": KubernetesClusterDetailedStatusAvailable, + "error": KubernetesClusterDetailedStatusError, + "provisioning": KubernetesClusterDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterDetailedStatus(input) + return &out, nil +} + +type KubernetesClusterFeatureAvailabilityLifecycle string + +const ( + KubernetesClusterFeatureAvailabilityLifecycleGenerallyAvailable KubernetesClusterFeatureAvailabilityLifecycle = "GenerallyAvailable" + KubernetesClusterFeatureAvailabilityLifecyclePreview KubernetesClusterFeatureAvailabilityLifecycle = "Preview" +) + +func PossibleValuesForKubernetesClusterFeatureAvailabilityLifecycle() []string { + return []string{ + string(KubernetesClusterFeatureAvailabilityLifecycleGenerallyAvailable), + string(KubernetesClusterFeatureAvailabilityLifecyclePreview), + } +} + +func (s *KubernetesClusterFeatureAvailabilityLifecycle) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterFeatureAvailabilityLifecycle(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterFeatureAvailabilityLifecycle(input string) (*KubernetesClusterFeatureAvailabilityLifecycle, error) { + vals := map[string]KubernetesClusterFeatureAvailabilityLifecycle{ + "generallyavailable": KubernetesClusterFeatureAvailabilityLifecycleGenerallyAvailable, + "preview": KubernetesClusterFeatureAvailabilityLifecyclePreview, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterFeatureAvailabilityLifecycle(input) + return &out, nil +} + +type KubernetesClusterFeatureDetailedStatus string + +const ( + KubernetesClusterFeatureDetailedStatusError KubernetesClusterFeatureDetailedStatus = "Error" + KubernetesClusterFeatureDetailedStatusInstalled KubernetesClusterFeatureDetailedStatus = "Installed" + KubernetesClusterFeatureDetailedStatusProvisioning KubernetesClusterFeatureDetailedStatus = "Provisioning" +) + +func PossibleValuesForKubernetesClusterFeatureDetailedStatus() []string { + return []string{ + string(KubernetesClusterFeatureDetailedStatusError), + string(KubernetesClusterFeatureDetailedStatusInstalled), + string(KubernetesClusterFeatureDetailedStatusProvisioning), + } +} + +func (s *KubernetesClusterFeatureDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterFeatureDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterFeatureDetailedStatus(input string) (*KubernetesClusterFeatureDetailedStatus, error) { + vals := map[string]KubernetesClusterFeatureDetailedStatus{ + "error": KubernetesClusterFeatureDetailedStatusError, + "installed": KubernetesClusterFeatureDetailedStatusInstalled, + "provisioning": KubernetesClusterFeatureDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterFeatureDetailedStatus(input) + return &out, nil +} + +type KubernetesClusterFeatureProvisioningState string + +const ( + KubernetesClusterFeatureProvisioningStateAccepted KubernetesClusterFeatureProvisioningState = "Accepted" + KubernetesClusterFeatureProvisioningStateCanceled KubernetesClusterFeatureProvisioningState = "Canceled" + KubernetesClusterFeatureProvisioningStateDeleting KubernetesClusterFeatureProvisioningState = "Deleting" + KubernetesClusterFeatureProvisioningStateFailed KubernetesClusterFeatureProvisioningState = "Failed" + KubernetesClusterFeatureProvisioningStateSucceeded KubernetesClusterFeatureProvisioningState = "Succeeded" + KubernetesClusterFeatureProvisioningStateUpdating KubernetesClusterFeatureProvisioningState = "Updating" +) + +func PossibleValuesForKubernetesClusterFeatureProvisioningState() []string { + return []string{ + string(KubernetesClusterFeatureProvisioningStateAccepted), + string(KubernetesClusterFeatureProvisioningStateCanceled), + string(KubernetesClusterFeatureProvisioningStateDeleting), + string(KubernetesClusterFeatureProvisioningStateFailed), + string(KubernetesClusterFeatureProvisioningStateSucceeded), + string(KubernetesClusterFeatureProvisioningStateUpdating), + } +} + +func (s *KubernetesClusterFeatureProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterFeatureProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterFeatureProvisioningState(input string) (*KubernetesClusterFeatureProvisioningState, error) { + vals := map[string]KubernetesClusterFeatureProvisioningState{ + "accepted": KubernetesClusterFeatureProvisioningStateAccepted, + "canceled": KubernetesClusterFeatureProvisioningStateCanceled, + "deleting": KubernetesClusterFeatureProvisioningStateDeleting, + "failed": KubernetesClusterFeatureProvisioningStateFailed, + "succeeded": KubernetesClusterFeatureProvisioningStateSucceeded, + "updating": KubernetesClusterFeatureProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterFeatureProvisioningState(input) + return &out, nil +} + +type KubernetesClusterFeatureRequired string + +const ( + KubernetesClusterFeatureRequiredFalse KubernetesClusterFeatureRequired = "False" + KubernetesClusterFeatureRequiredTrue KubernetesClusterFeatureRequired = "True" +) + +func PossibleValuesForKubernetesClusterFeatureRequired() []string { + return []string{ + string(KubernetesClusterFeatureRequiredFalse), + string(KubernetesClusterFeatureRequiredTrue), + } +} + +func (s *KubernetesClusterFeatureRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterFeatureRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterFeatureRequired(input string) (*KubernetesClusterFeatureRequired, error) { + vals := map[string]KubernetesClusterFeatureRequired{ + "false": KubernetesClusterFeatureRequiredFalse, + "true": KubernetesClusterFeatureRequiredTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterFeatureRequired(input) + return &out, nil +} + +type KubernetesClusterNodeDetailedStatus string + +const ( + KubernetesClusterNodeDetailedStatusAvailable KubernetesClusterNodeDetailedStatus = "Available" + KubernetesClusterNodeDetailedStatusError KubernetesClusterNodeDetailedStatus = "Error" + KubernetesClusterNodeDetailedStatusProvisioning KubernetesClusterNodeDetailedStatus = "Provisioning" + KubernetesClusterNodeDetailedStatusRunning KubernetesClusterNodeDetailedStatus = "Running" + KubernetesClusterNodeDetailedStatusScheduling KubernetesClusterNodeDetailedStatus = "Scheduling" + KubernetesClusterNodeDetailedStatusStopped KubernetesClusterNodeDetailedStatus = "Stopped" + KubernetesClusterNodeDetailedStatusTerminating KubernetesClusterNodeDetailedStatus = "Terminating" + KubernetesClusterNodeDetailedStatusUnknown KubernetesClusterNodeDetailedStatus = "Unknown" +) + +func PossibleValuesForKubernetesClusterNodeDetailedStatus() []string { + return []string{ + string(KubernetesClusterNodeDetailedStatusAvailable), + string(KubernetesClusterNodeDetailedStatusError), + string(KubernetesClusterNodeDetailedStatusProvisioning), + string(KubernetesClusterNodeDetailedStatusRunning), + string(KubernetesClusterNodeDetailedStatusScheduling), + string(KubernetesClusterNodeDetailedStatusStopped), + string(KubernetesClusterNodeDetailedStatusTerminating), + string(KubernetesClusterNodeDetailedStatusUnknown), + } +} + +func (s *KubernetesClusterNodeDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterNodeDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterNodeDetailedStatus(input string) (*KubernetesClusterNodeDetailedStatus, error) { + vals := map[string]KubernetesClusterNodeDetailedStatus{ + "available": KubernetesClusterNodeDetailedStatusAvailable, + "error": KubernetesClusterNodeDetailedStatusError, + "provisioning": KubernetesClusterNodeDetailedStatusProvisioning, + "running": KubernetesClusterNodeDetailedStatusRunning, + "scheduling": KubernetesClusterNodeDetailedStatusScheduling, + "stopped": KubernetesClusterNodeDetailedStatusStopped, + "terminating": KubernetesClusterNodeDetailedStatusTerminating, + "unknown": KubernetesClusterNodeDetailedStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterNodeDetailedStatus(input) + return &out, nil +} + +type KubernetesClusterProvisioningState string + +const ( + KubernetesClusterProvisioningStateAccepted KubernetesClusterProvisioningState = "Accepted" + KubernetesClusterProvisioningStateCanceled KubernetesClusterProvisioningState = "Canceled" + KubernetesClusterProvisioningStateCreated KubernetesClusterProvisioningState = "Created" + KubernetesClusterProvisioningStateDeleting KubernetesClusterProvisioningState = "Deleting" + KubernetesClusterProvisioningStateFailed KubernetesClusterProvisioningState = "Failed" + KubernetesClusterProvisioningStateInProgress KubernetesClusterProvisioningState = "InProgress" + KubernetesClusterProvisioningStateSucceeded KubernetesClusterProvisioningState = "Succeeded" + KubernetesClusterProvisioningStateUpdating KubernetesClusterProvisioningState = "Updating" +) + +func PossibleValuesForKubernetesClusterProvisioningState() []string { + return []string{ + string(KubernetesClusterProvisioningStateAccepted), + string(KubernetesClusterProvisioningStateCanceled), + string(KubernetesClusterProvisioningStateCreated), + string(KubernetesClusterProvisioningStateDeleting), + string(KubernetesClusterProvisioningStateFailed), + string(KubernetesClusterProvisioningStateInProgress), + string(KubernetesClusterProvisioningStateSucceeded), + string(KubernetesClusterProvisioningStateUpdating), + } +} + +func (s *KubernetesClusterProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesClusterProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesClusterProvisioningState(input string) (*KubernetesClusterProvisioningState, error) { + vals := map[string]KubernetesClusterProvisioningState{ + "accepted": KubernetesClusterProvisioningStateAccepted, + "canceled": KubernetesClusterProvisioningStateCanceled, + "created": KubernetesClusterProvisioningStateCreated, + "deleting": KubernetesClusterProvisioningStateDeleting, + "failed": KubernetesClusterProvisioningStateFailed, + "inprogress": KubernetesClusterProvisioningStateInProgress, + "succeeded": KubernetesClusterProvisioningStateSucceeded, + "updating": KubernetesClusterProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesClusterProvisioningState(input) + return &out, nil +} + +type KubernetesNodePowerState string + +const ( + KubernetesNodePowerStateOff KubernetesNodePowerState = "Off" + KubernetesNodePowerStateOn KubernetesNodePowerState = "On" + KubernetesNodePowerStateUnknown KubernetesNodePowerState = "Unknown" +) + +func PossibleValuesForKubernetesNodePowerState() []string { + return []string{ + string(KubernetesNodePowerStateOff), + string(KubernetesNodePowerStateOn), + string(KubernetesNodePowerStateUnknown), + } +} + +func (s *KubernetesNodePowerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesNodePowerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesNodePowerState(input string) (*KubernetesNodePowerState, error) { + vals := map[string]KubernetesNodePowerState{ + "off": KubernetesNodePowerStateOff, + "on": KubernetesNodePowerStateOn, + "unknown": KubernetesNodePowerStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesNodePowerState(input) + return &out, nil +} + +type KubernetesNodeRole string + +const ( + KubernetesNodeRoleControlPlane KubernetesNodeRole = "ControlPlane" + KubernetesNodeRoleWorker KubernetesNodeRole = "Worker" +) + +func PossibleValuesForKubernetesNodeRole() []string { + return []string{ + string(KubernetesNodeRoleControlPlane), + string(KubernetesNodeRoleWorker), + } +} + +func (s *KubernetesNodeRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesNodeRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesNodeRole(input string) (*KubernetesNodeRole, error) { + vals := map[string]KubernetesNodeRole{ + "controlplane": KubernetesNodeRoleControlPlane, + "worker": KubernetesNodeRoleWorker, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesNodeRole(input) + return &out, nil +} + +type KubernetesPluginType string + +const ( + KubernetesPluginTypeDPDK KubernetesPluginType = "DPDK" + KubernetesPluginTypeIPVLAN KubernetesPluginType = "IPVLAN" + KubernetesPluginTypeMACVLAN KubernetesPluginType = "MACVLAN" + KubernetesPluginTypeOSDevice KubernetesPluginType = "OSDevice" + KubernetesPluginTypeSRIOV KubernetesPluginType = "SRIOV" +) + +func PossibleValuesForKubernetesPluginType() []string { + return []string{ + string(KubernetesPluginTypeDPDK), + string(KubernetesPluginTypeIPVLAN), + string(KubernetesPluginTypeMACVLAN), + string(KubernetesPluginTypeOSDevice), + string(KubernetesPluginTypeSRIOV), + } +} + +func (s *KubernetesPluginType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesPluginType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesPluginType(input string) (*KubernetesPluginType, error) { + vals := map[string]KubernetesPluginType{ + "dpdk": KubernetesPluginTypeDPDK, + "ipvlan": KubernetesPluginTypeIPVLAN, + "macvlan": KubernetesPluginTypeMACVLAN, + "osdevice": KubernetesPluginTypeOSDevice, + "sriov": KubernetesPluginTypeSRIOV, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesPluginType(input) + return &out, nil +} + +type L2NetworkDetailedStatus string + +const ( + L2NetworkDetailedStatusAvailable L2NetworkDetailedStatus = "Available" + L2NetworkDetailedStatusError L2NetworkDetailedStatus = "Error" + L2NetworkDetailedStatusProvisioning L2NetworkDetailedStatus = "Provisioning" +) + +func PossibleValuesForL2NetworkDetailedStatus() []string { + return []string{ + string(L2NetworkDetailedStatusAvailable), + string(L2NetworkDetailedStatusError), + string(L2NetworkDetailedStatusProvisioning), + } +} + +func (s *L2NetworkDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseL2NetworkDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseL2NetworkDetailedStatus(input string) (*L2NetworkDetailedStatus, error) { + vals := map[string]L2NetworkDetailedStatus{ + "available": L2NetworkDetailedStatusAvailable, + "error": L2NetworkDetailedStatusError, + "provisioning": L2NetworkDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := L2NetworkDetailedStatus(input) + return &out, nil +} + +type L2NetworkProvisioningState string + +const ( + L2NetworkProvisioningStateAccepted L2NetworkProvisioningState = "Accepted" + L2NetworkProvisioningStateCanceled L2NetworkProvisioningState = "Canceled" + L2NetworkProvisioningStateFailed L2NetworkProvisioningState = "Failed" + L2NetworkProvisioningStateProvisioning L2NetworkProvisioningState = "Provisioning" + L2NetworkProvisioningStateSucceeded L2NetworkProvisioningState = "Succeeded" +) + +func PossibleValuesForL2NetworkProvisioningState() []string { + return []string{ + string(L2NetworkProvisioningStateAccepted), + string(L2NetworkProvisioningStateCanceled), + string(L2NetworkProvisioningStateFailed), + string(L2NetworkProvisioningStateProvisioning), + string(L2NetworkProvisioningStateSucceeded), + } +} + +func (s *L2NetworkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseL2NetworkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseL2NetworkProvisioningState(input string) (*L2NetworkProvisioningState, error) { + vals := map[string]L2NetworkProvisioningState{ + "accepted": L2NetworkProvisioningStateAccepted, + "canceled": L2NetworkProvisioningStateCanceled, + "failed": L2NetworkProvisioningStateFailed, + "provisioning": L2NetworkProvisioningStateProvisioning, + "succeeded": L2NetworkProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := L2NetworkProvisioningState(input) + return &out, nil +} + +type L3NetworkConfigurationIPamEnabled string + +const ( + L3NetworkConfigurationIPamEnabledFalse L3NetworkConfigurationIPamEnabled = "False" + L3NetworkConfigurationIPamEnabledTrue L3NetworkConfigurationIPamEnabled = "True" +) + +func PossibleValuesForL3NetworkConfigurationIPamEnabled() []string { + return []string{ + string(L3NetworkConfigurationIPamEnabledFalse), + string(L3NetworkConfigurationIPamEnabledTrue), + } +} + +func (s *L3NetworkConfigurationIPamEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseL3NetworkConfigurationIPamEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseL3NetworkConfigurationIPamEnabled(input string) (*L3NetworkConfigurationIPamEnabled, error) { + vals := map[string]L3NetworkConfigurationIPamEnabled{ + "false": L3NetworkConfigurationIPamEnabledFalse, + "true": L3NetworkConfigurationIPamEnabledTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := L3NetworkConfigurationIPamEnabled(input) + return &out, nil +} + +type L3NetworkDetailedStatus string + +const ( + L3NetworkDetailedStatusAvailable L3NetworkDetailedStatus = "Available" + L3NetworkDetailedStatusError L3NetworkDetailedStatus = "Error" + L3NetworkDetailedStatusProvisioning L3NetworkDetailedStatus = "Provisioning" +) + +func PossibleValuesForL3NetworkDetailedStatus() []string { + return []string{ + string(L3NetworkDetailedStatusAvailable), + string(L3NetworkDetailedStatusError), + string(L3NetworkDetailedStatusProvisioning), + } +} + +func (s *L3NetworkDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseL3NetworkDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseL3NetworkDetailedStatus(input string) (*L3NetworkDetailedStatus, error) { + vals := map[string]L3NetworkDetailedStatus{ + "available": L3NetworkDetailedStatusAvailable, + "error": L3NetworkDetailedStatusError, + "provisioning": L3NetworkDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := L3NetworkDetailedStatus(input) + return &out, nil +} + +type L3NetworkProvisioningState string + +const ( + L3NetworkProvisioningStateAccepted L3NetworkProvisioningState = "Accepted" + L3NetworkProvisioningStateCanceled L3NetworkProvisioningState = "Canceled" + L3NetworkProvisioningStateFailed L3NetworkProvisioningState = "Failed" + L3NetworkProvisioningStateProvisioning L3NetworkProvisioningState = "Provisioning" + L3NetworkProvisioningStateSucceeded L3NetworkProvisioningState = "Succeeded" +) + +func PossibleValuesForL3NetworkProvisioningState() []string { + return []string{ + string(L3NetworkProvisioningStateAccepted), + string(L3NetworkProvisioningStateCanceled), + string(L3NetworkProvisioningStateFailed), + string(L3NetworkProvisioningStateProvisioning), + string(L3NetworkProvisioningStateSucceeded), + } +} + +func (s *L3NetworkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseL3NetworkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseL3NetworkProvisioningState(input string) (*L3NetworkProvisioningState, error) { + vals := map[string]L3NetworkProvisioningState{ + "accepted": L3NetworkProvisioningStateAccepted, + "canceled": L3NetworkProvisioningStateCanceled, + "failed": L3NetworkProvisioningStateFailed, + "provisioning": L3NetworkProvisioningStateProvisioning, + "succeeded": L3NetworkProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := L3NetworkProvisioningState(input) + return &out, nil +} + +type MachineSkuDiskConnectionType string + +const ( + MachineSkuDiskConnectionTypePCIE MachineSkuDiskConnectionType = "PCIE" + MachineSkuDiskConnectionTypeRAID MachineSkuDiskConnectionType = "RAID" + MachineSkuDiskConnectionTypeSAS MachineSkuDiskConnectionType = "SAS" + MachineSkuDiskConnectionTypeSATA MachineSkuDiskConnectionType = "SATA" +) + +func PossibleValuesForMachineSkuDiskConnectionType() []string { + return []string{ + string(MachineSkuDiskConnectionTypePCIE), + string(MachineSkuDiskConnectionTypeRAID), + string(MachineSkuDiskConnectionTypeSAS), + string(MachineSkuDiskConnectionTypeSATA), + } +} + +func (s *MachineSkuDiskConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMachineSkuDiskConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMachineSkuDiskConnectionType(input string) (*MachineSkuDiskConnectionType, error) { + vals := map[string]MachineSkuDiskConnectionType{ + "pcie": MachineSkuDiskConnectionTypePCIE, + "raid": MachineSkuDiskConnectionTypeRAID, + "sas": MachineSkuDiskConnectionTypeSAS, + "sata": MachineSkuDiskConnectionTypeSATA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MachineSkuDiskConnectionType(input) + return &out, nil +} + +type ManagedServiceIdentitySelectorType string + +const ( + ManagedServiceIdentitySelectorTypeSystemAssignedIdentity ManagedServiceIdentitySelectorType = "SystemAssignedIdentity" + ManagedServiceIdentitySelectorTypeUserAssignedIdentity ManagedServiceIdentitySelectorType = "UserAssignedIdentity" +) + +func PossibleValuesForManagedServiceIdentitySelectorType() []string { + return []string{ + string(ManagedServiceIdentitySelectorTypeSystemAssignedIdentity), + string(ManagedServiceIdentitySelectorTypeUserAssignedIdentity), + } +} + +func (s *ManagedServiceIdentitySelectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentitySelectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServiceIdentitySelectorType(input string) (*ManagedServiceIdentitySelectorType, error) { + vals := map[string]ManagedServiceIdentitySelectorType{ + "systemassignedidentity": ManagedServiceIdentitySelectorTypeSystemAssignedIdentity, + "userassignedidentity": ManagedServiceIdentitySelectorTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentitySelectorType(input) + return &out, nil +} + +type OsDiskCreateOption string + +const ( + OsDiskCreateOptionEphemeral OsDiskCreateOption = "Ephemeral" +) + +func PossibleValuesForOsDiskCreateOption() []string { + return []string{ + string(OsDiskCreateOptionEphemeral), + } +} + +func (s *OsDiskCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsDiskCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOsDiskCreateOption(input string) (*OsDiskCreateOption, error) { + vals := map[string]OsDiskCreateOption{ + "ephemeral": OsDiskCreateOptionEphemeral, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OsDiskCreateOption(input) + return &out, nil +} + +type OsDiskDeleteOption string + +const ( + OsDiskDeleteOptionDelete OsDiskDeleteOption = "Delete" +) + +func PossibleValuesForOsDiskDeleteOption() []string { + return []string{ + string(OsDiskDeleteOptionDelete), + } +} + +func (s *OsDiskDeleteOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsDiskDeleteOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOsDiskDeleteOption(input string) (*OsDiskDeleteOption, error) { + vals := map[string]OsDiskDeleteOption{ + "delete": OsDiskDeleteOptionDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OsDiskDeleteOption(input) + return &out, nil +} + +type RackDetailedStatus string + +const ( + RackDetailedStatusAvailable RackDetailedStatus = "Available" + RackDetailedStatusError RackDetailedStatus = "Error" + RackDetailedStatusProvisioning RackDetailedStatus = "Provisioning" +) + +func PossibleValuesForRackDetailedStatus() []string { + return []string{ + string(RackDetailedStatusAvailable), + string(RackDetailedStatusError), + string(RackDetailedStatusProvisioning), + } +} + +func (s *RackDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRackDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRackDetailedStatus(input string) (*RackDetailedStatus, error) { + vals := map[string]RackDetailedStatus{ + "available": RackDetailedStatusAvailable, + "error": RackDetailedStatusError, + "provisioning": RackDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RackDetailedStatus(input) + return &out, nil +} + +type RackProvisioningState string + +const ( + RackProvisioningStateAccepted RackProvisioningState = "Accepted" + RackProvisioningStateCanceled RackProvisioningState = "Canceled" + RackProvisioningStateFailed RackProvisioningState = "Failed" + RackProvisioningStateProvisioning RackProvisioningState = "Provisioning" + RackProvisioningStateSucceeded RackProvisioningState = "Succeeded" +) + +func PossibleValuesForRackProvisioningState() []string { + return []string{ + string(RackProvisioningStateAccepted), + string(RackProvisioningStateCanceled), + string(RackProvisioningStateFailed), + string(RackProvisioningStateProvisioning), + string(RackProvisioningStateSucceeded), + } +} + +func (s *RackProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRackProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRackProvisioningState(input string) (*RackProvisioningState, error) { + vals := map[string]RackProvisioningState{ + "accepted": RackProvisioningStateAccepted, + "canceled": RackProvisioningStateCanceled, + "failed": RackProvisioningStateFailed, + "provisioning": RackProvisioningStateProvisioning, + "succeeded": RackProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RackProvisioningState(input) + return &out, nil +} + +type RackSkuProvisioningState string + +const ( + RackSkuProvisioningStateCanceled RackSkuProvisioningState = "Canceled" + RackSkuProvisioningStateFailed RackSkuProvisioningState = "Failed" + RackSkuProvisioningStateSucceeded RackSkuProvisioningState = "Succeeded" +) + +func PossibleValuesForRackSkuProvisioningState() []string { + return []string{ + string(RackSkuProvisioningStateCanceled), + string(RackSkuProvisioningStateFailed), + string(RackSkuProvisioningStateSucceeded), + } +} + +func (s *RackSkuProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRackSkuProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRackSkuProvisioningState(input string) (*RackSkuProvisioningState, error) { + vals := map[string]RackSkuProvisioningState{ + "canceled": RackSkuProvisioningStateCanceled, + "failed": RackSkuProvisioningStateFailed, + "succeeded": RackSkuProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RackSkuProvisioningState(input) + return &out, nil +} + +type RackSkuType string + +const ( + RackSkuTypeAggregator RackSkuType = "Aggregator" + RackSkuTypeCompute RackSkuType = "Compute" + RackSkuTypeSingle RackSkuType = "Single" +) + +func PossibleValuesForRackSkuType() []string { + return []string{ + string(RackSkuTypeAggregator), + string(RackSkuTypeCompute), + string(RackSkuTypeSingle), + } +} + +func (s *RackSkuType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRackSkuType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRackSkuType(input string) (*RackSkuType, error) { + vals := map[string]RackSkuType{ + "aggregator": RackSkuTypeAggregator, + "compute": RackSkuTypeCompute, + "single": RackSkuTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RackSkuType(input) + return &out, nil +} + +type RemoteVendorManagementFeature string + +const ( + RemoteVendorManagementFeatureSupported RemoteVendorManagementFeature = "Supported" + RemoteVendorManagementFeatureUnsupported RemoteVendorManagementFeature = "Unsupported" +) + +func PossibleValuesForRemoteVendorManagementFeature() []string { + return []string{ + string(RemoteVendorManagementFeatureSupported), + string(RemoteVendorManagementFeatureUnsupported), + } +} + +func (s *RemoteVendorManagementFeature) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteVendorManagementFeature(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteVendorManagementFeature(input string) (*RemoteVendorManagementFeature, error) { + vals := map[string]RemoteVendorManagementFeature{ + "supported": RemoteVendorManagementFeatureSupported, + "unsupported": RemoteVendorManagementFeatureUnsupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteVendorManagementFeature(input) + return &out, nil +} + +type RemoteVendorManagementStatus string + +const ( + RemoteVendorManagementStatusDisabled RemoteVendorManagementStatus = "Disabled" + RemoteVendorManagementStatusEnabled RemoteVendorManagementStatus = "Enabled" + RemoteVendorManagementStatusUnsupported RemoteVendorManagementStatus = "Unsupported" +) + +func PossibleValuesForRemoteVendorManagementStatus() []string { + return []string{ + string(RemoteVendorManagementStatusDisabled), + string(RemoteVendorManagementStatusEnabled), + string(RemoteVendorManagementStatusUnsupported), + } +} + +func (s *RemoteVendorManagementStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteVendorManagementStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteVendorManagementStatus(input string) (*RemoteVendorManagementStatus, error) { + vals := map[string]RemoteVendorManagementStatus{ + "disabled": RemoteVendorManagementStatusDisabled, + "enabled": RemoteVendorManagementStatusEnabled, + "unsupported": RemoteVendorManagementStatusUnsupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteVendorManagementStatus(input) + return &out, nil +} + +type RuntimeProtectionEnforcementLevel string + +const ( + RuntimeProtectionEnforcementLevelAudit RuntimeProtectionEnforcementLevel = "Audit" + RuntimeProtectionEnforcementLevelDisabled RuntimeProtectionEnforcementLevel = "Disabled" + RuntimeProtectionEnforcementLevelOnDemand RuntimeProtectionEnforcementLevel = "OnDemand" + RuntimeProtectionEnforcementLevelPassive RuntimeProtectionEnforcementLevel = "Passive" + RuntimeProtectionEnforcementLevelRealTime RuntimeProtectionEnforcementLevel = "RealTime" +) + +func PossibleValuesForRuntimeProtectionEnforcementLevel() []string { + return []string{ + string(RuntimeProtectionEnforcementLevelAudit), + string(RuntimeProtectionEnforcementLevelDisabled), + string(RuntimeProtectionEnforcementLevelOnDemand), + string(RuntimeProtectionEnforcementLevelPassive), + string(RuntimeProtectionEnforcementLevelRealTime), + } +} + +func (s *RuntimeProtectionEnforcementLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeProtectionEnforcementLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeProtectionEnforcementLevel(input string) (*RuntimeProtectionEnforcementLevel, error) { + vals := map[string]RuntimeProtectionEnforcementLevel{ + "audit": RuntimeProtectionEnforcementLevelAudit, + "disabled": RuntimeProtectionEnforcementLevelDisabled, + "ondemand": RuntimeProtectionEnforcementLevelOnDemand, + "passive": RuntimeProtectionEnforcementLevelPassive, + "realtime": RuntimeProtectionEnforcementLevelRealTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeProtectionEnforcementLevel(input) + return &out, nil +} + +type SkipShutdown string + +const ( + SkipShutdownFalse SkipShutdown = "False" + SkipShutdownTrue SkipShutdown = "True" +) + +func PossibleValuesForSkipShutdown() []string { + return []string{ + string(SkipShutdownFalse), + string(SkipShutdownTrue), + } +} + +func (s *SkipShutdown) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkipShutdown(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkipShutdown(input string) (*SkipShutdown, error) { + vals := map[string]SkipShutdown{ + "false": SkipShutdownFalse, + "true": SkipShutdownTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkipShutdown(input) + return &out, nil +} + +type StorageApplianceDetailedStatus string + +const ( + StorageApplianceDetailedStatusAvailable StorageApplianceDetailedStatus = "Available" + StorageApplianceDetailedStatusError StorageApplianceDetailedStatus = "Error" + StorageApplianceDetailedStatusProvisioning StorageApplianceDetailedStatus = "Provisioning" +) + +func PossibleValuesForStorageApplianceDetailedStatus() []string { + return []string{ + string(StorageApplianceDetailedStatusAvailable), + string(StorageApplianceDetailedStatusError), + string(StorageApplianceDetailedStatusProvisioning), + } +} + +func (s *StorageApplianceDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageApplianceDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageApplianceDetailedStatus(input string) (*StorageApplianceDetailedStatus, error) { + vals := map[string]StorageApplianceDetailedStatus{ + "available": StorageApplianceDetailedStatusAvailable, + "error": StorageApplianceDetailedStatusError, + "provisioning": StorageApplianceDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageApplianceDetailedStatus(input) + return &out, nil +} + +type StorageApplianceProvisioningState string + +const ( + StorageApplianceProvisioningStateAccepted StorageApplianceProvisioningState = "Accepted" + StorageApplianceProvisioningStateCanceled StorageApplianceProvisioningState = "Canceled" + StorageApplianceProvisioningStateFailed StorageApplianceProvisioningState = "Failed" + StorageApplianceProvisioningStateProvisioning StorageApplianceProvisioningState = "Provisioning" + StorageApplianceProvisioningStateSucceeded StorageApplianceProvisioningState = "Succeeded" +) + +func PossibleValuesForStorageApplianceProvisioningState() []string { + return []string{ + string(StorageApplianceProvisioningStateAccepted), + string(StorageApplianceProvisioningStateCanceled), + string(StorageApplianceProvisioningStateFailed), + string(StorageApplianceProvisioningStateProvisioning), + string(StorageApplianceProvisioningStateSucceeded), + } +} + +func (s *StorageApplianceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageApplianceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageApplianceProvisioningState(input string) (*StorageApplianceProvisioningState, error) { + vals := map[string]StorageApplianceProvisioningState{ + "accepted": StorageApplianceProvisioningStateAccepted, + "canceled": StorageApplianceProvisioningStateCanceled, + "failed": StorageApplianceProvisioningStateFailed, + "provisioning": StorageApplianceProvisioningStateProvisioning, + "succeeded": StorageApplianceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageApplianceProvisioningState(input) + return &out, nil +} + +type TrunkedNetworkDetailedStatus string + +const ( + TrunkedNetworkDetailedStatusAvailable TrunkedNetworkDetailedStatus = "Available" + TrunkedNetworkDetailedStatusError TrunkedNetworkDetailedStatus = "Error" + TrunkedNetworkDetailedStatusProvisioning TrunkedNetworkDetailedStatus = "Provisioning" +) + +func PossibleValuesForTrunkedNetworkDetailedStatus() []string { + return []string{ + string(TrunkedNetworkDetailedStatusAvailable), + string(TrunkedNetworkDetailedStatusError), + string(TrunkedNetworkDetailedStatusProvisioning), + } +} + +func (s *TrunkedNetworkDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrunkedNetworkDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrunkedNetworkDetailedStatus(input string) (*TrunkedNetworkDetailedStatus, error) { + vals := map[string]TrunkedNetworkDetailedStatus{ + "available": TrunkedNetworkDetailedStatusAvailable, + "error": TrunkedNetworkDetailedStatusError, + "provisioning": TrunkedNetworkDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrunkedNetworkDetailedStatus(input) + return &out, nil +} + +type TrunkedNetworkProvisioningState string + +const ( + TrunkedNetworkProvisioningStateAccepted TrunkedNetworkProvisioningState = "Accepted" + TrunkedNetworkProvisioningStateCanceled TrunkedNetworkProvisioningState = "Canceled" + TrunkedNetworkProvisioningStateFailed TrunkedNetworkProvisioningState = "Failed" + TrunkedNetworkProvisioningStateProvisioning TrunkedNetworkProvisioningState = "Provisioning" + TrunkedNetworkProvisioningStateSucceeded TrunkedNetworkProvisioningState = "Succeeded" +) + +func PossibleValuesForTrunkedNetworkProvisioningState() []string { + return []string{ + string(TrunkedNetworkProvisioningStateAccepted), + string(TrunkedNetworkProvisioningStateCanceled), + string(TrunkedNetworkProvisioningStateFailed), + string(TrunkedNetworkProvisioningStateProvisioning), + string(TrunkedNetworkProvisioningStateSucceeded), + } +} + +func (s *TrunkedNetworkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrunkedNetworkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrunkedNetworkProvisioningState(input string) (*TrunkedNetworkProvisioningState, error) { + vals := map[string]TrunkedNetworkProvisioningState{ + "accepted": TrunkedNetworkProvisioningStateAccepted, + "canceled": TrunkedNetworkProvisioningStateCanceled, + "failed": TrunkedNetworkProvisioningStateFailed, + "provisioning": TrunkedNetworkProvisioningStateProvisioning, + "succeeded": TrunkedNetworkProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrunkedNetworkProvisioningState(input) + return &out, nil +} + +type ValidationThresholdGrouping string + +const ( + ValidationThresholdGroupingPerCluster ValidationThresholdGrouping = "PerCluster" + ValidationThresholdGroupingPerRack ValidationThresholdGrouping = "PerRack" +) + +func PossibleValuesForValidationThresholdGrouping() []string { + return []string{ + string(ValidationThresholdGroupingPerCluster), + string(ValidationThresholdGroupingPerRack), + } +} + +func (s *ValidationThresholdGrouping) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationThresholdGrouping(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationThresholdGrouping(input string) (*ValidationThresholdGrouping, error) { + vals := map[string]ValidationThresholdGrouping{ + "percluster": ValidationThresholdGroupingPerCluster, + "perrack": ValidationThresholdGroupingPerRack, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationThresholdGrouping(input) + return &out, nil +} + +type ValidationThresholdType string + +const ( + ValidationThresholdTypeCountSuccess ValidationThresholdType = "CountSuccess" + ValidationThresholdTypePercentSuccess ValidationThresholdType = "PercentSuccess" +) + +func PossibleValuesForValidationThresholdType() []string { + return []string{ + string(ValidationThresholdTypeCountSuccess), + string(ValidationThresholdTypePercentSuccess), + } +} + +func (s *ValidationThresholdType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationThresholdType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationThresholdType(input string) (*ValidationThresholdType, error) { + vals := map[string]ValidationThresholdType{ + "countsuccess": ValidationThresholdTypeCountSuccess, + "percentsuccess": ValidationThresholdTypePercentSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationThresholdType(input) + return &out, nil +} + +type VirtualMachineBootMethod string + +const ( + VirtualMachineBootMethodBIOS VirtualMachineBootMethod = "BIOS" + VirtualMachineBootMethodUEFI VirtualMachineBootMethod = "UEFI" +) + +func PossibleValuesForVirtualMachineBootMethod() []string { + return []string{ + string(VirtualMachineBootMethodBIOS), + string(VirtualMachineBootMethodUEFI), + } +} + +func (s *VirtualMachineBootMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineBootMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineBootMethod(input string) (*VirtualMachineBootMethod, error) { + vals := map[string]VirtualMachineBootMethod{ + "bios": VirtualMachineBootMethodBIOS, + "uefi": VirtualMachineBootMethodUEFI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineBootMethod(input) + return &out, nil +} + +type VirtualMachineDetailedStatus string + +const ( + VirtualMachineDetailedStatusAvailable VirtualMachineDetailedStatus = "Available" + VirtualMachineDetailedStatusError VirtualMachineDetailedStatus = "Error" + VirtualMachineDetailedStatusProvisioning VirtualMachineDetailedStatus = "Provisioning" + VirtualMachineDetailedStatusRunning VirtualMachineDetailedStatus = "Running" + VirtualMachineDetailedStatusScheduling VirtualMachineDetailedStatus = "Scheduling" + VirtualMachineDetailedStatusStopped VirtualMachineDetailedStatus = "Stopped" + VirtualMachineDetailedStatusTerminating VirtualMachineDetailedStatus = "Terminating" + VirtualMachineDetailedStatusUnknown VirtualMachineDetailedStatus = "Unknown" +) + +func PossibleValuesForVirtualMachineDetailedStatus() []string { + return []string{ + string(VirtualMachineDetailedStatusAvailable), + string(VirtualMachineDetailedStatusError), + string(VirtualMachineDetailedStatusProvisioning), + string(VirtualMachineDetailedStatusRunning), + string(VirtualMachineDetailedStatusScheduling), + string(VirtualMachineDetailedStatusStopped), + string(VirtualMachineDetailedStatusTerminating), + string(VirtualMachineDetailedStatusUnknown), + } +} + +func (s *VirtualMachineDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineDetailedStatus(input string) (*VirtualMachineDetailedStatus, error) { + vals := map[string]VirtualMachineDetailedStatus{ + "available": VirtualMachineDetailedStatusAvailable, + "error": VirtualMachineDetailedStatusError, + "provisioning": VirtualMachineDetailedStatusProvisioning, + "running": VirtualMachineDetailedStatusRunning, + "scheduling": VirtualMachineDetailedStatusScheduling, + "stopped": VirtualMachineDetailedStatusStopped, + "terminating": VirtualMachineDetailedStatusTerminating, + "unknown": VirtualMachineDetailedStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineDetailedStatus(input) + return &out, nil +} + +type VirtualMachineDeviceModelType string + +const ( + VirtualMachineDeviceModelTypeTOne VirtualMachineDeviceModelType = "T1" + VirtualMachineDeviceModelTypeTTwo VirtualMachineDeviceModelType = "T2" +) + +func PossibleValuesForVirtualMachineDeviceModelType() []string { + return []string{ + string(VirtualMachineDeviceModelTypeTOne), + string(VirtualMachineDeviceModelTypeTTwo), + } +} + +func (s *VirtualMachineDeviceModelType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineDeviceModelType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineDeviceModelType(input string) (*VirtualMachineDeviceModelType, error) { + vals := map[string]VirtualMachineDeviceModelType{ + "t1": VirtualMachineDeviceModelTypeTOne, + "t2": VirtualMachineDeviceModelTypeTTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineDeviceModelType(input) + return &out, nil +} + +type VirtualMachineIPAllocationMethod string + +const ( + VirtualMachineIPAllocationMethodDisabled VirtualMachineIPAllocationMethod = "Disabled" + VirtualMachineIPAllocationMethodDynamic VirtualMachineIPAllocationMethod = "Dynamic" + VirtualMachineIPAllocationMethodStatic VirtualMachineIPAllocationMethod = "Static" +) + +func PossibleValuesForVirtualMachineIPAllocationMethod() []string { + return []string{ + string(VirtualMachineIPAllocationMethodDisabled), + string(VirtualMachineIPAllocationMethodDynamic), + string(VirtualMachineIPAllocationMethodStatic), + } +} + +func (s *VirtualMachineIPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineIPAllocationMethod(input string) (*VirtualMachineIPAllocationMethod, error) { + vals := map[string]VirtualMachineIPAllocationMethod{ + "disabled": VirtualMachineIPAllocationMethodDisabled, + "dynamic": VirtualMachineIPAllocationMethodDynamic, + "static": VirtualMachineIPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineIPAllocationMethod(input) + return &out, nil +} + +type VirtualMachineIsolateEmulatorThread string + +const ( + VirtualMachineIsolateEmulatorThreadFalse VirtualMachineIsolateEmulatorThread = "False" + VirtualMachineIsolateEmulatorThreadTrue VirtualMachineIsolateEmulatorThread = "True" +) + +func PossibleValuesForVirtualMachineIsolateEmulatorThread() []string { + return []string{ + string(VirtualMachineIsolateEmulatorThreadFalse), + string(VirtualMachineIsolateEmulatorThreadTrue), + } +} + +func (s *VirtualMachineIsolateEmulatorThread) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineIsolateEmulatorThread(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineIsolateEmulatorThread(input string) (*VirtualMachineIsolateEmulatorThread, error) { + vals := map[string]VirtualMachineIsolateEmulatorThread{ + "false": VirtualMachineIsolateEmulatorThreadFalse, + "true": VirtualMachineIsolateEmulatorThreadTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineIsolateEmulatorThread(input) + return &out, nil +} + +type VirtualMachinePlacementHintPodAffinityScope string + +const ( + VirtualMachinePlacementHintPodAffinityScopeMachine VirtualMachinePlacementHintPodAffinityScope = "Machine" + VirtualMachinePlacementHintPodAffinityScopeRack VirtualMachinePlacementHintPodAffinityScope = "Rack" +) + +func PossibleValuesForVirtualMachinePlacementHintPodAffinityScope() []string { + return []string{ + string(VirtualMachinePlacementHintPodAffinityScopeMachine), + string(VirtualMachinePlacementHintPodAffinityScopeRack), + } +} + +func (s *VirtualMachinePlacementHintPodAffinityScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachinePlacementHintPodAffinityScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachinePlacementHintPodAffinityScope(input string) (*VirtualMachinePlacementHintPodAffinityScope, error) { + vals := map[string]VirtualMachinePlacementHintPodAffinityScope{ + "machine": VirtualMachinePlacementHintPodAffinityScopeMachine, + "rack": VirtualMachinePlacementHintPodAffinityScopeRack, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachinePlacementHintPodAffinityScope(input) + return &out, nil +} + +type VirtualMachinePlacementHintType string + +const ( + VirtualMachinePlacementHintTypeAffinity VirtualMachinePlacementHintType = "Affinity" + VirtualMachinePlacementHintTypeAntiAffinity VirtualMachinePlacementHintType = "AntiAffinity" +) + +func PossibleValuesForVirtualMachinePlacementHintType() []string { + return []string{ + string(VirtualMachinePlacementHintTypeAffinity), + string(VirtualMachinePlacementHintTypeAntiAffinity), + } +} + +func (s *VirtualMachinePlacementHintType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachinePlacementHintType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachinePlacementHintType(input string) (*VirtualMachinePlacementHintType, error) { + vals := map[string]VirtualMachinePlacementHintType{ + "affinity": VirtualMachinePlacementHintTypeAffinity, + "antiaffinity": VirtualMachinePlacementHintTypeAntiAffinity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachinePlacementHintType(input) + return &out, nil +} + +type VirtualMachinePowerState string + +const ( + VirtualMachinePowerStateOff VirtualMachinePowerState = "Off" + VirtualMachinePowerStateOn VirtualMachinePowerState = "On" + VirtualMachinePowerStateUnknown VirtualMachinePowerState = "Unknown" +) + +func PossibleValuesForVirtualMachinePowerState() []string { + return []string{ + string(VirtualMachinePowerStateOff), + string(VirtualMachinePowerStateOn), + string(VirtualMachinePowerStateUnknown), + } +} + +func (s *VirtualMachinePowerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachinePowerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachinePowerState(input string) (*VirtualMachinePowerState, error) { + vals := map[string]VirtualMachinePowerState{ + "off": VirtualMachinePowerStateOff, + "on": VirtualMachinePowerStateOn, + "unknown": VirtualMachinePowerStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachinePowerState(input) + return &out, nil +} + +type VirtualMachineProvisioningState string + +const ( + VirtualMachineProvisioningStateAccepted VirtualMachineProvisioningState = "Accepted" + VirtualMachineProvisioningStateCanceled VirtualMachineProvisioningState = "Canceled" + VirtualMachineProvisioningStateFailed VirtualMachineProvisioningState = "Failed" + VirtualMachineProvisioningStateProvisioning VirtualMachineProvisioningState = "Provisioning" + VirtualMachineProvisioningStateSucceeded VirtualMachineProvisioningState = "Succeeded" +) + +func PossibleValuesForVirtualMachineProvisioningState() []string { + return []string{ + string(VirtualMachineProvisioningStateAccepted), + string(VirtualMachineProvisioningStateCanceled), + string(VirtualMachineProvisioningStateFailed), + string(VirtualMachineProvisioningStateProvisioning), + string(VirtualMachineProvisioningStateSucceeded), + } +} + +func (s *VirtualMachineProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineProvisioningState(input string) (*VirtualMachineProvisioningState, error) { + vals := map[string]VirtualMachineProvisioningState{ + "accepted": VirtualMachineProvisioningStateAccepted, + "canceled": VirtualMachineProvisioningStateCanceled, + "failed": VirtualMachineProvisioningStateFailed, + "provisioning": VirtualMachineProvisioningStateProvisioning, + "succeeded": VirtualMachineProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineProvisioningState(input) + return &out, nil +} + +type VirtualMachineSchedulingExecution string + +const ( + VirtualMachineSchedulingExecutionHard VirtualMachineSchedulingExecution = "Hard" + VirtualMachineSchedulingExecutionSoft VirtualMachineSchedulingExecution = "Soft" +) + +func PossibleValuesForVirtualMachineSchedulingExecution() []string { + return []string{ + string(VirtualMachineSchedulingExecutionHard), + string(VirtualMachineSchedulingExecutionSoft), + } +} + +func (s *VirtualMachineSchedulingExecution) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineSchedulingExecution(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineSchedulingExecution(input string) (*VirtualMachineSchedulingExecution, error) { + vals := map[string]VirtualMachineSchedulingExecution{ + "hard": VirtualMachineSchedulingExecutionHard, + "soft": VirtualMachineSchedulingExecutionSoft, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineSchedulingExecution(input) + return &out, nil +} + +type VirtualMachineVirtioInterfaceType string + +const ( + VirtualMachineVirtioInterfaceTypeModern VirtualMachineVirtioInterfaceType = "Modern" + VirtualMachineVirtioInterfaceTypeTransitional VirtualMachineVirtioInterfaceType = "Transitional" +) + +func PossibleValuesForVirtualMachineVirtioInterfaceType() []string { + return []string{ + string(VirtualMachineVirtioInterfaceTypeModern), + string(VirtualMachineVirtioInterfaceTypeTransitional), + } +} + +func (s *VirtualMachineVirtioInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualMachineVirtioInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualMachineVirtioInterfaceType(input string) (*VirtualMachineVirtioInterfaceType, error) { + vals := map[string]VirtualMachineVirtioInterfaceType{ + "modern": VirtualMachineVirtioInterfaceTypeModern, + "transitional": VirtualMachineVirtioInterfaceTypeTransitional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualMachineVirtioInterfaceType(input) + return &out, nil +} + +type VolumeDetailedStatus string + +const ( + VolumeDetailedStatusActive VolumeDetailedStatus = "Active" + VolumeDetailedStatusError VolumeDetailedStatus = "Error" + VolumeDetailedStatusProvisioning VolumeDetailedStatus = "Provisioning" +) + +func PossibleValuesForVolumeDetailedStatus() []string { + return []string{ + string(VolumeDetailedStatusActive), + string(VolumeDetailedStatusError), + string(VolumeDetailedStatusProvisioning), + } +} + +func (s *VolumeDetailedStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeDetailedStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeDetailedStatus(input string) (*VolumeDetailedStatus, error) { + vals := map[string]VolumeDetailedStatus{ + "active": VolumeDetailedStatusActive, + "error": VolumeDetailedStatusError, + "provisioning": VolumeDetailedStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeDetailedStatus(input) + return &out, nil +} + +type VolumeProvisioningState string + +const ( + VolumeProvisioningStateAccepted VolumeProvisioningState = "Accepted" + VolumeProvisioningStateCanceled VolumeProvisioningState = "Canceled" + VolumeProvisioningStateFailed VolumeProvisioningState = "Failed" + VolumeProvisioningStateProvisioning VolumeProvisioningState = "Provisioning" + VolumeProvisioningStateSucceeded VolumeProvisioningState = "Succeeded" +) + +func PossibleValuesForVolumeProvisioningState() []string { + return []string{ + string(VolumeProvisioningStateAccepted), + string(VolumeProvisioningStateCanceled), + string(VolumeProvisioningStateFailed), + string(VolumeProvisioningStateProvisioning), + string(VolumeProvisioningStateSucceeded), + } +} + +func (s *VolumeProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeProvisioningState(input string) (*VolumeProvisioningState, error) { + vals := map[string]VolumeProvisioningState{ + "accepted": VolumeProvisioningStateAccepted, + "canceled": VolumeProvisioningStateCanceled, + "failed": VolumeProvisioningStateFailed, + "provisioning": VolumeProvisioningStateProvisioning, + "succeeded": VolumeProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeProvisioningState(input) + return &out, nil +} + +type WorkloadImpact string + +const ( + WorkloadImpactFalse WorkloadImpact = "False" + WorkloadImpactTrue WorkloadImpact = "True" +) + +func PossibleValuesForWorkloadImpact() []string { + return []string{ + string(WorkloadImpactFalse), + string(WorkloadImpactTrue), + } +} + +func (s *WorkloadImpact) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadImpact(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadImpact(input string) (*WorkloadImpact, error) { + vals := map[string]WorkloadImpact{ + "false": WorkloadImpactFalse, + "true": WorkloadImpactTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadImpact(input) + return &out, nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool.go new file mode 100644 index 00000000000..3bafcf12105 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AgentPoolId{}) +} + +var _ resourceids.ResourceId = &AgentPoolId{} + +// AgentPoolId is a struct representing the Resource ID for a Agent Pool +type AgentPoolId struct { + SubscriptionId string + ResourceGroupName string + KubernetesClusterName string + AgentPoolName string +} + +// NewAgentPoolID returns a new AgentPoolId struct +func NewAgentPoolID(subscriptionId string, resourceGroupName string, kubernetesClusterName string, agentPoolName string) AgentPoolId { + return AgentPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubernetesClusterName: kubernetesClusterName, + AgentPoolName: agentPoolName, + } +} + +// ParseAgentPoolID parses 'input' into a AgentPoolId +func ParseAgentPoolID(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAgentPoolIDInsensitively parses 'input' case-insensitively into a AgentPoolId +// note: this method should only be used for API response data and not user input +func ParseAgentPoolIDInsensitively(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AgentPoolId) 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.KubernetesClusterName, ok = input.Parsed["kubernetesClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubernetesClusterName", input) + } + + if id.AgentPoolName, ok = input.Parsed["agentPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "agentPoolName", input) + } + + return nil +} + +// ValidateAgentPoolID checks that 'input' can be parsed as a Agent Pool ID +func ValidateAgentPoolID(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 := ParseAgentPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Agent Pool ID +func (id AgentPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/kubernetesClusters/%s/agentPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubernetesClusterName, id.AgentPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Agent Pool ID +func (id AgentPoolId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticKubernetesClusters", "kubernetesClusters", "kubernetesClusters"), + resourceids.UserSpecifiedSegment("kubernetesClusterName", "kubernetesClusterName"), + resourceids.StaticSegment("staticAgentPools", "agentPools", "agentPools"), + resourceids.UserSpecifiedSegment("agentPoolName", "agentPoolName"), + } +} + +// String returns a human-readable description of this Agent Pool ID +func (id AgentPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kubernetes Cluster Name: %q", id.KubernetesClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + } + return fmt.Sprintf("Agent Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool_test.go new file mode 100644 index 00000000000..89a5a902a0a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_agentpool_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &AgentPoolId{} + +func TestNewAgentPoolID(t *testing.T) { + id := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName") + + 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.KubernetesClusterName != "kubernetesClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'KubernetesClusterName'", id.KubernetesClusterName, "kubernetesClusterName") + } + + if id.AgentPoolName != "agentPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'AgentPoolName'", id.AgentPoolName, "agentPoolName") + } +} + +func TestFormatAgentPoolID(t *testing.T) { + actual := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "agentPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools/agentPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAgentPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools/agentPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolID(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestParseAgentPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/aGeNtPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/agentPools/agentPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/aGeNtPoOlS/aGeNtPoOlNaMe", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubernetesClusterName: "kUbErNeTeScLuStErNaMe", + AgentPoolName: "aGeNtPoOlNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/aGeNtPoOlS/aGeNtPoOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolIDInsensitively(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestSegmentsForAgentPoolId(t *testing.T) { + segments := AgentPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AgentPoolId 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/networkcloud/2024-07-01/networkclouds/id_baremetalmachine.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachine.go new file mode 100644 index 00000000000..a2695fe0aea --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachine.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BareMetalMachineId{}) +} + +var _ resourceids.ResourceId = &BareMetalMachineId{} + +// BareMetalMachineId is a struct representing the Resource ID for a Bare Metal Machine +type BareMetalMachineId struct { + SubscriptionId string + ResourceGroupName string + BareMetalMachineName string +} + +// NewBareMetalMachineID returns a new BareMetalMachineId struct +func NewBareMetalMachineID(subscriptionId string, resourceGroupName string, bareMetalMachineName string) BareMetalMachineId { + return BareMetalMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BareMetalMachineName: bareMetalMachineName, + } +} + +// ParseBareMetalMachineID parses 'input' into a BareMetalMachineId +func ParseBareMetalMachineID(input string) (*BareMetalMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BareMetalMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BareMetalMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBareMetalMachineIDInsensitively parses 'input' case-insensitively into a BareMetalMachineId +// note: this method should only be used for API response data and not user input +func ParseBareMetalMachineIDInsensitively(input string) (*BareMetalMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BareMetalMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BareMetalMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BareMetalMachineId) 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.BareMetalMachineName, ok = input.Parsed["bareMetalMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "bareMetalMachineName", input) + } + + return nil +} + +// ValidateBareMetalMachineID checks that 'input' can be parsed as a Bare Metal Machine ID +func ValidateBareMetalMachineID(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 := ParseBareMetalMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Bare Metal Machine ID +func (id BareMetalMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/bareMetalMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BareMetalMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Bare Metal Machine ID +func (id BareMetalMachineId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticBareMetalMachines", "bareMetalMachines", "bareMetalMachines"), + resourceids.UserSpecifiedSegment("bareMetalMachineName", "bareMetalMachineName"), + } +} + +// String returns a human-readable description of this Bare Metal Machine ID +func (id BareMetalMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Bare Metal Machine Name: %q", id.BareMetalMachineName), + } + return fmt.Sprintf("Bare Metal Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachine_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachine_test.go new file mode 100644 index 00000000000..6f5f0ab78f0 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachine_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &BareMetalMachineId{} + +func TestNewBareMetalMachineID(t *testing.T) { + id := NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName") + + 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.BareMetalMachineName != "bareMetalMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'BareMetalMachineName'", id.BareMetalMachineName, "bareMetalMachineName") + } +} + +func TestFormatBareMetalMachineID(t *testing.T) { + actual := NewBareMetalMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bareMetalMachineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBareMetalMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BareMetalMachineId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName", + Expected: &BareMetalMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BareMetalMachineName: "bareMetalMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBareMetalMachineID(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.BareMetalMachineName != v.Expected.BareMetalMachineName { + t.Fatalf("Expected %q but got %q for BareMetalMachineName", v.Expected.BareMetalMachineName, actual.BareMetalMachineName) + } + + } +} + +func TestParseBareMetalMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BareMetalMachineId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/bArEmEtAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName", + Expected: &BareMetalMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BareMetalMachineName: "bareMetalMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/bArEmEtAlMaChInEs/bArEmEtAlMaChInEnAmE", + Expected: &BareMetalMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BareMetalMachineName: "bArEmEtAlMaChInEnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/bArEmEtAlMaChInEs/bArEmEtAlMaChInEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBareMetalMachineIDInsensitively(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.BareMetalMachineName != v.Expected.BareMetalMachineName { + t.Fatalf("Expected %q but got %q for BareMetalMachineName", v.Expected.BareMetalMachineName, actual.BareMetalMachineName) + } + + } +} + +func TestSegmentsForBareMetalMachineId(t *testing.T) { + segments := BareMetalMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BareMetalMachineId 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/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset.go new file mode 100644 index 00000000000..bd7ca352662 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BareMetalMachineKeySetId{}) +} + +var _ resourceids.ResourceId = &BareMetalMachineKeySetId{} + +// BareMetalMachineKeySetId is a struct representing the Resource ID for a Bare Metal Machine Key Set +type BareMetalMachineKeySetId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + BareMetalMachineKeySetName string +} + +// NewBareMetalMachineKeySetID returns a new BareMetalMachineKeySetId struct +func NewBareMetalMachineKeySetID(subscriptionId string, resourceGroupName string, clusterName string, bareMetalMachineKeySetName string) BareMetalMachineKeySetId { + return BareMetalMachineKeySetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + BareMetalMachineKeySetName: bareMetalMachineKeySetName, + } +} + +// ParseBareMetalMachineKeySetID parses 'input' into a BareMetalMachineKeySetId +func ParseBareMetalMachineKeySetID(input string) (*BareMetalMachineKeySetId, error) { + parser := resourceids.NewParserFromResourceIdType(&BareMetalMachineKeySetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BareMetalMachineKeySetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBareMetalMachineKeySetIDInsensitively parses 'input' case-insensitively into a BareMetalMachineKeySetId +// note: this method should only be used for API response data and not user input +func ParseBareMetalMachineKeySetIDInsensitively(input string) (*BareMetalMachineKeySetId, error) { + parser := resourceids.NewParserFromResourceIdType(&BareMetalMachineKeySetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BareMetalMachineKeySetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BareMetalMachineKeySetId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.BareMetalMachineKeySetName, ok = input.Parsed["bareMetalMachineKeySetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "bareMetalMachineKeySetName", input) + } + + return nil +} + +// ValidateBareMetalMachineKeySetID checks that 'input' can be parsed as a Bare Metal Machine Key Set ID +func ValidateBareMetalMachineKeySetID(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 := ParseBareMetalMachineKeySetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Bare Metal Machine Key Set ID +func (id BareMetalMachineKeySetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/clusters/%s/bareMetalMachineKeySets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.BareMetalMachineKeySetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Bare Metal Machine Key Set ID +func (id BareMetalMachineKeySetId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticBareMetalMachineKeySets", "bareMetalMachineKeySets", "bareMetalMachineKeySets"), + resourceids.UserSpecifiedSegment("bareMetalMachineKeySetName", "bareMetalMachineKeySetName"), + } +} + +// String returns a human-readable description of this Bare Metal Machine Key Set ID +func (id BareMetalMachineKeySetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Bare Metal Machine Key Set Name: %q", id.BareMetalMachineKeySetName), + } + return fmt.Sprintf("Bare Metal Machine Key Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset_test.go new file mode 100644 index 00000000000..ce4ed02f5a6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_baremetalmachinekeyset_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &BareMetalMachineKeySetId{} + +func TestNewBareMetalMachineKeySetID(t *testing.T) { + id := NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.BareMetalMachineKeySetName != "bareMetalMachineKeySetName" { + t.Fatalf("Expected %q but got %q for Segment 'BareMetalMachineKeySetName'", id.BareMetalMachineKeySetName, "bareMetalMachineKeySetName") + } +} + +func TestFormatBareMetalMachineKeySetID(t *testing.T) { + actual := NewBareMetalMachineKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bareMetalMachineKeySetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets/bareMetalMachineKeySetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBareMetalMachineKeySetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BareMetalMachineKeySetId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets/bareMetalMachineKeySetName", + Expected: &BareMetalMachineKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + BareMetalMachineKeySetName: "bareMetalMachineKeySetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets/bareMetalMachineKeySetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBareMetalMachineKeySetID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.BareMetalMachineKeySetName != v.Expected.BareMetalMachineKeySetName { + t.Fatalf("Expected %q but got %q for BareMetalMachineKeySetName", v.Expected.BareMetalMachineKeySetName, actual.BareMetalMachineKeySetName) + } + + } +} + +func TestParseBareMetalMachineKeySetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BareMetalMachineKeySetId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bArEmEtAlMaChInEkEySeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets/bareMetalMachineKeySetName", + Expected: &BareMetalMachineKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + BareMetalMachineKeySetName: "bareMetalMachineKeySetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bareMetalMachineKeySets/bareMetalMachineKeySetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bArEmEtAlMaChInEkEySeTs/bArEmEtAlMaChInEkEySeTnAmE", + Expected: &BareMetalMachineKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + BareMetalMachineKeySetName: "bArEmEtAlMaChInEkEySeTnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bArEmEtAlMaChInEkEySeTs/bArEmEtAlMaChInEkEySeTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBareMetalMachineKeySetIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.BareMetalMachineKeySetName != v.Expected.BareMetalMachineKeySetName { + t.Fatalf("Expected %q but got %q for BareMetalMachineKeySetName", v.Expected.BareMetalMachineKeySetName, actual.BareMetalMachineKeySetName) + } + + } +} + +func TestSegmentsForBareMetalMachineKeySetId(t *testing.T) { + segments := BareMetalMachineKeySetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BareMetalMachineKeySetId 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/networkcloud/2024-07-01/networkclouds/id_bmckeyset.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_bmckeyset.go new file mode 100644 index 00000000000..60a21c46a71 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_bmckeyset.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BmcKeySetId{}) +} + +var _ resourceids.ResourceId = &BmcKeySetId{} + +// BmcKeySetId is a struct representing the Resource ID for a Bmc Key Set +type BmcKeySetId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + BmcKeySetName string +} + +// NewBmcKeySetID returns a new BmcKeySetId struct +func NewBmcKeySetID(subscriptionId string, resourceGroupName string, clusterName string, bmcKeySetName string) BmcKeySetId { + return BmcKeySetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + BmcKeySetName: bmcKeySetName, + } +} + +// ParseBmcKeySetID parses 'input' into a BmcKeySetId +func ParseBmcKeySetID(input string) (*BmcKeySetId, error) { + parser := resourceids.NewParserFromResourceIdType(&BmcKeySetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BmcKeySetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBmcKeySetIDInsensitively parses 'input' case-insensitively into a BmcKeySetId +// note: this method should only be used for API response data and not user input +func ParseBmcKeySetIDInsensitively(input string) (*BmcKeySetId, error) { + parser := resourceids.NewParserFromResourceIdType(&BmcKeySetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BmcKeySetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BmcKeySetId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.BmcKeySetName, ok = input.Parsed["bmcKeySetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "bmcKeySetName", input) + } + + return nil +} + +// ValidateBmcKeySetID checks that 'input' can be parsed as a Bmc Key Set ID +func ValidateBmcKeySetID(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 := ParseBmcKeySetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Bmc Key Set ID +func (id BmcKeySetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/clusters/%s/bmcKeySets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.BmcKeySetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Bmc Key Set ID +func (id BmcKeySetId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticBmcKeySets", "bmcKeySets", "bmcKeySets"), + resourceids.UserSpecifiedSegment("bmcKeySetName", "bmcKeySetName"), + } +} + +// String returns a human-readable description of this Bmc Key Set ID +func (id BmcKeySetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Bmc Key Set Name: %q", id.BmcKeySetName), + } + return fmt.Sprintf("Bmc Key Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_bmckeyset_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_bmckeyset_test.go new file mode 100644 index 00000000000..294c5cad612 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_bmckeyset_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &BmcKeySetId{} + +func TestNewBmcKeySetID(t *testing.T) { + id := NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.BmcKeySetName != "bmcKeySetName" { + t.Fatalf("Expected %q but got %q for Segment 'BmcKeySetName'", id.BmcKeySetName, "bmcKeySetName") + } +} + +func TestFormatBmcKeySetID(t *testing.T) { + actual := NewBmcKeySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "bmcKeySetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets/bmcKeySetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBmcKeySetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BmcKeySetId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets/bmcKeySetName", + Expected: &BmcKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + BmcKeySetName: "bmcKeySetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets/bmcKeySetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBmcKeySetID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.BmcKeySetName != v.Expected.BmcKeySetName { + t.Fatalf("Expected %q but got %q for BmcKeySetName", v.Expected.BmcKeySetName, actual.BmcKeySetName) + } + + } +} + +func TestParseBmcKeySetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BmcKeySetId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bMcKeYsEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets/bmcKeySetName", + Expected: &BmcKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + BmcKeySetName: "bmcKeySetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/bmcKeySets/bmcKeySetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bMcKeYsEtS/bMcKeYsEtNaMe", + Expected: &BmcKeySetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + BmcKeySetName: "bMcKeYsEtNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/bMcKeYsEtS/bMcKeYsEtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBmcKeySetIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.BmcKeySetName != v.Expected.BmcKeySetName { + t.Fatalf("Expected %q but got %q for BmcKeySetName", v.Expected.BmcKeySetName, actual.BmcKeySetName) + } + + } +} + +func TestSegmentsForBmcKeySetId(t *testing.T) { + segments := BmcKeySetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BmcKeySetId 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/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork.go new file mode 100644 index 00000000000..cacd0b00885 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CloudServicesNetworkId{}) +} + +var _ resourceids.ResourceId = &CloudServicesNetworkId{} + +// CloudServicesNetworkId is a struct representing the Resource ID for a Cloud Services Network +type CloudServicesNetworkId struct { + SubscriptionId string + ResourceGroupName string + CloudServicesNetworkName string +} + +// NewCloudServicesNetworkID returns a new CloudServicesNetworkId struct +func NewCloudServicesNetworkID(subscriptionId string, resourceGroupName string, cloudServicesNetworkName string) CloudServicesNetworkId { + return CloudServicesNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServicesNetworkName: cloudServicesNetworkName, + } +} + +// ParseCloudServicesNetworkID parses 'input' into a CloudServicesNetworkId +func ParseCloudServicesNetworkID(input string) (*CloudServicesNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudServicesNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudServicesNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudServicesNetworkIDInsensitively parses 'input' case-insensitively into a CloudServicesNetworkId +// note: this method should only be used for API response data and not user input +func ParseCloudServicesNetworkIDInsensitively(input string) (*CloudServicesNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudServicesNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudServicesNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudServicesNetworkId) 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.CloudServicesNetworkName, ok = input.Parsed["cloudServicesNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServicesNetworkName", input) + } + + return nil +} + +// ValidateCloudServicesNetworkID checks that 'input' can be parsed as a Cloud Services Network ID +func ValidateCloudServicesNetworkID(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 := ParseCloudServicesNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Services Network ID +func (id CloudServicesNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/cloudServicesNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServicesNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Services Network ID +func (id CloudServicesNetworkId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticCloudServicesNetworks", "cloudServicesNetworks", "cloudServicesNetworks"), + resourceids.UserSpecifiedSegment("cloudServicesNetworkName", "cloudServicesNetworkName"), + } +} + +// String returns a human-readable description of this Cloud Services Network ID +func (id CloudServicesNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Services Network Name: %q", id.CloudServicesNetworkName), + } + return fmt.Sprintf("Cloud Services Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork_test.go new file mode 100644 index 00000000000..df01d065411 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cloudservicesnetwork_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &CloudServicesNetworkId{} + +func TestNewCloudServicesNetworkID(t *testing.T) { + id := NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName") + + 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.CloudServicesNetworkName != "cloudServicesNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServicesNetworkName'", id.CloudServicesNetworkName, "cloudServicesNetworkName") + } +} + +func TestFormatCloudServicesNetworkID(t *testing.T) { + actual := NewCloudServicesNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServicesNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudServicesNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudServicesNetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName", + Expected: &CloudServicesNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServicesNetworkName: "cloudServicesNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudServicesNetworkID(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.CloudServicesNetworkName != v.Expected.CloudServicesNetworkName { + t.Fatalf("Expected %q but got %q for CloudServicesNetworkName", v.Expected.CloudServicesNetworkName, actual.CloudServicesNetworkName) + } + + } +} + +func TestParseCloudServicesNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudServicesNetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLoUdSeRvIcEsNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName", + Expected: &CloudServicesNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServicesNetworkName: "cloudServicesNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLoUdSeRvIcEsNeTwOrKs/cLoUdSeRvIcEsNeTwOrKnAmE", + Expected: &CloudServicesNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudServicesNetworkName: "cLoUdSeRvIcEsNeTwOrKnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/cLoUdSeRvIcEsNeTwOrKs/cLoUdSeRvIcEsNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudServicesNetworkIDInsensitively(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.CloudServicesNetworkName != v.Expected.CloudServicesNetworkName { + t.Fatalf("Expected %q but got %q for CloudServicesNetworkName", v.Expected.CloudServicesNetworkName, actual.CloudServicesNetworkName) + } + + } +} + +func TestSegmentsForCloudServicesNetworkId(t *testing.T) { + segments := CloudServicesNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudServicesNetworkId 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/networkcloud/2024-07-01/networkclouds/id_cluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cluster.go new file mode 100644 index 00000000000..9ad8ffd6559 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cluster.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ClusterId{}) +} + +var _ resourceids.ResourceId = &ClusterId{} + +// ClusterId is a struct representing the Resource ID for a Cluster +type ClusterId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string +} + +// NewClusterID returns a new ClusterId struct +func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { + return ClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + } +} + +// ParseClusterID parses 'input' into a ClusterId +func ParseClusterID(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId +// note: this method should only be used for API response data and not user input +func ParseClusterIDInsensitively(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClusterId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + return nil +} + +// ValidateClusterID checks that 'input' can be parsed as a Cluster ID +func ValidateClusterID(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 := ParseClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cluster ID +func (id ClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/clusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cluster ID +func (id ClusterId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + } +} + +// String returns a human-readable description of this Cluster ID +func (id ClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + } + return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_cluster_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cluster_test.go new file mode 100644 index 00000000000..ff1740af9ef --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_cluster_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &ClusterId{} + +func TestNewClusterID(t *testing.T) { + id := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } +} + +func TestFormatClusterID(t *testing.T) { + actual := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestParseClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestSegmentsForClusterId(t *testing.T) { + segments := ClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ClusterId 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/networkcloud/2024-07-01/networkclouds/id_clustermanager.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_clustermanager.go new file mode 100644 index 00000000000..7b2b98cf069 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_clustermanager.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ClusterManagerId{}) +} + +var _ resourceids.ResourceId = &ClusterManagerId{} + +// ClusterManagerId is a struct representing the Resource ID for a Cluster Manager +type ClusterManagerId struct { + SubscriptionId string + ResourceGroupName string + ClusterManagerName string +} + +// NewClusterManagerID returns a new ClusterManagerId struct +func NewClusterManagerID(subscriptionId string, resourceGroupName string, clusterManagerName string) ClusterManagerId { + return ClusterManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterManagerName: clusterManagerName, + } +} + +// ParseClusterManagerID parses 'input' into a ClusterManagerId +func ParseClusterManagerID(input string) (*ClusterManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClusterManagerIDInsensitively parses 'input' case-insensitively into a ClusterManagerId +// note: this method should only be used for API response data and not user input +func ParseClusterManagerIDInsensitively(input string) (*ClusterManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClusterManagerId) 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.ClusterManagerName, ok = input.Parsed["clusterManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterManagerName", input) + } + + return nil +} + +// ValidateClusterManagerID checks that 'input' can be parsed as a Cluster Manager ID +func ValidateClusterManagerID(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 := ParseClusterManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cluster Manager ID +func (id ClusterManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/clusterManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cluster Manager ID +func (id ClusterManagerId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticClusterManagers", "clusterManagers", "clusterManagers"), + resourceids.UserSpecifiedSegment("clusterManagerName", "clusterManagerName"), + } +} + +// String returns a human-readable description of this Cluster Manager ID +func (id ClusterManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Manager Name: %q", id.ClusterManagerName), + } + return fmt.Sprintf("Cluster Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_clustermanager_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_clustermanager_test.go new file mode 100644 index 00000000000..ef3073ef937 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_clustermanager_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &ClusterManagerId{} + +func TestNewClusterManagerID(t *testing.T) { + id := NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName") + + 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.ClusterManagerName != "clusterManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterManagerName'", id.ClusterManagerName, "clusterManagerName") + } +} + +func TestFormatClusterManagerID(t *testing.T) { + actual := NewClusterManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers/clusterManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseClusterManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterManagerId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers/clusterManagerName", + Expected: &ClusterManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterManagerName: "clusterManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers/clusterManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterManagerID(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.ClusterManagerName != v.Expected.ClusterManagerName { + t.Fatalf("Expected %q but got %q for ClusterManagerName", v.Expected.ClusterManagerName, actual.ClusterManagerName) + } + + } +} + +func TestParseClusterManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterManagerId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers/clusterManagerName", + Expected: &ClusterManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterManagerName: "clusterManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusterManagers/clusterManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErMaNaGeRs/cLuStErMaNaGeRnAmE", + Expected: &ClusterManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterManagerName: "cLuStErMaNaGeRnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/cLuStErMaNaGeRs/cLuStErMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterManagerIDInsensitively(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.ClusterManagerName != v.Expected.ClusterManagerName { + t.Fatalf("Expected %q but got %q for ClusterManagerName", v.Expected.ClusterManagerName, actual.ClusterManagerName) + } + + } +} + +func TestSegmentsForClusterManagerId(t *testing.T) { + segments := ClusterManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ClusterManagerId 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/networkcloud/2024-07-01/networkclouds/id_console.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_console.go new file mode 100644 index 00000000000..2119a373fcf --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_console.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ConsoleId{}) +} + +var _ resourceids.ResourceId = &ConsoleId{} + +// ConsoleId is a struct representing the Resource ID for a Console +type ConsoleId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineName string + ConsoleName string +} + +// NewConsoleID returns a new ConsoleId struct +func NewConsoleID(subscriptionId string, resourceGroupName string, virtualMachineName string, consoleName string) ConsoleId { + return ConsoleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineName: virtualMachineName, + ConsoleName: consoleName, + } +} + +// ParseConsoleID parses 'input' into a ConsoleId +func ParseConsoleID(input string) (*ConsoleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConsoleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConsoleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConsoleIDInsensitively parses 'input' case-insensitively into a ConsoleId +// note: this method should only be used for API response data and not user input +func ParseConsoleIDInsensitively(input string) (*ConsoleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConsoleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConsoleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConsoleId) 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.VirtualMachineName, ok = input.Parsed["virtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineName", input) + } + + if id.ConsoleName, ok = input.Parsed["consoleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "consoleName", input) + } + + return nil +} + +// ValidateConsoleID checks that 'input' can be parsed as a Console ID +func ValidateConsoleID(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 := ParseConsoleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Console ID +func (id ConsoleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/virtualMachines/%s/consoles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineName, id.ConsoleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Console ID +func (id ConsoleId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticVirtualMachines", "virtualMachines", "virtualMachines"), + resourceids.UserSpecifiedSegment("virtualMachineName", "virtualMachineName"), + resourceids.StaticSegment("staticConsoles", "consoles", "consoles"), + resourceids.UserSpecifiedSegment("consoleName", "consoleName"), + } +} + +// String returns a human-readable description of this Console ID +func (id ConsoleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Name: %q", id.VirtualMachineName), + fmt.Sprintf("Console Name: %q", id.ConsoleName), + } + return fmt.Sprintf("Console (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_console_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_console_test.go new file mode 100644 index 00000000000..3bde8ffeed1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_console_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &ConsoleId{} + +func TestNewConsoleID(t *testing.T) { + id := NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName") + + 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.VirtualMachineName != "virtualMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineName'", id.VirtualMachineName, "virtualMachineName") + } + + if id.ConsoleName != "consoleName" { + t.Fatalf("Expected %q but got %q for Segment 'ConsoleName'", id.ConsoleName, "consoleName") + } +} + +func TestFormatConsoleID(t *testing.T) { + actual := NewConsoleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName", "consoleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles/consoleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConsoleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConsoleId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles/consoleName", + Expected: &ConsoleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + ConsoleName: "consoleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles/consoleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConsoleID(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + if actual.ConsoleName != v.Expected.ConsoleName { + t.Fatalf("Expected %q but got %q for ConsoleName", v.Expected.ConsoleName, actual.ConsoleName) + } + + } +} + +func TestParseConsoleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConsoleId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/cOnSoLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles/consoleName", + Expected: &ConsoleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + ConsoleName: "consoleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/consoles/consoleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/cOnSoLeS/cOnSoLeNaMe", + Expected: &ConsoleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineName: "vIrTuAlMaChInEnAmE", + ConsoleName: "cOnSoLeNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/cOnSoLeS/cOnSoLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConsoleIDInsensitively(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + if actual.ConsoleName != v.Expected.ConsoleName { + t.Fatalf("Expected %q but got %q for ConsoleName", v.Expected.ConsoleName, actual.ConsoleName) + } + + } +} + +func TestSegmentsForConsoleId(t *testing.T) { + segments := ConsoleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConsoleId 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/networkcloud/2024-07-01/networkclouds/id_feature.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_feature.go new file mode 100644 index 00000000000..ec785b6d082 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_feature.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FeatureId{}) +} + +var _ resourceids.ResourceId = &FeatureId{} + +// FeatureId is a struct representing the Resource ID for a Feature +type FeatureId struct { + SubscriptionId string + ResourceGroupName string + KubernetesClusterName string + FeatureName string +} + +// NewFeatureID returns a new FeatureId struct +func NewFeatureID(subscriptionId string, resourceGroupName string, kubernetesClusterName string, featureName string) FeatureId { + return FeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubernetesClusterName: kubernetesClusterName, + FeatureName: featureName, + } +} + +// ParseFeatureID parses 'input' into a FeatureId +func ParseFeatureID(input string) (*FeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureIDInsensitively parses 'input' case-insensitively into a FeatureId +// note: this method should only be used for API response data and not user input +func ParseFeatureIDInsensitively(input string) (*FeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureId) 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.KubernetesClusterName, ok = input.Parsed["kubernetesClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubernetesClusterName", input) + } + + if id.FeatureName, ok = input.Parsed["featureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureName", input) + } + + return nil +} + +// ValidateFeatureID checks that 'input' can be parsed as a Feature ID +func ValidateFeatureID(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 := ParseFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature ID +func (id FeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/kubernetesClusters/%s/features/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubernetesClusterName, id.FeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature ID +func (id FeatureId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticKubernetesClusters", "kubernetesClusters", "kubernetesClusters"), + resourceids.UserSpecifiedSegment("kubernetesClusterName", "kubernetesClusterName"), + resourceids.StaticSegment("staticFeatures", "features", "features"), + resourceids.UserSpecifiedSegment("featureName", "featureName"), + } +} + +// String returns a human-readable description of this Feature ID +func (id FeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kubernetes Cluster Name: %q", id.KubernetesClusterName), + fmt.Sprintf("Feature Name: %q", id.FeatureName), + } + return fmt.Sprintf("Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_feature_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_feature_test.go new file mode 100644 index 00000000000..62b24b11a5c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_feature_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &FeatureId{} + +func TestNewFeatureID(t *testing.T) { + id := NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName") + + 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.KubernetesClusterName != "kubernetesClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'KubernetesClusterName'", id.KubernetesClusterName, "kubernetesClusterName") + } + + if id.FeatureName != "featureName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureName'", id.FeatureName, "featureName") + } +} + +func TestFormatFeatureID(t *testing.T) { + actual := NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName", "featureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features/featureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features/featureName", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + FeatureName: "featureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features/featureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureID(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + if actual.FeatureName != v.Expected.FeatureName { + t.Fatalf("Expected %q but got %q for FeatureName", v.Expected.FeatureName, actual.FeatureName) + } + + } +} + +func TestParseFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/fEaTuReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features/featureName", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + FeatureName: "featureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/features/featureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/fEaTuReS/fEaTuReNaMe", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubernetesClusterName: "kUbErNeTeScLuStErNaMe", + FeatureName: "fEaTuReNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/fEaTuReS/fEaTuReNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureIDInsensitively(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + if actual.FeatureName != v.Expected.FeatureName { + t.Fatalf("Expected %q but got %q for FeatureName", v.Expected.FeatureName, actual.FeatureName) + } + + } +} + +func TestSegmentsForFeatureId(t *testing.T) { + segments := FeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureId 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/networkcloud/2024-07-01/networkclouds/id_kubernetescluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_kubernetescluster.go new file mode 100644 index 00000000000..6ff204047c8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_kubernetescluster.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&KubernetesClusterId{}) +} + +var _ resourceids.ResourceId = &KubernetesClusterId{} + +// KubernetesClusterId is a struct representing the Resource ID for a Kubernetes Cluster +type KubernetesClusterId struct { + SubscriptionId string + ResourceGroupName string + KubernetesClusterName string +} + +// NewKubernetesClusterID returns a new KubernetesClusterId struct +func NewKubernetesClusterID(subscriptionId string, resourceGroupName string, kubernetesClusterName string) KubernetesClusterId { + return KubernetesClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubernetesClusterName: kubernetesClusterName, + } +} + +// ParseKubernetesClusterID parses 'input' into a KubernetesClusterId +func ParseKubernetesClusterID(input string) (*KubernetesClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubernetesClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubernetesClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKubernetesClusterIDInsensitively parses 'input' case-insensitively into a KubernetesClusterId +// note: this method should only be used for API response data and not user input +func ParseKubernetesClusterIDInsensitively(input string) (*KubernetesClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubernetesClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubernetesClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KubernetesClusterId) 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.KubernetesClusterName, ok = input.Parsed["kubernetesClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubernetesClusterName", input) + } + + return nil +} + +// ValidateKubernetesClusterID checks that 'input' can be parsed as a Kubernetes Cluster ID +func ValidateKubernetesClusterID(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 := ParseKubernetesClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Kubernetes Cluster ID +func (id KubernetesClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/kubernetesClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubernetesClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Kubernetes Cluster ID +func (id KubernetesClusterId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticKubernetesClusters", "kubernetesClusters", "kubernetesClusters"), + resourceids.UserSpecifiedSegment("kubernetesClusterName", "kubernetesClusterName"), + } +} + +// String returns a human-readable description of this Kubernetes Cluster ID +func (id KubernetesClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kubernetes Cluster Name: %q", id.KubernetesClusterName), + } + return fmt.Sprintf("Kubernetes Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_kubernetescluster_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_kubernetescluster_test.go new file mode 100644 index 00000000000..525bda86bf7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_kubernetescluster_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &KubernetesClusterId{} + +func TestNewKubernetesClusterID(t *testing.T) { + id := NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName") + + 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.KubernetesClusterName != "kubernetesClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'KubernetesClusterName'", id.KubernetesClusterName, "kubernetesClusterName") + } +} + +func TestFormatKubernetesClusterID(t *testing.T) { + actual := NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubernetesClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKubernetesClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubernetesClusterId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Expected: &KubernetesClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubernetesClusterID(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + } +} + +func TestParseKubernetesClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubernetesClusterId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName", + Expected: &KubernetesClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubernetesClusterName: "kubernetesClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/kubernetesClusters/kubernetesClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe", + Expected: &KubernetesClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubernetesClusterName: "kUbErNeTeScLuStErNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/kUbErNeTeScLuStErS/kUbErNeTeScLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubernetesClusterIDInsensitively(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.KubernetesClusterName != v.Expected.KubernetesClusterName { + t.Fatalf("Expected %q but got %q for KubernetesClusterName", v.Expected.KubernetesClusterName, actual.KubernetesClusterName) + } + + } +} + +func TestSegmentsForKubernetesClusterId(t *testing.T) { + segments := KubernetesClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KubernetesClusterId 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/networkcloud/2024-07-01/networkclouds/id_l2network.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l2network.go new file mode 100644 index 00000000000..1e808ac6ac9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l2network.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&L2NetworkId{}) +} + +var _ resourceids.ResourceId = &L2NetworkId{} + +// L2NetworkId is a struct representing the Resource ID for a L 2 Network +type L2NetworkId struct { + SubscriptionId string + ResourceGroupName string + L2NetworkName string +} + +// NewL2NetworkID returns a new L2NetworkId struct +func NewL2NetworkID(subscriptionId string, resourceGroupName string, l2NetworkName string) L2NetworkId { + return L2NetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + L2NetworkName: l2NetworkName, + } +} + +// ParseL2NetworkID parses 'input' into a L2NetworkId +func ParseL2NetworkID(input string) (*L2NetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&L2NetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := L2NetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseL2NetworkIDInsensitively parses 'input' case-insensitively into a L2NetworkId +// note: this method should only be used for API response data and not user input +func ParseL2NetworkIDInsensitively(input string) (*L2NetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&L2NetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := L2NetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *L2NetworkId) 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.L2NetworkName, ok = input.Parsed["l2NetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "l2NetworkName", input) + } + + return nil +} + +// ValidateL2NetworkID checks that 'input' can be parsed as a L 2 Network ID +func ValidateL2NetworkID(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 := ParseL2NetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted L 2 Network ID +func (id L2NetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/l2Networks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.L2NetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this L 2 Network ID +func (id L2NetworkId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticL2Networks", "l2Networks", "l2Networks"), + resourceids.UserSpecifiedSegment("l2NetworkName", "l2NetworkName"), + } +} + +// String returns a human-readable description of this L 2 Network ID +func (id L2NetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("L 2 Network Name: %q", id.L2NetworkName), + } + return fmt.Sprintf("L 2 Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_l2network_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l2network_test.go new file mode 100644 index 00000000000..68562280b04 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l2network_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &L2NetworkId{} + +func TestNewL2NetworkID(t *testing.T) { + id := NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName") + + 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.L2NetworkName != "l2NetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'L2NetworkName'", id.L2NetworkName, "l2NetworkName") + } +} + +func TestFormatL2NetworkID(t *testing.T) { + actual := NewL2NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l2NetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseL2NetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *L2NetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName", + Expected: &L2NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + L2NetworkName: "l2NetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseL2NetworkID(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.L2NetworkName != v.Expected.L2NetworkName { + t.Fatalf("Expected %q but got %q for L2NetworkName", v.Expected.L2NetworkName, actual.L2NetworkName) + } + + } +} + +func TestParseL2NetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *L2NetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/l2nEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName", + Expected: &L2NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + L2NetworkName: "l2NetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/l2nEtWoRkS/l2nEtWoRkNaMe", + Expected: &L2NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + L2NetworkName: "l2nEtWoRkNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/l2nEtWoRkS/l2nEtWoRkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseL2NetworkIDInsensitively(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.L2NetworkName != v.Expected.L2NetworkName { + t.Fatalf("Expected %q but got %q for L2NetworkName", v.Expected.L2NetworkName, actual.L2NetworkName) + } + + } +} + +func TestSegmentsForL2NetworkId(t *testing.T) { + segments := L2NetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("L2NetworkId 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/networkcloud/2024-07-01/networkclouds/id_l3network.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l3network.go new file mode 100644 index 00000000000..828d67c3cc5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l3network.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&L3NetworkId{}) +} + +var _ resourceids.ResourceId = &L3NetworkId{} + +// L3NetworkId is a struct representing the Resource ID for a L 3 Network +type L3NetworkId struct { + SubscriptionId string + ResourceGroupName string + L3NetworkName string +} + +// NewL3NetworkID returns a new L3NetworkId struct +func NewL3NetworkID(subscriptionId string, resourceGroupName string, l3NetworkName string) L3NetworkId { + return L3NetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + L3NetworkName: l3NetworkName, + } +} + +// ParseL3NetworkID parses 'input' into a L3NetworkId +func ParseL3NetworkID(input string) (*L3NetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&L3NetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := L3NetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseL3NetworkIDInsensitively parses 'input' case-insensitively into a L3NetworkId +// note: this method should only be used for API response data and not user input +func ParseL3NetworkIDInsensitively(input string) (*L3NetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&L3NetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := L3NetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *L3NetworkId) 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.L3NetworkName, ok = input.Parsed["l3NetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "l3NetworkName", input) + } + + return nil +} + +// ValidateL3NetworkID checks that 'input' can be parsed as a L 3 Network ID +func ValidateL3NetworkID(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 := ParseL3NetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted L 3 Network ID +func (id L3NetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/l3Networks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.L3NetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this L 3 Network ID +func (id L3NetworkId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticL3Networks", "l3Networks", "l3Networks"), + resourceids.UserSpecifiedSegment("l3NetworkName", "l3NetworkName"), + } +} + +// String returns a human-readable description of this L 3 Network ID +func (id L3NetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("L 3 Network Name: %q", id.L3NetworkName), + } + return fmt.Sprintf("L 3 Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_l3network_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l3network_test.go new file mode 100644 index 00000000000..9d059ea3402 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_l3network_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &L3NetworkId{} + +func TestNewL3NetworkID(t *testing.T) { + id := NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName") + + 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.L3NetworkName != "l3NetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'L3NetworkName'", id.L3NetworkName, "l3NetworkName") + } +} + +func TestFormatL3NetworkID(t *testing.T) { + actual := NewL3NetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "l3NetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseL3NetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *L3NetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName", + Expected: &L3NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + L3NetworkName: "l3NetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseL3NetworkID(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.L3NetworkName != v.Expected.L3NetworkName { + t.Fatalf("Expected %q but got %q for L3NetworkName", v.Expected.L3NetworkName, actual.L3NetworkName) + } + + } +} + +func TestParseL3NetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *L3NetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/l3nEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName", + Expected: &L3NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + L3NetworkName: "l3NetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/l3nEtWoRkS/l3nEtWoRkNaMe", + Expected: &L3NetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + L3NetworkName: "l3nEtWoRkNaMe", + }, + }, + { + // 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.nEtWoRkClOuD/l3nEtWoRkS/l3nEtWoRkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseL3NetworkIDInsensitively(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.L3NetworkName != v.Expected.L3NetworkName { + t.Fatalf("Expected %q but got %q for L3NetworkName", v.Expected.L3NetworkName, actual.L3NetworkName) + } + + } +} + +func TestSegmentsForL3NetworkId(t *testing.T) { + segments := L3NetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("L3NetworkId 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/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration.go new file mode 100644 index 00000000000..02ae1dde8dd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration.go @@ -0,0 +1,139 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&MetricsConfigurationId{}) +} + +var _ resourceids.ResourceId = &MetricsConfigurationId{} + +// MetricsConfigurationId is a struct representing the Resource ID for a Metrics Configuration +type MetricsConfigurationId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + MetricsConfigurationName string +} + +// NewMetricsConfigurationID returns a new MetricsConfigurationId struct +func NewMetricsConfigurationID(subscriptionId string, resourceGroupName string, clusterName string, metricsConfigurationName string) MetricsConfigurationId { + return MetricsConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + MetricsConfigurationName: metricsConfigurationName, + } +} + +// ParseMetricsConfigurationID parses 'input' into a MetricsConfigurationId +func ParseMetricsConfigurationID(input string) (*MetricsConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MetricsConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MetricsConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMetricsConfigurationIDInsensitively parses 'input' case-insensitively into a MetricsConfigurationId +// note: this method should only be used for API response data and not user input +func ParseMetricsConfigurationIDInsensitively(input string) (*MetricsConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MetricsConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MetricsConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MetricsConfigurationId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.MetricsConfigurationName, ok = input.Parsed["metricsConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "metricsConfigurationName", input) + } + + return nil +} + +// ValidateMetricsConfigurationID checks that 'input' can be parsed as a Metrics Configuration ID +func ValidateMetricsConfigurationID(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 := ParseMetricsConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Metrics Configuration ID +func (id MetricsConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/clusters/%s/metricsConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.MetricsConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Metrics Configuration ID +func (id MetricsConfigurationId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticMetricsConfigurations", "metricsConfigurations", "metricsConfigurations"), + resourceids.UserSpecifiedSegment("metricsConfigurationName", "metricsConfigurationName"), + } +} + +// String returns a human-readable description of this Metrics Configuration ID +func (id MetricsConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Metrics Configuration Name: %q", id.MetricsConfigurationName), + } + return fmt.Sprintf("Metrics Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration_test.go new file mode 100644 index 00000000000..b2c8f3fd7d7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_metricsconfiguration_test.go @@ -0,0 +1,327 @@ +package networkclouds + +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 = &MetricsConfigurationId{} + +func TestNewMetricsConfigurationID(t *testing.T) { + id := NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.MetricsConfigurationName != "metricsConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'MetricsConfigurationName'", id.MetricsConfigurationName, "metricsConfigurationName") + } +} + +func TestFormatMetricsConfigurationID(t *testing.T) { + actual := NewMetricsConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "metricsConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations/metricsConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMetricsConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MetricsConfigurationId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations/metricsConfigurationName", + Expected: &MetricsConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + MetricsConfigurationName: "metricsConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations/metricsConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMetricsConfigurationID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.MetricsConfigurationName != v.Expected.MetricsConfigurationName { + t.Fatalf("Expected %q but got %q for MetricsConfigurationName", v.Expected.MetricsConfigurationName, actual.MetricsConfigurationName) + } + + } +} + +func TestParseMetricsConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MetricsConfigurationId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/mEtRiCsCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations/metricsConfigurationName", + Expected: &MetricsConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + MetricsConfigurationName: "metricsConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/clusters/clusterName/metricsConfigurations/metricsConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/mEtRiCsCoNfIgUrAtIoNs/mEtRiCsCoNfIgUrAtIoNnAmE", + Expected: &MetricsConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + MetricsConfigurationName: "mEtRiCsCoNfIgUrAtIoNnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/cLuStErS/cLuStErNaMe/mEtRiCsCoNfIgUrAtIoNs/mEtRiCsCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMetricsConfigurationIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.MetricsConfigurationName != v.Expected.MetricsConfigurationName { + t.Fatalf("Expected %q but got %q for MetricsConfigurationName", v.Expected.MetricsConfigurationName, actual.MetricsConfigurationName) + } + + } +} + +func TestSegmentsForMetricsConfigurationId(t *testing.T) { + segments := MetricsConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MetricsConfigurationId 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/networkcloud/2024-07-01/networkclouds/id_rack.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_rack.go new file mode 100644 index 00000000000..7f58665b99b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_rack.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RackId{}) +} + +var _ resourceids.ResourceId = &RackId{} + +// RackId is a struct representing the Resource ID for a Rack +type RackId struct { + SubscriptionId string + ResourceGroupName string + RackName string +} + +// NewRackID returns a new RackId struct +func NewRackID(subscriptionId string, resourceGroupName string, rackName string) RackId { + return RackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RackName: rackName, + } +} + +// ParseRackID parses 'input' into a RackId +func ParseRackID(input string) (*RackId, error) { + parser := resourceids.NewParserFromResourceIdType(&RackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRackIDInsensitively parses 'input' case-insensitively into a RackId +// note: this method should only be used for API response data and not user input +func ParseRackIDInsensitively(input string) (*RackId, error) { + parser := resourceids.NewParserFromResourceIdType(&RackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RackId) 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.RackName, ok = input.Parsed["rackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "rackName", input) + } + + return nil +} + +// ValidateRackID checks that 'input' can be parsed as a Rack ID +func ValidateRackID(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 := ParseRackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rack ID +func (id RackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/racks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rack ID +func (id RackId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticRacks", "racks", "racks"), + resourceids.UserSpecifiedSegment("rackName", "rackName"), + } +} + +// String returns a human-readable description of this Rack ID +func (id RackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Rack Name: %q", id.RackName), + } + return fmt.Sprintf("Rack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_rack_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_rack_test.go new file mode 100644 index 00000000000..3c789bd7f68 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_rack_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &RackId{} + +func TestNewRackID(t *testing.T) { + id := NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName") + + 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.RackName != "rackName" { + t.Fatalf("Expected %q but got %q for Segment 'RackName'", id.RackName, "rackName") + } +} + +func TestFormatRackID(t *testing.T) { + actual := NewRackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "rackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks/rackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RackId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks/rackName", + Expected: &RackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RackName: "rackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks/rackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRackID(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.RackName != v.Expected.RackName { + t.Fatalf("Expected %q but got %q for RackName", v.Expected.RackName, actual.RackName) + } + + } +} + +func TestParseRackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RackId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/rAcKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks/rackName", + Expected: &RackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RackName: "rackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/racks/rackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/rAcKs/rAcKnAmE", + Expected: &RackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RackName: "rAcKnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/rAcKs/rAcKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRackIDInsensitively(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.RackName != v.Expected.RackName { + t.Fatalf("Expected %q but got %q for RackName", v.Expected.RackName, actual.RackName) + } + + } +} + +func TestSegmentsForRackId(t *testing.T) { + segments := RackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RackId 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/networkcloud/2024-07-01/networkclouds/id_racksku.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_racksku.go new file mode 100644 index 00000000000..174bcdd5cfb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_racksku.go @@ -0,0 +1,121 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RackSkuId{}) +} + +var _ resourceids.ResourceId = &RackSkuId{} + +// RackSkuId is a struct representing the Resource ID for a Rack Sku +type RackSkuId struct { + SubscriptionId string + RackSkuName string +} + +// NewRackSkuID returns a new RackSkuId struct +func NewRackSkuID(subscriptionId string, rackSkuName string) RackSkuId { + return RackSkuId{ + SubscriptionId: subscriptionId, + RackSkuName: rackSkuName, + } +} + +// ParseRackSkuID parses 'input' into a RackSkuId +func ParseRackSkuID(input string) (*RackSkuId, error) { + parser := resourceids.NewParserFromResourceIdType(&RackSkuId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RackSkuId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRackSkuIDInsensitively parses 'input' case-insensitively into a RackSkuId +// note: this method should only be used for API response data and not user input +func ParseRackSkuIDInsensitively(input string) (*RackSkuId, error) { + parser := resourceids.NewParserFromResourceIdType(&RackSkuId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RackSkuId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RackSkuId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.RackSkuName, ok = input.Parsed["rackSkuName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "rackSkuName", input) + } + + return nil +} + +// ValidateRackSkuID checks that 'input' can be parsed as a Rack Sku ID +func ValidateRackSkuID(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 := ParseRackSkuID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rack Sku ID +func (id RackSkuId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.NetworkCloud/rackSkus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.RackSkuName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rack Sku ID +func (id RackSkuId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticRackSkus", "rackSkus", "rackSkus"), + resourceids.UserSpecifiedSegment("rackSkuName", "rackSkuName"), + } +} + +// String returns a human-readable description of this Rack Sku ID +func (id RackSkuId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Rack Sku Name: %q", id.RackSkuName), + } + return fmt.Sprintf("Rack Sku (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_racksku_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_racksku_test.go new file mode 100644 index 00000000000..b73f0d31ef9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_racksku_test.go @@ -0,0 +1,237 @@ +package networkclouds + +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 = &RackSkuId{} + +func TestNewRackSkuID(t *testing.T) { + id := NewRackSkuID("12345678-1234-9876-4563-123456789012", "rackSkuName") + + 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.RackSkuName != "rackSkuName" { + t.Fatalf("Expected %q but got %q for Segment 'RackSkuName'", id.RackSkuName, "rackSkuName") + } +} + +func TestFormatRackSkuID(t *testing.T) { + actual := NewRackSkuID("12345678-1234-9876-4563-123456789012", "rackSkuName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRackSkuID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RackSkuId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName", + Expected: &RackSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RackSkuName: "rackSkuName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRackSkuID(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.RackSkuName != v.Expected.RackSkuName { + t.Fatalf("Expected %q but got %q for RackSkuName", v.Expected.RackSkuName, actual.RackSkuName) + } + + } +} + +func TestParseRackSkuIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RackSkuId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/rAcKsKuS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName", + Expected: &RackSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RackSkuName: "rackSkuName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/rAcKsKuS/rAcKsKuNaMe", + Expected: &RackSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RackSkuName: "rAcKsKuNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/rAcKsKuS/rAcKsKuNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRackSkuIDInsensitively(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.RackSkuName != v.Expected.RackSkuName { + t.Fatalf("Expected %q but got %q for RackSkuName", v.Expected.RackSkuName, actual.RackSkuName) + } + + } +} + +func TestSegmentsForRackSkuId(t *testing.T) { + segments := RackSkuId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RackSkuId 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/networkcloud/2024-07-01/networkclouds/id_storageappliance.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_storageappliance.go new file mode 100644 index 00000000000..33fe446cefc --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_storageappliance.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&StorageApplianceId{}) +} + +var _ resourceids.ResourceId = &StorageApplianceId{} + +// StorageApplianceId is a struct representing the Resource ID for a Storage Appliance +type StorageApplianceId struct { + SubscriptionId string + ResourceGroupName string + StorageApplianceName string +} + +// NewStorageApplianceID returns a new StorageApplianceId struct +func NewStorageApplianceID(subscriptionId string, resourceGroupName string, storageApplianceName string) StorageApplianceId { + return StorageApplianceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageApplianceName: storageApplianceName, + } +} + +// ParseStorageApplianceID parses 'input' into a StorageApplianceId +func ParseStorageApplianceID(input string) (*StorageApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageApplianceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageApplianceIDInsensitively parses 'input' case-insensitively into a StorageApplianceId +// note: this method should only be used for API response data and not user input +func ParseStorageApplianceIDInsensitively(input string) (*StorageApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageApplianceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageApplianceId) 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.StorageApplianceName, ok = input.Parsed["storageApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageApplianceName", input) + } + + return nil +} + +// ValidateStorageApplianceID checks that 'input' can be parsed as a Storage Appliance ID +func ValidateStorageApplianceID(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 := ParseStorageApplianceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Appliance ID +func (id StorageApplianceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/storageAppliances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageApplianceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Appliance ID +func (id StorageApplianceId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticStorageAppliances", "storageAppliances", "storageAppliances"), + resourceids.UserSpecifiedSegment("storageApplianceName", "storageApplianceName"), + } +} + +// String returns a human-readable description of this Storage Appliance ID +func (id StorageApplianceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Appliance Name: %q", id.StorageApplianceName), + } + return fmt.Sprintf("Storage Appliance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_storageappliance_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_storageappliance_test.go new file mode 100644 index 00000000000..571553aa0cf --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_storageappliance_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &StorageApplianceId{} + +func TestNewStorageApplianceID(t *testing.T) { + id := NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName") + + 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.StorageApplianceName != "storageApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'StorageApplianceName'", id.StorageApplianceName, "storageApplianceName") + } +} + +func TestFormatStorageApplianceID(t *testing.T) { + actual := NewStorageApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageApplianceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances/storageApplianceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageApplianceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageApplianceId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances/storageApplianceName", + Expected: &StorageApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StorageApplianceName: "storageApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances/storageApplianceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageApplianceID(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.StorageApplianceName != v.Expected.StorageApplianceName { + t.Fatalf("Expected %q but got %q for StorageApplianceName", v.Expected.StorageApplianceName, actual.StorageApplianceName) + } + + } +} + +func TestParseStorageApplianceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageApplianceId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/sToRaGeApPlIaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances/storageApplianceName", + Expected: &StorageApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StorageApplianceName: "storageApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/storageAppliances/storageApplianceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/sToRaGeApPlIaNcEs/sToRaGeApPlIaNcEnAmE", + Expected: &StorageApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StorageApplianceName: "sToRaGeApPlIaNcEnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/sToRaGeApPlIaNcEs/sToRaGeApPlIaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageApplianceIDInsensitively(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.StorageApplianceName != v.Expected.StorageApplianceName { + t.Fatalf("Expected %q but got %q for StorageApplianceName", v.Expected.StorageApplianceName, actual.StorageApplianceName) + } + + } +} + +func TestSegmentsForStorageApplianceId(t *testing.T) { + segments := StorageApplianceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageApplianceId 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/networkcloud/2024-07-01/networkclouds/id_trunkednetwork.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_trunkednetwork.go new file mode 100644 index 00000000000..d3abd0ec8a9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_trunkednetwork.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TrunkedNetworkId{}) +} + +var _ resourceids.ResourceId = &TrunkedNetworkId{} + +// TrunkedNetworkId is a struct representing the Resource ID for a Trunked Network +type TrunkedNetworkId struct { + SubscriptionId string + ResourceGroupName string + TrunkedNetworkName string +} + +// NewTrunkedNetworkID returns a new TrunkedNetworkId struct +func NewTrunkedNetworkID(subscriptionId string, resourceGroupName string, trunkedNetworkName string) TrunkedNetworkId { + return TrunkedNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + TrunkedNetworkName: trunkedNetworkName, + } +} + +// ParseTrunkedNetworkID parses 'input' into a TrunkedNetworkId +func ParseTrunkedNetworkID(input string) (*TrunkedNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrunkedNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrunkedNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTrunkedNetworkIDInsensitively parses 'input' case-insensitively into a TrunkedNetworkId +// note: this method should only be used for API response data and not user input +func ParseTrunkedNetworkIDInsensitively(input string) (*TrunkedNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrunkedNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrunkedNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TrunkedNetworkId) 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.TrunkedNetworkName, ok = input.Parsed["trunkedNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "trunkedNetworkName", input) + } + + return nil +} + +// ValidateTrunkedNetworkID checks that 'input' can be parsed as a Trunked Network ID +func ValidateTrunkedNetworkID(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 := ParseTrunkedNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trunked Network ID +func (id TrunkedNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/trunkedNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.TrunkedNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trunked Network ID +func (id TrunkedNetworkId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticTrunkedNetworks", "trunkedNetworks", "trunkedNetworks"), + resourceids.UserSpecifiedSegment("trunkedNetworkName", "trunkedNetworkName"), + } +} + +// String returns a human-readable description of this Trunked Network ID +func (id TrunkedNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Trunked Network Name: %q", id.TrunkedNetworkName), + } + return fmt.Sprintf("Trunked Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_trunkednetwork_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_trunkednetwork_test.go new file mode 100644 index 00000000000..67a0e2d89d7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_trunkednetwork_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &TrunkedNetworkId{} + +func TestNewTrunkedNetworkID(t *testing.T) { + id := NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName") + + 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.TrunkedNetworkName != "trunkedNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'TrunkedNetworkName'", id.TrunkedNetworkName, "trunkedNetworkName") + } +} + +func TestFormatTrunkedNetworkID(t *testing.T) { + actual := NewTrunkedNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trunkedNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTrunkedNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrunkedNetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName", + Expected: &TrunkedNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + TrunkedNetworkName: "trunkedNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrunkedNetworkID(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.TrunkedNetworkName != v.Expected.TrunkedNetworkName { + t.Fatalf("Expected %q but got %q for TrunkedNetworkName", v.Expected.TrunkedNetworkName, actual.TrunkedNetworkName) + } + + } +} + +func TestParseTrunkedNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrunkedNetworkId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/tRuNkEdNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName", + Expected: &TrunkedNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + TrunkedNetworkName: "trunkedNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/tRuNkEdNeTwOrKs/tRuNkEdNeTwOrKnAmE", + Expected: &TrunkedNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + TrunkedNetworkName: "tRuNkEdNeTwOrKnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/tRuNkEdNeTwOrKs/tRuNkEdNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrunkedNetworkIDInsensitively(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.TrunkedNetworkName != v.Expected.TrunkedNetworkName { + t.Fatalf("Expected %q but got %q for TrunkedNetworkName", v.Expected.TrunkedNetworkName, actual.TrunkedNetworkName) + } + + } +} + +func TestSegmentsForTrunkedNetworkId(t *testing.T) { + segments := TrunkedNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TrunkedNetworkId 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/networkcloud/2024-07-01/networkclouds/id_virtualmachine.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_virtualmachine.go new file mode 100644 index 00000000000..4448a7234b8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_virtualmachine.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VirtualMachineId{}) +} + +var _ resourceids.ResourceId = &VirtualMachineId{} + +// VirtualMachineId is a struct representing the Resource ID for a Virtual Machine +type VirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineName string +} + +// NewVirtualMachineID returns a new VirtualMachineId struct +func NewVirtualMachineID(subscriptionId string, resourceGroupName string, virtualMachineName string) VirtualMachineId { + return VirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineName: virtualMachineName, + } +} + +// ParseVirtualMachineID parses 'input' into a VirtualMachineId +func ParseVirtualMachineID(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineIDInsensitively parses 'input' case-insensitively into a VirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineIDInsensitively(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineId) 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.VirtualMachineName, ok = input.Parsed["virtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineName", input) + } + + return nil +} + +// ValidateVirtualMachineID checks that 'input' can be parsed as a Virtual Machine ID +func ValidateVirtualMachineID(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 := ParseVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine ID +func (id VirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/virtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine ID +func (id VirtualMachineId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticVirtualMachines", "virtualMachines", "virtualMachines"), + resourceids.UserSpecifiedSegment("virtualMachineName", "virtualMachineName"), + } +} + +// String returns a human-readable description of this Virtual Machine ID +func (id VirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Name: %q", id.VirtualMachineName), + } + return fmt.Sprintf("Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_virtualmachine_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_virtualmachine_test.go new file mode 100644 index 00000000000..19eefccb396 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_virtualmachine_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &VirtualMachineId{} + +func TestNewVirtualMachineID(t *testing.T) { + id := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + + 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.VirtualMachineName != "virtualMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineName'", id.VirtualMachineName, "virtualMachineName") + } +} + +func TestFormatVirtualMachineID(t *testing.T) { + actual := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineID(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestParseVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/virtualMachines/virtualMachineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineName: "vIrTuAlMaChInEnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineIDInsensitively(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestSegmentsForVirtualMachineId(t *testing.T) { + segments := VirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineId 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/networkcloud/2024-07-01/networkclouds/id_volume.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_volume.go new file mode 100644 index 00000000000..47ff7b7db8b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_volume.go @@ -0,0 +1,130 @@ +package networkclouds + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VolumeId{}) +} + +var _ resourceids.ResourceId = &VolumeId{} + +// VolumeId is a struct representing the Resource ID for a Volume +type VolumeId struct { + SubscriptionId string + ResourceGroupName string + VolumeName string +} + +// NewVolumeID returns a new VolumeId struct +func NewVolumeID(subscriptionId string, resourceGroupName string, volumeName string) VolumeId { + return VolumeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VolumeName: volumeName, + } +} + +// ParseVolumeID parses 'input' into a VolumeId +func ParseVolumeID(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVolumeIDInsensitively parses 'input' case-insensitively into a VolumeId +// note: this method should only be used for API response data and not user input +func ParseVolumeIDInsensitively(input string) (*VolumeId, error) { + parser := resourceids.NewParserFromResourceIdType(&VolumeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VolumeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VolumeId) 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.VolumeName, ok = input.Parsed["volumeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "volumeName", input) + } + + return nil +} + +// ValidateVolumeID checks that 'input' can be parsed as a Volume ID +func ValidateVolumeID(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 := ParseVolumeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Volume ID +func (id VolumeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkCloud/volumes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VolumeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Volume ID +func (id VolumeId) 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("staticMicrosoftNetworkCloud", "Microsoft.NetworkCloud", "Microsoft.NetworkCloud"), + resourceids.StaticSegment("staticVolumes", "volumes", "volumes"), + resourceids.UserSpecifiedSegment("volumeName", "volumeName"), + } +} + +// String returns a human-readable description of this Volume ID +func (id VolumeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Volume Name: %q", id.VolumeName), + } + return fmt.Sprintf("Volume (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/id_volume_test.go b/resource-manager/networkcloud/2024-07-01/networkclouds/id_volume_test.go new file mode 100644 index 00000000000..3de0d43f9ce --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/id_volume_test.go @@ -0,0 +1,282 @@ +package networkclouds + +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 = &VolumeId{} + +func TestNewVolumeID(t *testing.T) { + id := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName") + + 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.VolumeName != "volumeName" { + t.Fatalf("Expected %q but got %q for Segment 'VolumeName'", id.VolumeName, "volumeName") + } +} + +func TestFormatVolumeID(t *testing.T) { + actual := NewVolumeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "volumeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes/volumeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVolumeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes/volumeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeID(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.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestParseVolumeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VolumeId + }{ + { + // 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.NetworkCloud", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vOlUmEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes/volumeName", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VolumeName: "volumeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkCloud/volumes/volumeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkClOuD/vOlUmEs/vOlUmEnAmE", + Expected: &VolumeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VolumeName: "vOlUmEnAmE", + }, + }, + { + // 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.nEtWoRkClOuD/vOlUmEs/vOlUmEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVolumeIDInsensitively(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.VolumeName != v.Expected.VolumeName { + t.Fatalf("Expected %q but got %q for VolumeName", v.Expected.VolumeName, actual.VolumeName) + } + + } +} + +func TestSegmentsForVolumeId(t *testing.T) { + segments := VolumeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VolumeId 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/networkcloud/2024-07-01/networkclouds/method_agentpoolscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolscreateorupdate.go new file mode 100644 index 00000000000..c3f6b7f0760 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 AgentPoolsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// AgentPoolsCreateOrUpdate ... +func (c NetworkcloudsClient) AgentPoolsCreateOrUpdate(ctx context.Context, id AgentPoolId, input AgentPool) (result AgentPoolsCreateOrUpdateOperationResponse, 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 +} + +// AgentPoolsCreateOrUpdateThenPoll performs AgentPoolsCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) AgentPoolsCreateOrUpdateThenPoll(ctx context.Context, id AgentPoolId, input AgentPool) error { + result, err := c.AgentPoolsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AgentPoolsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AgentPoolsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsdelete.go new file mode 100644 index 00000000000..9c072805383 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 AgentPoolsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AgentPoolsDelete ... +func (c NetworkcloudsClient) AgentPoolsDelete(ctx context.Context, id AgentPoolId) (result AgentPoolsDeleteOperationResponse, 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 +} + +// AgentPoolsDeleteThenPoll performs AgentPoolsDelete then polls until it's completed +func (c NetworkcloudsClient) AgentPoolsDeleteThenPoll(ctx context.Context, id AgentPoolId) error { + result, err := c.AgentPoolsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing AgentPoolsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AgentPoolsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsget.go new file mode 100644 index 00000000000..a746e33c607 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 AgentPoolsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// AgentPoolsGet ... +func (c NetworkcloudsClient) AgentPoolsGet(ctx context.Context, id AgentPoolId) (result AgentPoolsGetOperationResponse, 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 + } + + var model AgentPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolslistbykubernetescluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolslistbykubernetescluster.go new file mode 100644 index 00000000000..002e0906e83 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolslistbykubernetescluster.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 AgentPoolsListByKubernetesClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AgentPool +} + +type AgentPoolsListByKubernetesClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []AgentPool +} + +type AgentPoolsListByKubernetesClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AgentPoolsListByKubernetesClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AgentPoolsListByKubernetesCluster ... +func (c NetworkcloudsClient) AgentPoolsListByKubernetesCluster(ctx context.Context, id KubernetesClusterId) (result AgentPoolsListByKubernetesClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AgentPoolsListByKubernetesClusterCustomPager{}, + Path: fmt.Sprintf("%s/agentPools", 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 *[]AgentPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AgentPoolsListByKubernetesClusterComplete retrieves all the results into a single object +func (c NetworkcloudsClient) AgentPoolsListByKubernetesClusterComplete(ctx context.Context, id KubernetesClusterId) (AgentPoolsListByKubernetesClusterCompleteResult, error) { + return c.AgentPoolsListByKubernetesClusterCompleteMatchingPredicate(ctx, id, AgentPoolOperationPredicate{}) +} + +// AgentPoolsListByKubernetesClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) AgentPoolsListByKubernetesClusterCompleteMatchingPredicate(ctx context.Context, id KubernetesClusterId, predicate AgentPoolOperationPredicate) (result AgentPoolsListByKubernetesClusterCompleteResult, err error) { + items := make([]AgentPool, 0) + + resp, err := c.AgentPoolsListByKubernetesCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = AgentPoolsListByKubernetesClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsupdate.go new file mode 100644 index 00000000000..14a0b0cd960 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_agentpoolsupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 AgentPoolsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// AgentPoolsUpdate ... +func (c NetworkcloudsClient) AgentPoolsUpdate(ctx context.Context, id AgentPoolId, input AgentPoolPatchParameters) (result AgentPoolsUpdateOperationResponse, 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 +} + +// AgentPoolsUpdateThenPoll performs AgentPoolsUpdate then polls until it's completed +func (c NetworkcloudsClient) AgentPoolsUpdateThenPoll(ctx context.Context, id AgentPoolId, input AgentPoolPatchParameters) error { + result, err := c.AgentPoolsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AgentPoolsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AgentPoolsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetscreateorupdate.go new file mode 100644 index 00000000000..8c8c1a077d2 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BareMetalMachineKeySetsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachineKeySet +} + +// BareMetalMachineKeySetsCreateOrUpdate ... +func (c NetworkcloudsClient) BareMetalMachineKeySetsCreateOrUpdate(ctx context.Context, id BareMetalMachineKeySetId, input BareMetalMachineKeySet) (result BareMetalMachineKeySetsCreateOrUpdateOperationResponse, 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 +} + +// BareMetalMachineKeySetsCreateOrUpdateThenPoll performs BareMetalMachineKeySetsCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachineKeySetsCreateOrUpdateThenPoll(ctx context.Context, id BareMetalMachineKeySetId, input BareMetalMachineKeySet) error { + result, err := c.BareMetalMachineKeySetsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachineKeySetsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachineKeySetsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsdelete.go new file mode 100644 index 00000000000..cb8d1838e5b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 BareMetalMachineKeySetsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachineKeySetsDelete ... +func (c NetworkcloudsClient) BareMetalMachineKeySetsDelete(ctx context.Context, id BareMetalMachineKeySetId) (result BareMetalMachineKeySetsDeleteOperationResponse, 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 +} + +// BareMetalMachineKeySetsDeleteThenPoll performs BareMetalMachineKeySetsDelete then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachineKeySetsDeleteThenPoll(ctx context.Context, id BareMetalMachineKeySetId) error { + result, err := c.BareMetalMachineKeySetsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachineKeySetsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachineKeySetsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsget.go new file mode 100644 index 00000000000..ff9fe302235 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 BareMetalMachineKeySetsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachineKeySet +} + +// BareMetalMachineKeySetsGet ... +func (c NetworkcloudsClient) BareMetalMachineKeySetsGet(ctx context.Context, id BareMetalMachineKeySetId) (result BareMetalMachineKeySetsGetOperationResponse, 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 + } + + var model BareMetalMachineKeySet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetslistbycluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetslistbycluster.go new file mode 100644 index 00000000000..383e2e9e04e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetslistbycluster.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 BareMetalMachineKeySetsListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BareMetalMachineKeySet +} + +type BareMetalMachineKeySetsListByClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []BareMetalMachineKeySet +} + +type BareMetalMachineKeySetsListByClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *BareMetalMachineKeySetsListByClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// BareMetalMachineKeySetsListByCluster ... +func (c NetworkcloudsClient) BareMetalMachineKeySetsListByCluster(ctx context.Context, id ClusterId) (result BareMetalMachineKeySetsListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &BareMetalMachineKeySetsListByClusterCustomPager{}, + Path: fmt.Sprintf("%s/bareMetalMachineKeySets", 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 *[]BareMetalMachineKeySet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// BareMetalMachineKeySetsListByClusterComplete retrieves all the results into a single object +func (c NetworkcloudsClient) BareMetalMachineKeySetsListByClusterComplete(ctx context.Context, id ClusterId) (BareMetalMachineKeySetsListByClusterCompleteResult, error) { + return c.BareMetalMachineKeySetsListByClusterCompleteMatchingPredicate(ctx, id, BareMetalMachineKeySetOperationPredicate{}) +} + +// BareMetalMachineKeySetsListByClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) BareMetalMachineKeySetsListByClusterCompleteMatchingPredicate(ctx context.Context, id ClusterId, predicate BareMetalMachineKeySetOperationPredicate) (result BareMetalMachineKeySetsListByClusterCompleteResult, err error) { + items := make([]BareMetalMachineKeySet, 0) + + resp, err := c.BareMetalMachineKeySetsListByCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = BareMetalMachineKeySetsListByClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsupdate.go new file mode 100644 index 00000000000..348c44b33f5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinekeysetsupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BareMetalMachineKeySetsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachineKeySet +} + +// BareMetalMachineKeySetsUpdate ... +func (c NetworkcloudsClient) BareMetalMachineKeySetsUpdate(ctx context.Context, id BareMetalMachineKeySetId, input BareMetalMachineKeySetPatchParameters) (result BareMetalMachineKeySetsUpdateOperationResponse, 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 +} + +// BareMetalMachineKeySetsUpdateThenPoll performs BareMetalMachineKeySetsUpdate then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachineKeySetsUpdateThenPoll(ctx context.Context, id BareMetalMachineKeySetId, input BareMetalMachineKeySetPatchParameters) error { + result, err := c.BareMetalMachineKeySetsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachineKeySetsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachineKeySetsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescordon.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescordon.go new file mode 100644 index 00000000000..eb42ba18a1f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescordon.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesCordonOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesCordon ... +func (c NetworkcloudsClient) BareMetalMachinesCordon(ctx context.Context, id BareMetalMachineId, input BareMetalMachineCordonParameters) (result BareMetalMachinesCordonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cordon", 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 +} + +// BareMetalMachinesCordonThenPoll performs BareMetalMachinesCordon then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesCordonThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachineCordonParameters) error { + result, err := c.BareMetalMachinesCordon(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesCordon: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesCordon: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescreateorupdate.go new file mode 100644 index 00000000000..b9d50c325f7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BareMetalMachinesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachine +} + +// BareMetalMachinesCreateOrUpdate ... +func (c NetworkcloudsClient) BareMetalMachinesCreateOrUpdate(ctx context.Context, id BareMetalMachineId, input BareMetalMachine) (result BareMetalMachinesCreateOrUpdateOperationResponse, 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 +} + +// BareMetalMachinesCreateOrUpdateThenPoll performs BareMetalMachinesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesCreateOrUpdateThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachine) error { + result, err := c.BareMetalMachinesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesdelete.go new file mode 100644 index 00000000000..3eeb947a219 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 BareMetalMachinesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesDelete ... +func (c NetworkcloudsClient) BareMetalMachinesDelete(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesDeleteOperationResponse, 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 +} + +// BareMetalMachinesDeleteThenPoll performs BareMetalMachinesDelete then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesDeleteThenPoll(ctx context.Context, id BareMetalMachineId) error { + result, err := c.BareMetalMachinesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesget.go new file mode 100644 index 00000000000..d080ff2b7be --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 BareMetalMachinesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachine +} + +// BareMetalMachinesGet ... +func (c NetworkcloudsClient) BareMetalMachinesGet(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesGetOperationResponse, 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 + } + + var model BareMetalMachine + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbyresourcegroup.go new file mode 100644 index 00000000000..13bac200220 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 BareMetalMachinesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BareMetalMachine +} + +type BareMetalMachinesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []BareMetalMachine +} + +type BareMetalMachinesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *BareMetalMachinesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// BareMetalMachinesListByResourceGroup ... +func (c NetworkcloudsClient) BareMetalMachinesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result BareMetalMachinesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &BareMetalMachinesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/bareMetalMachines", 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 *[]BareMetalMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// BareMetalMachinesListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) BareMetalMachinesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (BareMetalMachinesListByResourceGroupCompleteResult, error) { + return c.BareMetalMachinesListByResourceGroupCompleteMatchingPredicate(ctx, id, BareMetalMachineOperationPredicate{}) +} + +// BareMetalMachinesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) BareMetalMachinesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate BareMetalMachineOperationPredicate) (result BareMetalMachinesListByResourceGroupCompleteResult, err error) { + items := make([]BareMetalMachine, 0) + + resp, err := c.BareMetalMachinesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = BareMetalMachinesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbysubscription.go new file mode 100644 index 00000000000..d7931b5946b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachineslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 BareMetalMachinesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BareMetalMachine +} + +type BareMetalMachinesListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []BareMetalMachine +} + +type BareMetalMachinesListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *BareMetalMachinesListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// BareMetalMachinesListBySubscription ... +func (c NetworkcloudsClient) BareMetalMachinesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result BareMetalMachinesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &BareMetalMachinesListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/bareMetalMachines", 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 *[]BareMetalMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// BareMetalMachinesListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) BareMetalMachinesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (BareMetalMachinesListBySubscriptionCompleteResult, error) { + return c.BareMetalMachinesListBySubscriptionCompleteMatchingPredicate(ctx, id, BareMetalMachineOperationPredicate{}) +} + +// BareMetalMachinesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) BareMetalMachinesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BareMetalMachineOperationPredicate) (result BareMetalMachinesListBySubscriptionCompleteResult, err error) { + items := make([]BareMetalMachine, 0) + + resp, err := c.BareMetalMachinesListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = BareMetalMachinesListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinespoweroff.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinespoweroff.go new file mode 100644 index 00000000000..c4777fc6cb9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinespoweroff.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesPowerOffOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesPowerOff ... +func (c NetworkcloudsClient) BareMetalMachinesPowerOff(ctx context.Context, id BareMetalMachineId, input BareMetalMachinePowerOffParameters) (result BareMetalMachinesPowerOffOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/powerOff", 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 +} + +// BareMetalMachinesPowerOffThenPoll performs BareMetalMachinesPowerOff then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesPowerOffThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachinePowerOffParameters) error { + result, err := c.BareMetalMachinesPowerOff(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesPowerOff: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesPowerOff: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreimage.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreimage.go new file mode 100644 index 00000000000..0cde6e33e2e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreimage.go @@ -0,0 +1,69 @@ +package networkclouds + +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 BareMetalMachinesReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesReimage ... +func (c NetworkcloudsClient) BareMetalMachinesReimage(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", 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 +} + +// BareMetalMachinesReimageThenPoll performs BareMetalMachinesReimage then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesReimageThenPoll(ctx context.Context, id BareMetalMachineId) error { + result, err := c.BareMetalMachinesReimage(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesReimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesReimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreplace.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreplace.go new file mode 100644 index 00000000000..a7d7333dcb1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesreplace.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesReplaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesReplace ... +func (c NetworkcloudsClient) BareMetalMachinesReplace(ctx context.Context, id BareMetalMachineId, input BareMetalMachineReplaceParameters) (result BareMetalMachinesReplaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replace", 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 +} + +// BareMetalMachinesReplaceThenPoll performs BareMetalMachinesReplace then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesReplaceThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachineReplaceParameters) error { + result, err := c.BareMetalMachinesReplace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesReplace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesReplace: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrestart.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrestart.go new file mode 100644 index 00000000000..64e9435b595 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrestart.go @@ -0,0 +1,69 @@ +package networkclouds + +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 BareMetalMachinesRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesRestart ... +func (c NetworkcloudsClient) BareMetalMachinesRestart(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// BareMetalMachinesRestartThenPoll performs BareMetalMachinesRestart then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesRestartThenPoll(ctx context.Context, id BareMetalMachineId) error { + result, err := c.BareMetalMachinesRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesruncommand.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesruncommand.go new file mode 100644 index 00000000000..eaa4f69b416 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesruncommand.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesRunCommandOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesRunCommand ... +func (c NetworkcloudsClient) BareMetalMachinesRunCommand(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunCommandParameters) (result BareMetalMachinesRunCommandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/runCommand", 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 +} + +// BareMetalMachinesRunCommandThenPoll performs BareMetalMachinesRunCommand then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesRunCommandThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunCommandParameters) error { + result, err := c.BareMetalMachinesRunCommand(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesRunCommand: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesRunCommand: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrundataextracts.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrundataextracts.go new file mode 100644 index 00000000000..fa5b83c0493 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrundataextracts.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesRunDataExtractsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesRunDataExtracts ... +func (c NetworkcloudsClient) BareMetalMachinesRunDataExtracts(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunDataExtractsParameters) (result BareMetalMachinesRunDataExtractsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/runDataExtracts", 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 +} + +// BareMetalMachinesRunDataExtractsThenPoll performs BareMetalMachinesRunDataExtracts then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesRunDataExtractsThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunDataExtractsParameters) error { + result, err := c.BareMetalMachinesRunDataExtracts(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesRunDataExtracts: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesRunDataExtracts: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrunreadcommands.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrunreadcommands.go new file mode 100644 index 00000000000..fc68d3e1510 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesrunreadcommands.go @@ -0,0 +1,73 @@ +package networkclouds + +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 BareMetalMachinesRunReadCommandsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesRunReadCommands ... +func (c NetworkcloudsClient) BareMetalMachinesRunReadCommands(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunReadCommandsParameters) (result BareMetalMachinesRunReadCommandsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/runReadCommands", 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 +} + +// BareMetalMachinesRunReadCommandsThenPoll performs BareMetalMachinesRunReadCommands then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesRunReadCommandsThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachineRunReadCommandsParameters) error { + result, err := c.BareMetalMachinesRunReadCommands(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesRunReadCommands: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesRunReadCommands: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesstart.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesstart.go new file mode 100644 index 00000000000..9ec5f8797fd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesstart.go @@ -0,0 +1,69 @@ +package networkclouds + +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 BareMetalMachinesStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesStart ... +func (c NetworkcloudsClient) BareMetalMachinesStart(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// BareMetalMachinesStartThenPoll performs BareMetalMachinesStart then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesStartThenPoll(ctx context.Context, id BareMetalMachineId) error { + result, err := c.BareMetalMachinesStart(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesuncordon.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesuncordon.go new file mode 100644 index 00000000000..3287a136e58 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesuncordon.go @@ -0,0 +1,69 @@ +package networkclouds + +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 BareMetalMachinesUncordonOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BareMetalMachinesUncordon ... +func (c NetworkcloudsClient) BareMetalMachinesUncordon(ctx context.Context, id BareMetalMachineId) (result BareMetalMachinesUncordonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/uncordon", 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 +} + +// BareMetalMachinesUncordonThenPoll performs BareMetalMachinesUncordon then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesUncordonThenPoll(ctx context.Context, id BareMetalMachineId) error { + result, err := c.BareMetalMachinesUncordon(ctx, id) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesUncordon: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesUncordon: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesupdate.go new file mode 100644 index 00000000000..05806ecab3e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_baremetalmachinesupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BareMetalMachinesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BareMetalMachine +} + +// BareMetalMachinesUpdate ... +func (c NetworkcloudsClient) BareMetalMachinesUpdate(ctx context.Context, id BareMetalMachineId, input BareMetalMachinePatchParameters) (result BareMetalMachinesUpdateOperationResponse, 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 +} + +// BareMetalMachinesUpdateThenPoll performs BareMetalMachinesUpdate then polls until it's completed +func (c NetworkcloudsClient) BareMetalMachinesUpdateThenPoll(ctx context.Context, id BareMetalMachineId, input BareMetalMachinePatchParameters) error { + result, err := c.BareMetalMachinesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BareMetalMachinesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BareMetalMachinesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetscreateorupdate.go new file mode 100644 index 00000000000..248a5efd257 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BmcKeySetsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BmcKeySet +} + +// BmcKeySetsCreateOrUpdate ... +func (c NetworkcloudsClient) BmcKeySetsCreateOrUpdate(ctx context.Context, id BmcKeySetId, input BmcKeySet) (result BmcKeySetsCreateOrUpdateOperationResponse, 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 +} + +// BmcKeySetsCreateOrUpdateThenPoll performs BmcKeySetsCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) BmcKeySetsCreateOrUpdateThenPoll(ctx context.Context, id BmcKeySetId, input BmcKeySet) error { + result, err := c.BmcKeySetsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BmcKeySetsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BmcKeySetsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsdelete.go new file mode 100644 index 00000000000..7b0476fb02c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 BmcKeySetsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BmcKeySetsDelete ... +func (c NetworkcloudsClient) BmcKeySetsDelete(ctx context.Context, id BmcKeySetId) (result BmcKeySetsDeleteOperationResponse, 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 +} + +// BmcKeySetsDeleteThenPoll performs BmcKeySetsDelete then polls until it's completed +func (c NetworkcloudsClient) BmcKeySetsDeleteThenPoll(ctx context.Context, id BmcKeySetId) error { + result, err := c.BmcKeySetsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing BmcKeySetsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BmcKeySetsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsget.go new file mode 100644 index 00000000000..78cdd8c9028 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 BmcKeySetsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BmcKeySet +} + +// BmcKeySetsGet ... +func (c NetworkcloudsClient) BmcKeySetsGet(ctx context.Context, id BmcKeySetId) (result BmcKeySetsGetOperationResponse, 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 + } + + var model BmcKeySet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetslistbycluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetslistbycluster.go new file mode 100644 index 00000000000..8f2b7821e9f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetslistbycluster.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 BmcKeySetsListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BmcKeySet +} + +type BmcKeySetsListByClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []BmcKeySet +} + +type BmcKeySetsListByClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *BmcKeySetsListByClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// BmcKeySetsListByCluster ... +func (c NetworkcloudsClient) BmcKeySetsListByCluster(ctx context.Context, id ClusterId) (result BmcKeySetsListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &BmcKeySetsListByClusterCustomPager{}, + Path: fmt.Sprintf("%s/bmcKeySets", 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 *[]BmcKeySet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// BmcKeySetsListByClusterComplete retrieves all the results into a single object +func (c NetworkcloudsClient) BmcKeySetsListByClusterComplete(ctx context.Context, id ClusterId) (BmcKeySetsListByClusterCompleteResult, error) { + return c.BmcKeySetsListByClusterCompleteMatchingPredicate(ctx, id, BmcKeySetOperationPredicate{}) +} + +// BmcKeySetsListByClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) BmcKeySetsListByClusterCompleteMatchingPredicate(ctx context.Context, id ClusterId, predicate BmcKeySetOperationPredicate) (result BmcKeySetsListByClusterCompleteResult, err error) { + items := make([]BmcKeySet, 0) + + resp, err := c.BmcKeySetsListByCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = BmcKeySetsListByClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsupdate.go new file mode 100644 index 00000000000..009b882270c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_bmckeysetsupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 BmcKeySetsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BmcKeySet +} + +// BmcKeySetsUpdate ... +func (c NetworkcloudsClient) BmcKeySetsUpdate(ctx context.Context, id BmcKeySetId, input BmcKeySetPatchParameters) (result BmcKeySetsUpdateOperationResponse, 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 +} + +// BmcKeySetsUpdateThenPoll performs BmcKeySetsUpdate then polls until it's completed +func (c NetworkcloudsClient) BmcKeySetsUpdateThenPoll(ctx context.Context, id BmcKeySetId, input BmcKeySetPatchParameters) error { + result, err := c.BmcKeySetsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BmcKeySetsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BmcKeySetsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkscreateorupdate.go new file mode 100644 index 00000000000..d1f80ab6afa --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 CloudServicesNetworksCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudServicesNetwork +} + +// CloudServicesNetworksCreateOrUpdate ... +func (c NetworkcloudsClient) CloudServicesNetworksCreateOrUpdate(ctx context.Context, id CloudServicesNetworkId, input CloudServicesNetwork) (result CloudServicesNetworksCreateOrUpdateOperationResponse, 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 +} + +// CloudServicesNetworksCreateOrUpdateThenPoll performs CloudServicesNetworksCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) CloudServicesNetworksCreateOrUpdateThenPoll(ctx context.Context, id CloudServicesNetworkId, input CloudServicesNetwork) error { + result, err := c.CloudServicesNetworksCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudServicesNetworksCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudServicesNetworksCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksdelete.go new file mode 100644 index 00000000000..b897921e160 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 CloudServicesNetworksDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CloudServicesNetworksDelete ... +func (c NetworkcloudsClient) CloudServicesNetworksDelete(ctx context.Context, id CloudServicesNetworkId) (result CloudServicesNetworksDeleteOperationResponse, 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 +} + +// CloudServicesNetworksDeleteThenPoll performs CloudServicesNetworksDelete then polls until it's completed +func (c NetworkcloudsClient) CloudServicesNetworksDeleteThenPoll(ctx context.Context, id CloudServicesNetworkId) error { + result, err := c.CloudServicesNetworksDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CloudServicesNetworksDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudServicesNetworksDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksget.go new file mode 100644 index 00000000000..f13d813b1b4 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 CloudServicesNetworksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CloudServicesNetwork +} + +// CloudServicesNetworksGet ... +func (c NetworkcloudsClient) CloudServicesNetworksGet(ctx context.Context, id CloudServicesNetworkId) (result CloudServicesNetworksGetOperationResponse, 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 + } + + var model CloudServicesNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbyresourcegroup.go new file mode 100644 index 00000000000..0c3ce2aad54 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 CloudServicesNetworksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudServicesNetwork +} + +type CloudServicesNetworksListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudServicesNetwork +} + +type CloudServicesNetworksListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudServicesNetworksListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudServicesNetworksListByResourceGroup ... +func (c NetworkcloudsClient) CloudServicesNetworksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result CloudServicesNetworksListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudServicesNetworksListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/cloudServicesNetworks", 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 *[]CloudServicesNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudServicesNetworksListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) CloudServicesNetworksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (CloudServicesNetworksListByResourceGroupCompleteResult, error) { + return c.CloudServicesNetworksListByResourceGroupCompleteMatchingPredicate(ctx, id, CloudServicesNetworkOperationPredicate{}) +} + +// CloudServicesNetworksListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) CloudServicesNetworksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CloudServicesNetworkOperationPredicate) (result CloudServicesNetworksListByResourceGroupCompleteResult, err error) { + items := make([]CloudServicesNetwork, 0) + + resp, err := c.CloudServicesNetworksListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = CloudServicesNetworksListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbysubscription.go new file mode 100644 index 00000000000..ecb758fefab --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworkslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 CloudServicesNetworksListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudServicesNetwork +} + +type CloudServicesNetworksListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudServicesNetwork +} + +type CloudServicesNetworksListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudServicesNetworksListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudServicesNetworksListBySubscription ... +func (c NetworkcloudsClient) CloudServicesNetworksListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result CloudServicesNetworksListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudServicesNetworksListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/cloudServicesNetworks", 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 *[]CloudServicesNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudServicesNetworksListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) CloudServicesNetworksListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (CloudServicesNetworksListBySubscriptionCompleteResult, error) { + return c.CloudServicesNetworksListBySubscriptionCompleteMatchingPredicate(ctx, id, CloudServicesNetworkOperationPredicate{}) +} + +// CloudServicesNetworksListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) CloudServicesNetworksListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CloudServicesNetworkOperationPredicate) (result CloudServicesNetworksListBySubscriptionCompleteResult, err error) { + items := make([]CloudServicesNetwork, 0) + + resp, err := c.CloudServicesNetworksListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = CloudServicesNetworksListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksupdate.go new file mode 100644 index 00000000000..276001a7232 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_cloudservicesnetworksupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 CloudServicesNetworksUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudServicesNetwork +} + +// CloudServicesNetworksUpdate ... +func (c NetworkcloudsClient) CloudServicesNetworksUpdate(ctx context.Context, id CloudServicesNetworkId, input CloudServicesNetworkPatchParameters) (result CloudServicesNetworksUpdateOperationResponse, 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 +} + +// CloudServicesNetworksUpdateThenPoll performs CloudServicesNetworksUpdate then polls until it's completed +func (c NetworkcloudsClient) CloudServicesNetworksUpdateThenPoll(ctx context.Context, id CloudServicesNetworkId, input CloudServicesNetworkPatchParameters) error { + result, err := c.CloudServicesNetworksUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudServicesNetworksUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudServicesNetworksUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerscreateorupdate.go new file mode 100644 index 00000000000..cc00c701ddc --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 ClusterManagersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterManager +} + +// ClusterManagersCreateOrUpdate ... +func (c NetworkcloudsClient) ClusterManagersCreateOrUpdate(ctx context.Context, id ClusterManagerId, input ClusterManager) (result ClusterManagersCreateOrUpdateOperationResponse, 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 +} + +// ClusterManagersCreateOrUpdateThenPoll performs ClusterManagersCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) ClusterManagersCreateOrUpdateThenPoll(ctx context.Context, id ClusterManagerId, input ClusterManager) error { + result, err := c.ClusterManagersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClusterManagersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClusterManagersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersdelete.go new file mode 100644 index 00000000000..aedd6b39c44 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 ClusterManagersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClusterManagersDelete ... +func (c NetworkcloudsClient) ClusterManagersDelete(ctx context.Context, id ClusterManagerId) (result ClusterManagersDeleteOperationResponse, 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 +} + +// ClusterManagersDeleteThenPoll performs ClusterManagersDelete then polls until it's completed +func (c NetworkcloudsClient) ClusterManagersDeleteThenPoll(ctx context.Context, id ClusterManagerId) error { + result, err := c.ClusterManagersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ClusterManagersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClusterManagersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersget.go new file mode 100644 index 00000000000..017316c2566 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 ClusterManagersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterManager +} + +// ClusterManagersGet ... +func (c NetworkcloudsClient) ClusterManagersGet(ctx context.Context, id ClusterManagerId) (result ClusterManagersGetOperationResponse, 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 + } + + var model ClusterManager + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbyresourcegroup.go new file mode 100644 index 00000000000..0f35f56bc35 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 ClusterManagersListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ClusterManager +} + +type ClusterManagersListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ClusterManager +} + +type ClusterManagersListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ClusterManagersListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ClusterManagersListByResourceGroup ... +func (c NetworkcloudsClient) ClusterManagersListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ClusterManagersListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ClusterManagersListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/clusterManagers", 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 *[]ClusterManager `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ClusterManagersListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) ClusterManagersListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ClusterManagersListByResourceGroupCompleteResult, error) { + return c.ClusterManagersListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterManagerOperationPredicate{}) +} + +// ClusterManagersListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) ClusterManagersListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterManagerOperationPredicate) (result ClusterManagersListByResourceGroupCompleteResult, err error) { + items := make([]ClusterManager, 0) + + resp, err := c.ClusterManagersListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ClusterManagersListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbysubscription.go new file mode 100644 index 00000000000..40796857573 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagerslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 ClusterManagersListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ClusterManager +} + +type ClusterManagersListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ClusterManager +} + +type ClusterManagersListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ClusterManagersListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ClusterManagersListBySubscription ... +func (c NetworkcloudsClient) ClusterManagersListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ClusterManagersListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ClusterManagersListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/clusterManagers", 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 *[]ClusterManager `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ClusterManagersListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) ClusterManagersListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ClusterManagersListBySubscriptionCompleteResult, error) { + return c.ClusterManagersListBySubscriptionCompleteMatchingPredicate(ctx, id, ClusterManagerOperationPredicate{}) +} + +// ClusterManagersListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) ClusterManagersListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterManagerOperationPredicate) (result ClusterManagersListBySubscriptionCompleteResult, err error) { + items := make([]ClusterManager, 0) + + resp, err := c.ClusterManagersListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ClusterManagersListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersupdate.go new file mode 100644 index 00000000000..2b971cbbe9f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustermanagersupdate.go @@ -0,0 +1,57 @@ +package networkclouds + +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 ClusterManagersUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterManager +} + +// ClusterManagersUpdate ... +func (c NetworkcloudsClient) ClusterManagersUpdate(ctx context.Context, id ClusterManagerId, input ClusterManagerPatchParameters) (result ClusterManagersUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ClusterManager + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscontinueupdateversion.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscontinueupdateversion.go new file mode 100644 index 00000000000..c16c80fb9fb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscontinueupdateversion.go @@ -0,0 +1,73 @@ +package networkclouds + +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 ClustersContinueUpdateVersionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClustersContinueUpdateVersion ... +func (c NetworkcloudsClient) ClustersContinueUpdateVersion(ctx context.Context, id ClusterId, input ClusterContinueUpdateVersionParameters) (result ClustersContinueUpdateVersionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/continueUpdateVersion", 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 +} + +// ClustersContinueUpdateVersionThenPoll performs ClustersContinueUpdateVersion then polls until it's completed +func (c NetworkcloudsClient) ClustersContinueUpdateVersionThenPoll(ctx context.Context, id ClusterId, input ClusterContinueUpdateVersionParameters) error { + result, err := c.ClustersContinueUpdateVersion(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersContinueUpdateVersion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersContinueUpdateVersion: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscreateorupdate.go new file mode 100644 index 00000000000..6eb05c22fef --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 ClustersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Cluster +} + +// ClustersCreateOrUpdate ... +func (c NetworkcloudsClient) ClustersCreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (result ClustersCreateOrUpdateOperationResponse, 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 +} + +// ClustersCreateOrUpdateThenPoll performs ClustersCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) ClustersCreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) error { + result, err := c.ClustersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdelete.go new file mode 100644 index 00000000000..fc7b1e4fdcf --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 ClustersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClustersDelete ... +func (c NetworkcloudsClient) ClustersDelete(ctx context.Context, id ClusterId) (result ClustersDeleteOperationResponse, 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 +} + +// ClustersDeleteThenPoll performs ClustersDelete then polls until it's completed +func (c NetworkcloudsClient) ClustersDeleteThenPoll(ctx context.Context, id ClusterId) error { + result, err := c.ClustersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ClustersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdeploy.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdeploy.go new file mode 100644 index 00000000000..12c19931f03 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersdeploy.go @@ -0,0 +1,73 @@ +package networkclouds + +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 ClustersDeployOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClustersDeploy ... +func (c NetworkcloudsClient) ClustersDeploy(ctx context.Context, id ClusterId, input ClusterDeployParameters) (result ClustersDeployOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deploy", 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 +} + +// ClustersDeployThenPoll performs ClustersDeploy then polls until it's completed +func (c NetworkcloudsClient) ClustersDeployThenPoll(ctx context.Context, id ClusterId, input ClusterDeployParameters) error { + result, err := c.ClustersDeploy(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersDeploy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersDeploy: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersget.go new file mode 100644 index 00000000000..8fc66fdfcd8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 ClustersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Cluster +} + +// ClustersGet ... +func (c NetworkcloudsClient) ClustersGet(ctx context.Context, id ClusterId) (result ClustersGetOperationResponse, 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 + } + + var model Cluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbyresourcegroup.go new file mode 100644 index 00000000000..c929ab55c6f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 ClustersListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cluster +} + +type ClustersListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +type ClustersListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ClustersListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ClustersListByResourceGroup ... +func (c NetworkcloudsClient) ClustersListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ClustersListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ClustersListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/clusters", 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 *[]Cluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ClustersListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) ClustersListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ClustersListByResourceGroupCompleteResult, error) { + return c.ClustersListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ClustersListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) ClustersListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterOperationPredicate) (result ClustersListByResourceGroupCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.ClustersListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ClustersListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbysubscription.go new file mode 100644 index 00000000000..d1984a6090b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clusterslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 ClustersListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cluster +} + +type ClustersListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +type ClustersListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ClustersListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ClustersListBySubscription ... +func (c NetworkcloudsClient) ClustersListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ClustersListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ClustersListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/clusters", 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 *[]Cluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ClustersListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) ClustersListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ClustersListBySubscriptionCompleteResult, error) { + return c.ClustersListBySubscriptionCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ClustersListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) ClustersListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterOperationPredicate) (result ClustersListBySubscriptionCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.ClustersListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ClustersListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersscanruntime.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersscanruntime.go new file mode 100644 index 00000000000..da4179ab025 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersscanruntime.go @@ -0,0 +1,73 @@ +package networkclouds + +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 ClustersScanRuntimeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClustersScanRuntime ... +func (c NetworkcloudsClient) ClustersScanRuntime(ctx context.Context, id ClusterId, input ClusterScanRuntimeParameters) (result ClustersScanRuntimeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/scanRuntime", 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 +} + +// ClustersScanRuntimeThenPoll performs ClustersScanRuntime then polls until it's completed +func (c NetworkcloudsClient) ClustersScanRuntimeThenPoll(ctx context.Context, id ClusterId, input ClusterScanRuntimeParameters) error { + result, err := c.ClustersScanRuntime(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersScanRuntime: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersScanRuntime: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdate.go new file mode 100644 index 00000000000..2253ccaf488 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 ClustersUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Cluster +} + +// ClustersUpdate ... +func (c NetworkcloudsClient) ClustersUpdate(ctx context.Context, id ClusterId, input ClusterPatchParameters) (result ClustersUpdateOperationResponse, 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 +} + +// ClustersUpdateThenPoll performs ClustersUpdate then polls until it's completed +func (c NetworkcloudsClient) ClustersUpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatchParameters) error { + result, err := c.ClustersUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdateversion.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdateversion.go new file mode 100644 index 00000000000..b4ec2961ed3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_clustersupdateversion.go @@ -0,0 +1,73 @@ +package networkclouds + +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 ClustersUpdateVersionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ClustersUpdateVersion ... +func (c NetworkcloudsClient) ClustersUpdateVersion(ctx context.Context, id ClusterId, input ClusterUpdateVersionParameters) (result ClustersUpdateVersionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateVersion", 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 +} + +// ClustersUpdateVersionThenPoll performs ClustersUpdateVersion then polls until it's completed +func (c NetworkcloudsClient) ClustersUpdateVersionThenPoll(ctx context.Context, id ClusterId, input ClusterUpdateVersionParameters) error { + result, err := c.ClustersUpdateVersion(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ClustersUpdateVersion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ClustersUpdateVersion: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolescreateorupdate.go new file mode 100644 index 00000000000..7dc5cb61c8e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 ConsolesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Console +} + +// ConsolesCreateOrUpdate ... +func (c NetworkcloudsClient) ConsolesCreateOrUpdate(ctx context.Context, id ConsoleId, input Console) (result ConsolesCreateOrUpdateOperationResponse, 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 +} + +// ConsolesCreateOrUpdateThenPoll performs ConsolesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) ConsolesCreateOrUpdateThenPoll(ctx context.Context, id ConsoleId, input Console) error { + result, err := c.ConsolesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ConsolesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConsolesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesdelete.go new file mode 100644 index 00000000000..76111087b7a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 ConsolesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ConsolesDelete ... +func (c NetworkcloudsClient) ConsolesDelete(ctx context.Context, id ConsoleId) (result ConsolesDeleteOperationResponse, 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 +} + +// ConsolesDeleteThenPoll performs ConsolesDelete then polls until it's completed +func (c NetworkcloudsClient) ConsolesDeleteThenPoll(ctx context.Context, id ConsoleId) error { + result, err := c.ConsolesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ConsolesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConsolesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesget.go new file mode 100644 index 00000000000..35ca3b11c8e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 ConsolesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Console +} + +// ConsolesGet ... +func (c NetworkcloudsClient) ConsolesGet(ctx context.Context, id ConsoleId) (result ConsolesGetOperationResponse, 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 + } + + var model Console + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_consoleslistbyvirtualmachine.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consoleslistbyvirtualmachine.go new file mode 100644 index 00000000000..eb52d7381c0 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consoleslistbyvirtualmachine.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 ConsolesListByVirtualMachineOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Console +} + +type ConsolesListByVirtualMachineCompleteResult struct { + LatestHttpResponse *http.Response + Items []Console +} + +type ConsolesListByVirtualMachineCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ConsolesListByVirtualMachineCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ConsolesListByVirtualMachine ... +func (c NetworkcloudsClient) ConsolesListByVirtualMachine(ctx context.Context, id VirtualMachineId) (result ConsolesListByVirtualMachineOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ConsolesListByVirtualMachineCustomPager{}, + Path: fmt.Sprintf("%s/consoles", 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 *[]Console `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConsolesListByVirtualMachineComplete retrieves all the results into a single object +func (c NetworkcloudsClient) ConsolesListByVirtualMachineComplete(ctx context.Context, id VirtualMachineId) (ConsolesListByVirtualMachineCompleteResult, error) { + return c.ConsolesListByVirtualMachineCompleteMatchingPredicate(ctx, id, ConsoleOperationPredicate{}) +} + +// ConsolesListByVirtualMachineCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) ConsolesListByVirtualMachineCompleteMatchingPredicate(ctx context.Context, id VirtualMachineId, predicate ConsoleOperationPredicate) (result ConsolesListByVirtualMachineCompleteResult, err error) { + items := make([]Console, 0) + + resp, err := c.ConsolesListByVirtualMachine(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ConsolesListByVirtualMachineCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesupdate.go new file mode 100644 index 00000000000..d83e293a7db --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_consolesupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 ConsolesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Console +} + +// ConsolesUpdate ... +func (c NetworkcloudsClient) ConsolesUpdate(ctx context.Context, id ConsoleId, input ConsolePatchParameters) (result ConsolesUpdateOperationResponse, 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 +} + +// ConsolesUpdateThenPoll performs ConsolesUpdate then polls until it's completed +func (c NetworkcloudsClient) ConsolesUpdateThenPoll(ctx context.Context, id ConsoleId, input ConsolePatchParameters) error { + result, err := c.ConsolesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ConsolesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConsolesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturescreateorupdate.go new file mode 100644 index 00000000000..ccc07af4b36 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 KubernetesClusterFeaturesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesClusterFeature +} + +// KubernetesClusterFeaturesCreateOrUpdate ... +func (c NetworkcloudsClient) KubernetesClusterFeaturesCreateOrUpdate(ctx context.Context, id FeatureId, input KubernetesClusterFeature) (result KubernetesClusterFeaturesCreateOrUpdateOperationResponse, 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 +} + +// KubernetesClusterFeaturesCreateOrUpdateThenPoll performs KubernetesClusterFeaturesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) KubernetesClusterFeaturesCreateOrUpdateThenPoll(ctx context.Context, id FeatureId, input KubernetesClusterFeature) error { + result, err := c.KubernetesClusterFeaturesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing KubernetesClusterFeaturesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClusterFeaturesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesdelete.go new file mode 100644 index 00000000000..95c8c9bda34 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 KubernetesClusterFeaturesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// KubernetesClusterFeaturesDelete ... +func (c NetworkcloudsClient) KubernetesClusterFeaturesDelete(ctx context.Context, id FeatureId) (result KubernetesClusterFeaturesDeleteOperationResponse, 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 +} + +// KubernetesClusterFeaturesDeleteThenPoll performs KubernetesClusterFeaturesDelete then polls until it's completed +func (c NetworkcloudsClient) KubernetesClusterFeaturesDeleteThenPoll(ctx context.Context, id FeatureId) error { + result, err := c.KubernetesClusterFeaturesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing KubernetesClusterFeaturesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClusterFeaturesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesget.go new file mode 100644 index 00000000000..c79e38fd837 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 KubernetesClusterFeaturesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesClusterFeature +} + +// KubernetesClusterFeaturesGet ... +func (c NetworkcloudsClient) KubernetesClusterFeaturesGet(ctx context.Context, id FeatureId) (result KubernetesClusterFeaturesGetOperationResponse, 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 + } + + var model KubernetesClusterFeature + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeatureslistbykubernetescluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeatureslistbykubernetescluster.go new file mode 100644 index 00000000000..94eb89204fe --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeatureslistbykubernetescluster.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 KubernetesClusterFeaturesListByKubernetesClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubernetesClusterFeature +} + +type KubernetesClusterFeaturesListByKubernetesClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubernetesClusterFeature +} + +type KubernetesClusterFeaturesListByKubernetesClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *KubernetesClusterFeaturesListByKubernetesClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// KubernetesClusterFeaturesListByKubernetesCluster ... +func (c NetworkcloudsClient) KubernetesClusterFeaturesListByKubernetesCluster(ctx context.Context, id KubernetesClusterId) (result KubernetesClusterFeaturesListByKubernetesClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &KubernetesClusterFeaturesListByKubernetesClusterCustomPager{}, + Path: fmt.Sprintf("%s/features", 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 *[]KubernetesClusterFeature `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// KubernetesClusterFeaturesListByKubernetesClusterComplete retrieves all the results into a single object +func (c NetworkcloudsClient) KubernetesClusterFeaturesListByKubernetesClusterComplete(ctx context.Context, id KubernetesClusterId) (KubernetesClusterFeaturesListByKubernetesClusterCompleteResult, error) { + return c.KubernetesClusterFeaturesListByKubernetesClusterCompleteMatchingPredicate(ctx, id, KubernetesClusterFeatureOperationPredicate{}) +} + +// KubernetesClusterFeaturesListByKubernetesClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) KubernetesClusterFeaturesListByKubernetesClusterCompleteMatchingPredicate(ctx context.Context, id KubernetesClusterId, predicate KubernetesClusterFeatureOperationPredicate) (result KubernetesClusterFeaturesListByKubernetesClusterCompleteResult, err error) { + items := make([]KubernetesClusterFeature, 0) + + resp, err := c.KubernetesClusterFeaturesListByKubernetesCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = KubernetesClusterFeaturesListByKubernetesClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesupdate.go new file mode 100644 index 00000000000..38dc862bd0b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterfeaturesupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 KubernetesClusterFeaturesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesClusterFeature +} + +// KubernetesClusterFeaturesUpdate ... +func (c NetworkcloudsClient) KubernetesClusterFeaturesUpdate(ctx context.Context, id FeatureId, input KubernetesClusterFeaturePatchParameters) (result KubernetesClusterFeaturesUpdateOperationResponse, 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 +} + +// KubernetesClusterFeaturesUpdateThenPoll performs KubernetesClusterFeaturesUpdate then polls until it's completed +func (c NetworkcloudsClient) KubernetesClusterFeaturesUpdateThenPoll(ctx context.Context, id FeatureId, input KubernetesClusterFeaturePatchParameters) error { + result, err := c.KubernetesClusterFeaturesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing KubernetesClusterFeaturesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClusterFeaturesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterscreateorupdate.go new file mode 100644 index 00000000000..6beb41738b8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 KubernetesClustersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesCluster +} + +// KubernetesClustersCreateOrUpdate ... +func (c NetworkcloudsClient) KubernetesClustersCreateOrUpdate(ctx context.Context, id KubernetesClusterId, input KubernetesCluster) (result KubernetesClustersCreateOrUpdateOperationResponse, 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 +} + +// KubernetesClustersCreateOrUpdateThenPoll performs KubernetesClustersCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) KubernetesClustersCreateOrUpdateThenPoll(ctx context.Context, id KubernetesClusterId, input KubernetesCluster) error { + result, err := c.KubernetesClustersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing KubernetesClustersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClustersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersdelete.go new file mode 100644 index 00000000000..7541fe1be57 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 KubernetesClustersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// KubernetesClustersDelete ... +func (c NetworkcloudsClient) KubernetesClustersDelete(ctx context.Context, id KubernetesClusterId) (result KubernetesClustersDeleteOperationResponse, 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 +} + +// KubernetesClustersDeleteThenPoll performs KubernetesClustersDelete then polls until it's completed +func (c NetworkcloudsClient) KubernetesClustersDeleteThenPoll(ctx context.Context, id KubernetesClusterId) error { + result, err := c.KubernetesClustersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing KubernetesClustersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClustersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersget.go new file mode 100644 index 00000000000..1fc37bf80b9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 KubernetesClustersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesCluster +} + +// KubernetesClustersGet ... +func (c NetworkcloudsClient) KubernetesClustersGet(ctx context.Context, id KubernetesClusterId) (result KubernetesClustersGetOperationResponse, 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 + } + + var model KubernetesCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbyresourcegroup.go new file mode 100644 index 00000000000..47f472d246c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 KubernetesClustersListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubernetesCluster +} + +type KubernetesClustersListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubernetesCluster +} + +type KubernetesClustersListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *KubernetesClustersListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// KubernetesClustersListByResourceGroup ... +func (c NetworkcloudsClient) KubernetesClustersListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result KubernetesClustersListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &KubernetesClustersListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/kubernetesClusters", 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 *[]KubernetesCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// KubernetesClustersListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) KubernetesClustersListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (KubernetesClustersListByResourceGroupCompleteResult, error) { + return c.KubernetesClustersListByResourceGroupCompleteMatchingPredicate(ctx, id, KubernetesClusterOperationPredicate{}) +} + +// KubernetesClustersListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) KubernetesClustersListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubernetesClusterOperationPredicate) (result KubernetesClustersListByResourceGroupCompleteResult, err error) { + items := make([]KubernetesCluster, 0) + + resp, err := c.KubernetesClustersListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = KubernetesClustersListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbysubscription.go new file mode 100644 index 00000000000..ea5495c4a61 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclusterslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 KubernetesClustersListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubernetesCluster +} + +type KubernetesClustersListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubernetesCluster +} + +type KubernetesClustersListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *KubernetesClustersListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// KubernetesClustersListBySubscription ... +func (c NetworkcloudsClient) KubernetesClustersListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result KubernetesClustersListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &KubernetesClustersListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/kubernetesClusters", 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 *[]KubernetesCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// KubernetesClustersListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) KubernetesClustersListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (KubernetesClustersListBySubscriptionCompleteResult, error) { + return c.KubernetesClustersListBySubscriptionCompleteMatchingPredicate(ctx, id, KubernetesClusterOperationPredicate{}) +} + +// KubernetesClustersListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) KubernetesClustersListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubernetesClusterOperationPredicate) (result KubernetesClustersListBySubscriptionCompleteResult, err error) { + items := make([]KubernetesCluster, 0) + + resp, err := c.KubernetesClustersListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = KubernetesClustersListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersrestartnode.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersrestartnode.go new file mode 100644 index 00000000000..b9f98978712 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersrestartnode.go @@ -0,0 +1,73 @@ +package networkclouds + +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 KubernetesClustersRestartNodeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// KubernetesClustersRestartNode ... +func (c NetworkcloudsClient) KubernetesClustersRestartNode(ctx context.Context, id KubernetesClusterId, input KubernetesClusterRestartNodeParameters) (result KubernetesClustersRestartNodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restartNode", 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 +} + +// KubernetesClustersRestartNodeThenPoll performs KubernetesClustersRestartNode then polls until it's completed +func (c NetworkcloudsClient) KubernetesClustersRestartNodeThenPoll(ctx context.Context, id KubernetesClusterId, input KubernetesClusterRestartNodeParameters) error { + result, err := c.KubernetesClustersRestartNode(ctx, id, input) + if err != nil { + return fmt.Errorf("performing KubernetesClustersRestartNode: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClustersRestartNode: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersupdate.go new file mode 100644 index 00000000000..2580835a03c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_kubernetesclustersupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 KubernetesClustersUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesCluster +} + +// KubernetesClustersUpdate ... +func (c NetworkcloudsClient) KubernetesClustersUpdate(ctx context.Context, id KubernetesClusterId, input KubernetesClusterPatchParameters) (result KubernetesClustersUpdateOperationResponse, 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 +} + +// KubernetesClustersUpdateThenPoll performs KubernetesClustersUpdate then polls until it's completed +func (c NetworkcloudsClient) KubernetesClustersUpdateThenPoll(ctx context.Context, id KubernetesClusterId, input KubernetesClusterPatchParameters) error { + result, err := c.KubernetesClustersUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing KubernetesClustersUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after KubernetesClustersUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkscreateorupdate.go new file mode 100644 index 00000000000..256bafba27a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 L2NetworksCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *L2Network +} + +// L2NetworksCreateOrUpdate ... +func (c NetworkcloudsClient) L2NetworksCreateOrUpdate(ctx context.Context, id L2NetworkId, input L2Network) (result L2NetworksCreateOrUpdateOperationResponse, 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 +} + +// L2NetworksCreateOrUpdateThenPoll performs L2NetworksCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) L2NetworksCreateOrUpdateThenPoll(ctx context.Context, id L2NetworkId, input L2Network) error { + result, err := c.L2NetworksCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing L2NetworksCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after L2NetworksCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksdelete.go new file mode 100644 index 00000000000..48ac06d4c68 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 L2NetworksDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// L2NetworksDelete ... +func (c NetworkcloudsClient) L2NetworksDelete(ctx context.Context, id L2NetworkId) (result L2NetworksDeleteOperationResponse, 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 +} + +// L2NetworksDeleteThenPoll performs L2NetworksDelete then polls until it's completed +func (c NetworkcloudsClient) L2NetworksDeleteThenPoll(ctx context.Context, id L2NetworkId) error { + result, err := c.L2NetworksDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing L2NetworksDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after L2NetworksDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksget.go new file mode 100644 index 00000000000..88f3467ff6f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 L2NetworksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *L2Network +} + +// L2NetworksGet ... +func (c NetworkcloudsClient) L2NetworksGet(ctx context.Context, id L2NetworkId) (result L2NetworksGetOperationResponse, 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 + } + + var model L2Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbyresourcegroup.go new file mode 100644 index 00000000000..61806a0343d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 L2NetworksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]L2Network +} + +type L2NetworksListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []L2Network +} + +type L2NetworksListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *L2NetworksListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// L2NetworksListByResourceGroup ... +func (c NetworkcloudsClient) L2NetworksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result L2NetworksListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &L2NetworksListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/l2Networks", 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 *[]L2Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// L2NetworksListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) L2NetworksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (L2NetworksListByResourceGroupCompleteResult, error) { + return c.L2NetworksListByResourceGroupCompleteMatchingPredicate(ctx, id, L2NetworkOperationPredicate{}) +} + +// L2NetworksListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) L2NetworksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate L2NetworkOperationPredicate) (result L2NetworksListByResourceGroupCompleteResult, err error) { + items := make([]L2Network, 0) + + resp, err := c.L2NetworksListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = L2NetworksListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbysubscription.go new file mode 100644 index 00000000000..311c580ee0f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networkslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 L2NetworksListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]L2Network +} + +type L2NetworksListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []L2Network +} + +type L2NetworksListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *L2NetworksListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// L2NetworksListBySubscription ... +func (c NetworkcloudsClient) L2NetworksListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result L2NetworksListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &L2NetworksListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/l2Networks", 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 *[]L2Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// L2NetworksListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) L2NetworksListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (L2NetworksListBySubscriptionCompleteResult, error) { + return c.L2NetworksListBySubscriptionCompleteMatchingPredicate(ctx, id, L2NetworkOperationPredicate{}) +} + +// L2NetworksListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) L2NetworksListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate L2NetworkOperationPredicate) (result L2NetworksListBySubscriptionCompleteResult, err error) { + items := make([]L2Network, 0) + + resp, err := c.L2NetworksListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = L2NetworksListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksupdate.go new file mode 100644 index 00000000000..ecc2e4ab707 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l2networksupdate.go @@ -0,0 +1,57 @@ +package networkclouds + +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 L2NetworksUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *L2Network +} + +// L2NetworksUpdate ... +func (c NetworkcloudsClient) L2NetworksUpdate(ctx context.Context, id L2NetworkId, input L2NetworkPatchParameters) (result L2NetworksUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model L2Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkscreateorupdate.go new file mode 100644 index 00000000000..afcd47c07a1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 L3NetworksCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *L3Network +} + +// L3NetworksCreateOrUpdate ... +func (c NetworkcloudsClient) L3NetworksCreateOrUpdate(ctx context.Context, id L3NetworkId, input L3Network) (result L3NetworksCreateOrUpdateOperationResponse, 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 +} + +// L3NetworksCreateOrUpdateThenPoll performs L3NetworksCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) L3NetworksCreateOrUpdateThenPoll(ctx context.Context, id L3NetworkId, input L3Network) error { + result, err := c.L3NetworksCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing L3NetworksCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after L3NetworksCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksdelete.go new file mode 100644 index 00000000000..9ad004ab2ba --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 L3NetworksDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// L3NetworksDelete ... +func (c NetworkcloudsClient) L3NetworksDelete(ctx context.Context, id L3NetworkId) (result L3NetworksDeleteOperationResponse, 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 +} + +// L3NetworksDeleteThenPoll performs L3NetworksDelete then polls until it's completed +func (c NetworkcloudsClient) L3NetworksDeleteThenPoll(ctx context.Context, id L3NetworkId) error { + result, err := c.L3NetworksDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing L3NetworksDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after L3NetworksDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksget.go new file mode 100644 index 00000000000..1b207f4a64a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 L3NetworksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *L3Network +} + +// L3NetworksGet ... +func (c NetworkcloudsClient) L3NetworksGet(ctx context.Context, id L3NetworkId) (result L3NetworksGetOperationResponse, 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 + } + + var model L3Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbyresourcegroup.go new file mode 100644 index 00000000000..4a069c03f3a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 L3NetworksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]L3Network +} + +type L3NetworksListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []L3Network +} + +type L3NetworksListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *L3NetworksListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// L3NetworksListByResourceGroup ... +func (c NetworkcloudsClient) L3NetworksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result L3NetworksListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &L3NetworksListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/l3Networks", 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 *[]L3Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// L3NetworksListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) L3NetworksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (L3NetworksListByResourceGroupCompleteResult, error) { + return c.L3NetworksListByResourceGroupCompleteMatchingPredicate(ctx, id, L3NetworkOperationPredicate{}) +} + +// L3NetworksListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) L3NetworksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate L3NetworkOperationPredicate) (result L3NetworksListByResourceGroupCompleteResult, err error) { + items := make([]L3Network, 0) + + resp, err := c.L3NetworksListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = L3NetworksListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbysubscription.go new file mode 100644 index 00000000000..16acde9c89f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networkslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 L3NetworksListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]L3Network +} + +type L3NetworksListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []L3Network +} + +type L3NetworksListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *L3NetworksListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// L3NetworksListBySubscription ... +func (c NetworkcloudsClient) L3NetworksListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result L3NetworksListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &L3NetworksListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/l3Networks", 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 *[]L3Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// L3NetworksListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) L3NetworksListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (L3NetworksListBySubscriptionCompleteResult, error) { + return c.L3NetworksListBySubscriptionCompleteMatchingPredicate(ctx, id, L3NetworkOperationPredicate{}) +} + +// L3NetworksListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) L3NetworksListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate L3NetworkOperationPredicate) (result L3NetworksListBySubscriptionCompleteResult, err error) { + items := make([]L3Network, 0) + + resp, err := c.L3NetworksListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = L3NetworksListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksupdate.go new file mode 100644 index 00000000000..8d4c945367a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_l3networksupdate.go @@ -0,0 +1,57 @@ +package networkclouds + +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 L3NetworksUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *L3Network +} + +// L3NetworksUpdate ... +func (c NetworkcloudsClient) L3NetworksUpdate(ctx context.Context, id L3NetworkId, input L3NetworkPatchParameters) (result L3NetworksUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model L3Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationscreateorupdate.go new file mode 100644 index 00000000000..25364d02e92 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 MetricsConfigurationsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterMetricsConfiguration +} + +// MetricsConfigurationsCreateOrUpdate ... +func (c NetworkcloudsClient) MetricsConfigurationsCreateOrUpdate(ctx context.Context, id MetricsConfigurationId, input ClusterMetricsConfiguration) (result MetricsConfigurationsCreateOrUpdateOperationResponse, 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 +} + +// MetricsConfigurationsCreateOrUpdateThenPoll performs MetricsConfigurationsCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) MetricsConfigurationsCreateOrUpdateThenPoll(ctx context.Context, id MetricsConfigurationId, input ClusterMetricsConfiguration) error { + result, err := c.MetricsConfigurationsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MetricsConfigurationsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MetricsConfigurationsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsdelete.go new file mode 100644 index 00000000000..824d8d2c76c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 MetricsConfigurationsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MetricsConfigurationsDelete ... +func (c NetworkcloudsClient) MetricsConfigurationsDelete(ctx context.Context, id MetricsConfigurationId) (result MetricsConfigurationsDeleteOperationResponse, 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 +} + +// MetricsConfigurationsDeleteThenPoll performs MetricsConfigurationsDelete then polls until it's completed +func (c NetworkcloudsClient) MetricsConfigurationsDeleteThenPoll(ctx context.Context, id MetricsConfigurationId) error { + result, err := c.MetricsConfigurationsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing MetricsConfigurationsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MetricsConfigurationsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsget.go new file mode 100644 index 00000000000..74f3b8acf91 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 MetricsConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterMetricsConfiguration +} + +// MetricsConfigurationsGet ... +func (c NetworkcloudsClient) MetricsConfigurationsGet(ctx context.Context, id MetricsConfigurationId) (result MetricsConfigurationsGetOperationResponse, 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 + } + + var model ClusterMetricsConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationslistbycluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationslistbycluster.go new file mode 100644 index 00000000000..b88f8385b61 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationslistbycluster.go @@ -0,0 +1,105 @@ +package networkclouds + +import ( + "context" + "fmt" + "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 MetricsConfigurationsListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ClusterMetricsConfiguration +} + +type MetricsConfigurationsListByClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []ClusterMetricsConfiguration +} + +type MetricsConfigurationsListByClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *MetricsConfigurationsListByClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// MetricsConfigurationsListByCluster ... +func (c NetworkcloudsClient) MetricsConfigurationsListByCluster(ctx context.Context, id ClusterId) (result MetricsConfigurationsListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &MetricsConfigurationsListByClusterCustomPager{}, + Path: fmt.Sprintf("%s/metricsConfigurations", 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 *[]ClusterMetricsConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// MetricsConfigurationsListByClusterComplete retrieves all the results into a single object +func (c NetworkcloudsClient) MetricsConfigurationsListByClusterComplete(ctx context.Context, id ClusterId) (MetricsConfigurationsListByClusterCompleteResult, error) { + return c.MetricsConfigurationsListByClusterCompleteMatchingPredicate(ctx, id, ClusterMetricsConfigurationOperationPredicate{}) +} + +// MetricsConfigurationsListByClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) MetricsConfigurationsListByClusterCompleteMatchingPredicate(ctx context.Context, id ClusterId, predicate ClusterMetricsConfigurationOperationPredicate) (result MetricsConfigurationsListByClusterCompleteResult, err error) { + items := make([]ClusterMetricsConfiguration, 0) + + resp, err := c.MetricsConfigurationsListByCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = MetricsConfigurationsListByClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsupdate.go new file mode 100644 index 00000000000..41d5e31eeb8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_metricsconfigurationsupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 MetricsConfigurationsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterMetricsConfiguration +} + +// MetricsConfigurationsUpdate ... +func (c NetworkcloudsClient) MetricsConfigurationsUpdate(ctx context.Context, id MetricsConfigurationId, input ClusterMetricsConfigurationPatchParameters) (result MetricsConfigurationsUpdateOperationResponse, 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 +} + +// MetricsConfigurationsUpdateThenPoll performs MetricsConfigurationsUpdate then polls until it's completed +func (c NetworkcloudsClient) MetricsConfigurationsUpdateThenPoll(ctx context.Context, id MetricsConfigurationId, input ClusterMetricsConfigurationPatchParameters) error { + result, err := c.MetricsConfigurationsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MetricsConfigurationsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MetricsConfigurationsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackscreateorupdate.go new file mode 100644 index 00000000000..8050e2d8e4e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 RacksCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Rack +} + +// RacksCreateOrUpdate ... +func (c NetworkcloudsClient) RacksCreateOrUpdate(ctx context.Context, id RackId, input Rack) (result RacksCreateOrUpdateOperationResponse, 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 +} + +// RacksCreateOrUpdateThenPoll performs RacksCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) RacksCreateOrUpdateThenPoll(ctx context.Context, id RackId, input Rack) error { + result, err := c.RacksCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RacksCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RacksCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksdelete.go new file mode 100644 index 00000000000..8799983ea73 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 RacksDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RacksDelete ... +func (c NetworkcloudsClient) RacksDelete(ctx context.Context, id RackId) (result RacksDeleteOperationResponse, 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 +} + +// RacksDeleteThenPoll performs RacksDelete then polls until it's completed +func (c NetworkcloudsClient) RacksDeleteThenPoll(ctx context.Context, id RackId) error { + result, err := c.RacksDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RacksDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RacksDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksget.go new file mode 100644 index 00000000000..2155b30595d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 RacksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Rack +} + +// RacksGet ... +func (c NetworkcloudsClient) RacksGet(ctx context.Context, id RackId) (result RacksGetOperationResponse, 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 + } + + var model Rack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskusget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskusget.go new file mode 100644 index 00000000000..be0bc342665 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskusget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 RackSkusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RackSku +} + +// RackSkusGet ... +func (c NetworkcloudsClient) RackSkusGet(ctx context.Context, id RackSkuId) (result RackSkusGetOperationResponse, 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 + } + + var model RackSku + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskuslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskuslistbysubscription.go new file mode 100644 index 00000000000..7f8c250adc6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackskuslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 RackSkusListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RackSku +} + +type RackSkusListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []RackSku +} + +type RackSkusListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RackSkusListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RackSkusListBySubscription ... +func (c NetworkcloudsClient) RackSkusListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result RackSkusListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RackSkusListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/rackSkus", 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 *[]RackSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RackSkusListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) RackSkusListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (RackSkusListBySubscriptionCompleteResult, error) { + return c.RackSkusListBySubscriptionCompleteMatchingPredicate(ctx, id, RackSkuOperationPredicate{}) +} + +// RackSkusListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) RackSkusListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RackSkuOperationPredicate) (result RackSkusListBySubscriptionCompleteResult, err error) { + items := make([]RackSku, 0) + + resp, err := c.RackSkusListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RackSkusListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbyresourcegroup.go new file mode 100644 index 00000000000..ac827b79e55 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 RacksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Rack +} + +type RacksListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Rack +} + +type RacksListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RacksListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RacksListByResourceGroup ... +func (c NetworkcloudsClient) RacksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result RacksListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RacksListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/racks", 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 *[]Rack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RacksListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) RacksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (RacksListByResourceGroupCompleteResult, error) { + return c.RacksListByResourceGroupCompleteMatchingPredicate(ctx, id, RackOperationPredicate{}) +} + +// RacksListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) RacksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RackOperationPredicate) (result RacksListByResourceGroupCompleteResult, err error) { + items := make([]Rack, 0) + + resp, err := c.RacksListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RacksListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbysubscription.go new file mode 100644 index 00000000000..937e6edd4de --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_rackslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 RacksListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Rack +} + +type RacksListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Rack +} + +type RacksListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RacksListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RacksListBySubscription ... +func (c NetworkcloudsClient) RacksListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result RacksListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RacksListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/racks", 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 *[]Rack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RacksListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) RacksListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (RacksListBySubscriptionCompleteResult, error) { + return c.RacksListBySubscriptionCompleteMatchingPredicate(ctx, id, RackOperationPredicate{}) +} + +// RacksListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) RacksListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RackOperationPredicate) (result RacksListBySubscriptionCompleteResult, err error) { + items := make([]Rack, 0) + + resp, err := c.RacksListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RacksListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksupdate.go new file mode 100644 index 00000000000..3e865b2612e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_racksupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 RacksUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Rack +} + +// RacksUpdate ... +func (c NetworkcloudsClient) RacksUpdate(ctx context.Context, id RackId, input RackPatchParameters) (result RacksUpdateOperationResponse, 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 +} + +// RacksUpdateThenPoll performs RacksUpdate then polls until it's completed +func (c NetworkcloudsClient) RacksUpdateThenPoll(ctx context.Context, id RackId, input RackPatchParameters) error { + result, err := c.RacksUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RacksUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RacksUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancescreateorupdate.go new file mode 100644 index 00000000000..2287645adf7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 StorageAppliancesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageAppliance +} + +// StorageAppliancesCreateOrUpdate ... +func (c NetworkcloudsClient) StorageAppliancesCreateOrUpdate(ctx context.Context, id StorageApplianceId, input StorageAppliance) (result StorageAppliancesCreateOrUpdateOperationResponse, 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 +} + +// StorageAppliancesCreateOrUpdateThenPoll performs StorageAppliancesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) StorageAppliancesCreateOrUpdateThenPoll(ctx context.Context, id StorageApplianceId, input StorageAppliance) error { + result, err := c.StorageAppliancesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StorageAppliancesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageAppliancesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdelete.go new file mode 100644 index 00000000000..d12012b29fb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 StorageAppliancesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageAppliancesDelete ... +func (c NetworkcloudsClient) StorageAppliancesDelete(ctx context.Context, id StorageApplianceId) (result StorageAppliancesDeleteOperationResponse, 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 +} + +// StorageAppliancesDeleteThenPoll performs StorageAppliancesDelete then polls until it's completed +func (c NetworkcloudsClient) StorageAppliancesDeleteThenPoll(ctx context.Context, id StorageApplianceId) error { + result, err := c.StorageAppliancesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageAppliancesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageAppliancesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdisableremotevendormanagement.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdisableremotevendormanagement.go new file mode 100644 index 00000000000..0bb78e0121e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesdisableremotevendormanagement.go @@ -0,0 +1,69 @@ +package networkclouds + +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 StorageAppliancesDisableRemoteVendorManagementOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageAppliancesDisableRemoteVendorManagement ... +func (c NetworkcloudsClient) StorageAppliancesDisableRemoteVendorManagement(ctx context.Context, id StorageApplianceId) (result StorageAppliancesDisableRemoteVendorManagementOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disableRemoteVendorManagement", 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 +} + +// StorageAppliancesDisableRemoteVendorManagementThenPoll performs StorageAppliancesDisableRemoteVendorManagement then polls until it's completed +func (c NetworkcloudsClient) StorageAppliancesDisableRemoteVendorManagementThenPoll(ctx context.Context, id StorageApplianceId) error { + result, err := c.StorageAppliancesDisableRemoteVendorManagement(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageAppliancesDisableRemoteVendorManagement: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageAppliancesDisableRemoteVendorManagement: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesenableremotevendormanagement.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesenableremotevendormanagement.go new file mode 100644 index 00000000000..8b5bba8eddb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesenableremotevendormanagement.go @@ -0,0 +1,73 @@ +package networkclouds + +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 StorageAppliancesEnableRemoteVendorManagementOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageAppliancesEnableRemoteVendorManagement ... +func (c NetworkcloudsClient) StorageAppliancesEnableRemoteVendorManagement(ctx context.Context, id StorageApplianceId, input StorageApplianceEnableRemoteVendorManagementParameters) (result StorageAppliancesEnableRemoteVendorManagementOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enableRemoteVendorManagement", 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 +} + +// StorageAppliancesEnableRemoteVendorManagementThenPoll performs StorageAppliancesEnableRemoteVendorManagement then polls until it's completed +func (c NetworkcloudsClient) StorageAppliancesEnableRemoteVendorManagementThenPoll(ctx context.Context, id StorageApplianceId, input StorageApplianceEnableRemoteVendorManagementParameters) error { + result, err := c.StorageAppliancesEnableRemoteVendorManagement(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StorageAppliancesEnableRemoteVendorManagement: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageAppliancesEnableRemoteVendorManagement: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesget.go new file mode 100644 index 00000000000..6ba58bf27ec --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 StorageAppliancesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageAppliance +} + +// StorageAppliancesGet ... +func (c NetworkcloudsClient) StorageAppliancesGet(ctx context.Context, id StorageApplianceId) (result StorageAppliancesGetOperationResponse, 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 + } + + var model StorageAppliance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbyresourcegroup.go new file mode 100644 index 00000000000..787864ebabe --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 StorageAppliancesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageAppliance +} + +type StorageAppliancesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageAppliance +} + +type StorageAppliancesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *StorageAppliancesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// StorageAppliancesListByResourceGroup ... +func (c NetworkcloudsClient) StorageAppliancesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result StorageAppliancesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &StorageAppliancesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/storageAppliances", 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 *[]StorageAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// StorageAppliancesListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) StorageAppliancesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (StorageAppliancesListByResourceGroupCompleteResult, error) { + return c.StorageAppliancesListByResourceGroupCompleteMatchingPredicate(ctx, id, StorageApplianceOperationPredicate{}) +} + +// StorageAppliancesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) StorageAppliancesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StorageApplianceOperationPredicate) (result StorageAppliancesListByResourceGroupCompleteResult, err error) { + items := make([]StorageAppliance, 0) + + resp, err := c.StorageAppliancesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = StorageAppliancesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbysubscription.go new file mode 100644 index 00000000000..b1195f23421 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageapplianceslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 StorageAppliancesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageAppliance +} + +type StorageAppliancesListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageAppliance +} + +type StorageAppliancesListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *StorageAppliancesListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// StorageAppliancesListBySubscription ... +func (c NetworkcloudsClient) StorageAppliancesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result StorageAppliancesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &StorageAppliancesListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/storageAppliances", 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 *[]StorageAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// StorageAppliancesListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) StorageAppliancesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (StorageAppliancesListBySubscriptionCompleteResult, error) { + return c.StorageAppliancesListBySubscriptionCompleteMatchingPredicate(ctx, id, StorageApplianceOperationPredicate{}) +} + +// StorageAppliancesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) StorageAppliancesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StorageApplianceOperationPredicate) (result StorageAppliancesListBySubscriptionCompleteResult, err error) { + items := make([]StorageAppliance, 0) + + resp, err := c.StorageAppliancesListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = StorageAppliancesListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesupdate.go new file mode 100644 index 00000000000..e3c14626d52 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_storageappliancesupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 StorageAppliancesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageAppliance +} + +// StorageAppliancesUpdate ... +func (c NetworkcloudsClient) StorageAppliancesUpdate(ctx context.Context, id StorageApplianceId, input StorageAppliancePatchParameters) (result StorageAppliancesUpdateOperationResponse, 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 +} + +// StorageAppliancesUpdateThenPoll performs StorageAppliancesUpdate then polls until it's completed +func (c NetworkcloudsClient) StorageAppliancesUpdateThenPoll(ctx context.Context, id StorageApplianceId, input StorageAppliancePatchParameters) error { + result, err := c.StorageAppliancesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StorageAppliancesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageAppliancesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkscreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkscreateorupdate.go new file mode 100644 index 00000000000..20fbdeaa782 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkscreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 TrunkedNetworksCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TrunkedNetwork +} + +// TrunkedNetworksCreateOrUpdate ... +func (c NetworkcloudsClient) TrunkedNetworksCreateOrUpdate(ctx context.Context, id TrunkedNetworkId, input TrunkedNetwork) (result TrunkedNetworksCreateOrUpdateOperationResponse, 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 +} + +// TrunkedNetworksCreateOrUpdateThenPoll performs TrunkedNetworksCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) TrunkedNetworksCreateOrUpdateThenPoll(ctx context.Context, id TrunkedNetworkId, input TrunkedNetwork) error { + result, err := c.TrunkedNetworksCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TrunkedNetworksCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TrunkedNetworksCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksdelete.go new file mode 100644 index 00000000000..e20df992eeb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 TrunkedNetworksDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// TrunkedNetworksDelete ... +func (c NetworkcloudsClient) TrunkedNetworksDelete(ctx context.Context, id TrunkedNetworkId) (result TrunkedNetworksDeleteOperationResponse, 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 +} + +// TrunkedNetworksDeleteThenPoll performs TrunkedNetworksDelete then polls until it's completed +func (c NetworkcloudsClient) TrunkedNetworksDeleteThenPoll(ctx context.Context, id TrunkedNetworkId) error { + result, err := c.TrunkedNetworksDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing TrunkedNetworksDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TrunkedNetworksDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksget.go new file mode 100644 index 00000000000..3f6d1fcf63c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 TrunkedNetworksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TrunkedNetwork +} + +// TrunkedNetworksGet ... +func (c NetworkcloudsClient) TrunkedNetworksGet(ctx context.Context, id TrunkedNetworkId) (result TrunkedNetworksGetOperationResponse, 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 + } + + var model TrunkedNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbyresourcegroup.go new file mode 100644 index 00000000000..36db263e346 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 TrunkedNetworksListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrunkedNetwork +} + +type TrunkedNetworksListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrunkedNetwork +} + +type TrunkedNetworksListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *TrunkedNetworksListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// TrunkedNetworksListByResourceGroup ... +func (c NetworkcloudsClient) TrunkedNetworksListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result TrunkedNetworksListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &TrunkedNetworksListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/trunkedNetworks", 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 *[]TrunkedNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TrunkedNetworksListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) TrunkedNetworksListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (TrunkedNetworksListByResourceGroupCompleteResult, error) { + return c.TrunkedNetworksListByResourceGroupCompleteMatchingPredicate(ctx, id, TrunkedNetworkOperationPredicate{}) +} + +// TrunkedNetworksListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) TrunkedNetworksListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate TrunkedNetworkOperationPredicate) (result TrunkedNetworksListByResourceGroupCompleteResult, err error) { + items := make([]TrunkedNetwork, 0) + + resp, err := c.TrunkedNetworksListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = TrunkedNetworksListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbysubscription.go new file mode 100644 index 00000000000..4e99bafe3c2 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworkslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 TrunkedNetworksListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrunkedNetwork +} + +type TrunkedNetworksListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrunkedNetwork +} + +type TrunkedNetworksListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *TrunkedNetworksListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// TrunkedNetworksListBySubscription ... +func (c NetworkcloudsClient) TrunkedNetworksListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result TrunkedNetworksListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &TrunkedNetworksListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/trunkedNetworks", 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 *[]TrunkedNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TrunkedNetworksListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) TrunkedNetworksListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (TrunkedNetworksListBySubscriptionCompleteResult, error) { + return c.TrunkedNetworksListBySubscriptionCompleteMatchingPredicate(ctx, id, TrunkedNetworkOperationPredicate{}) +} + +// TrunkedNetworksListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) TrunkedNetworksListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TrunkedNetworkOperationPredicate) (result TrunkedNetworksListBySubscriptionCompleteResult, err error) { + items := make([]TrunkedNetwork, 0) + + resp, err := c.TrunkedNetworksListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = TrunkedNetworksListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksupdate.go new file mode 100644 index 00000000000..d29a1ac9138 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_trunkednetworksupdate.go @@ -0,0 +1,57 @@ +package networkclouds + +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 TrunkedNetworksUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TrunkedNetwork +} + +// TrunkedNetworksUpdate ... +func (c NetworkcloudsClient) TrunkedNetworksUpdate(ctx context.Context, id TrunkedNetworkId, input TrunkedNetworkPatchParameters) (result TrunkedNetworksUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model TrunkedNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinescreateorupdate.go new file mode 100644 index 00000000000..fbcff3f5dba --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 VirtualMachinesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualMachine +} + +// VirtualMachinesCreateOrUpdate ... +func (c NetworkcloudsClient) VirtualMachinesCreateOrUpdate(ctx context.Context, id VirtualMachineId, input VirtualMachine) (result VirtualMachinesCreateOrUpdateOperationResponse, 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 +} + +// VirtualMachinesCreateOrUpdateThenPoll performs VirtualMachinesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesCreateOrUpdateThenPoll(ctx context.Context, id VirtualMachineId, input VirtualMachine) error { + result, err := c.VirtualMachinesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualMachinesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesdelete.go new file mode 100644 index 00000000000..4c9ecaa819f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 VirtualMachinesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualMachinesDelete ... +func (c NetworkcloudsClient) VirtualMachinesDelete(ctx context.Context, id VirtualMachineId) (result VirtualMachinesDeleteOperationResponse, 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 +} + +// VirtualMachinesDeleteThenPoll performs VirtualMachinesDelete then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesDeleteThenPoll(ctx context.Context, id VirtualMachineId) error { + result, err := c.VirtualMachinesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualMachinesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesget.go new file mode 100644 index 00000000000..7e735c93520 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 VirtualMachinesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualMachine +} + +// VirtualMachinesGet ... +func (c NetworkcloudsClient) VirtualMachinesGet(ctx context.Context, id VirtualMachineId) (result VirtualMachinesGetOperationResponse, 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 + } + + var model VirtualMachine + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbyresourcegroup.go new file mode 100644 index 00000000000..6e9ffd78a99 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 VirtualMachinesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualMachine +} + +type VirtualMachinesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualMachine +} + +type VirtualMachinesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualMachinesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualMachinesListByResourceGroup ... +func (c NetworkcloudsClient) VirtualMachinesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VirtualMachinesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualMachinesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/virtualMachines", 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 *[]VirtualMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualMachinesListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) VirtualMachinesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VirtualMachinesListByResourceGroupCompleteResult, error) { + return c.VirtualMachinesListByResourceGroupCompleteMatchingPredicate(ctx, id, VirtualMachineOperationPredicate{}) +} + +// VirtualMachinesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) VirtualMachinesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualMachineOperationPredicate) (result VirtualMachinesListByResourceGroupCompleteResult, err error) { + items := make([]VirtualMachine, 0) + + resp, err := c.VirtualMachinesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = VirtualMachinesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbysubscription.go new file mode 100644 index 00000000000..06b592377a7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachineslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 VirtualMachinesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualMachine +} + +type VirtualMachinesListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualMachine +} + +type VirtualMachinesListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualMachinesListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualMachinesListBySubscription ... +func (c NetworkcloudsClient) VirtualMachinesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result VirtualMachinesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualMachinesListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/virtualMachines", 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 *[]VirtualMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualMachinesListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) VirtualMachinesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (VirtualMachinesListBySubscriptionCompleteResult, error) { + return c.VirtualMachinesListBySubscriptionCompleteMatchingPredicate(ctx, id, VirtualMachineOperationPredicate{}) +} + +// VirtualMachinesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) VirtualMachinesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualMachineOperationPredicate) (result VirtualMachinesListBySubscriptionCompleteResult, err error) { + items := make([]VirtualMachine, 0) + + resp, err := c.VirtualMachinesListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = VirtualMachinesListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinespoweroff.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinespoweroff.go new file mode 100644 index 00000000000..f7e7ce72cf7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinespoweroff.go @@ -0,0 +1,73 @@ +package networkclouds + +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 VirtualMachinesPowerOffOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualMachinesPowerOff ... +func (c NetworkcloudsClient) VirtualMachinesPowerOff(ctx context.Context, id VirtualMachineId, input VirtualMachinePowerOffParameters) (result VirtualMachinesPowerOffOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/powerOff", 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 +} + +// VirtualMachinesPowerOffThenPoll performs VirtualMachinesPowerOff then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesPowerOffThenPoll(ctx context.Context, id VirtualMachineId, input VirtualMachinePowerOffParameters) error { + result, err := c.VirtualMachinesPowerOff(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualMachinesPowerOff: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesPowerOff: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesreimage.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesreimage.go new file mode 100644 index 00000000000..a52ac85ed07 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesreimage.go @@ -0,0 +1,69 @@ +package networkclouds + +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 VirtualMachinesReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualMachinesReimage ... +func (c NetworkcloudsClient) VirtualMachinesReimage(ctx context.Context, id VirtualMachineId) (result VirtualMachinesReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", 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 +} + +// VirtualMachinesReimageThenPoll performs VirtualMachinesReimage then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesReimageThenPoll(ctx context.Context, id VirtualMachineId) error { + result, err := c.VirtualMachinesReimage(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualMachinesReimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesReimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesrestart.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesrestart.go new file mode 100644 index 00000000000..8b7b450a6e3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesrestart.go @@ -0,0 +1,69 @@ +package networkclouds + +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 VirtualMachinesRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualMachinesRestart ... +func (c NetworkcloudsClient) VirtualMachinesRestart(ctx context.Context, id VirtualMachineId) (result VirtualMachinesRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// VirtualMachinesRestartThenPoll performs VirtualMachinesRestart then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesRestartThenPoll(ctx context.Context, id VirtualMachineId) error { + result, err := c.VirtualMachinesRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualMachinesRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesstart.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesstart.go new file mode 100644 index 00000000000..0405c769c23 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesstart.go @@ -0,0 +1,69 @@ +package networkclouds + +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 VirtualMachinesStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualMachinesStart ... +func (c NetworkcloudsClient) VirtualMachinesStart(ctx context.Context, id VirtualMachineId) (result VirtualMachinesStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// VirtualMachinesStartThenPoll performs VirtualMachinesStart then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesStartThenPoll(ctx context.Context, id VirtualMachineId) error { + result, err := c.VirtualMachinesStart(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualMachinesStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesupdate.go new file mode 100644 index 00000000000..bcd15b7ddae --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_virtualmachinesupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 VirtualMachinesUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualMachine +} + +// VirtualMachinesUpdate ... +func (c NetworkcloudsClient) VirtualMachinesUpdate(ctx context.Context, id VirtualMachineId, input VirtualMachinePatchParameters) (result VirtualMachinesUpdateOperationResponse, 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 +} + +// VirtualMachinesUpdateThenPoll performs VirtualMachinesUpdate then polls until it's completed +func (c NetworkcloudsClient) VirtualMachinesUpdateThenPoll(ctx context.Context, id VirtualMachineId, input VirtualMachinePatchParameters) error { + result, err := c.VirtualMachinesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualMachinesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualMachinesUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumescreateorupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumescreateorupdate.go new file mode 100644 index 00000000000..eeceb264c4a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumescreateorupdate.go @@ -0,0 +1,75 @@ +package networkclouds + +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 VolumesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Volume +} + +// VolumesCreateOrUpdate ... +func (c NetworkcloudsClient) VolumesCreateOrUpdate(ctx context.Context, id VolumeId, input Volume) (result VolumesCreateOrUpdateOperationResponse, 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 +} + +// VolumesCreateOrUpdateThenPoll performs VolumesCreateOrUpdate then polls until it's completed +func (c NetworkcloudsClient) VolumesCreateOrUpdateThenPoll(ctx context.Context, id VolumeId, input Volume) error { + result, err := c.VolumesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VolumesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesdelete.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesdelete.go new file mode 100644 index 00000000000..9e3f56281e6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesdelete.go @@ -0,0 +1,70 @@ +package networkclouds + +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 VolumesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VolumesDelete ... +func (c NetworkcloudsClient) VolumesDelete(ctx context.Context, id VolumeId) (result VolumesDeleteOperationResponse, 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 +} + +// VolumesDeleteThenPoll performs VolumesDelete then polls until it's completed +func (c NetworkcloudsClient) VolumesDeleteThenPoll(ctx context.Context, id VolumeId) error { + result, err := c.VolumesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VolumesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VolumesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesget.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesget.go new file mode 100644 index 00000000000..61d90d38ff1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesget.go @@ -0,0 +1,53 @@ +package networkclouds + +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 VolumesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Volume +} + +// VolumesGet ... +func (c NetworkcloudsClient) VolumesGet(ctx context.Context, id VolumeId) (result VolumesGetOperationResponse, 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 + } + + var model Volume + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbyresourcegroup.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbyresourcegroup.go new file mode 100644 index 00000000000..81af7b60699 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkclouds + +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 VolumesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Volume +} + +type VolumesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Volume +} + +type VolumesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VolumesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VolumesListByResourceGroup ... +func (c NetworkcloudsClient) VolumesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VolumesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VolumesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/volumes", 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 *[]Volume `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VolumesListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkcloudsClient) VolumesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VolumesListByResourceGroupCompleteResult, error) { + return c.VolumesListByResourceGroupCompleteMatchingPredicate(ctx, id, VolumeOperationPredicate{}) +} + +// VolumesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) VolumesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VolumeOperationPredicate) (result VolumesListByResourceGroupCompleteResult, err error) { + items := make([]Volume, 0) + + resp, err := c.VolumesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = VolumesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbysubscription.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbysubscription.go new file mode 100644 index 00000000000..14f0be4d5b2 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumeslistbysubscription.go @@ -0,0 +1,106 @@ +package networkclouds + +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 VolumesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Volume +} + +type VolumesListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Volume +} + +type VolumesListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VolumesListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VolumesListBySubscription ... +func (c NetworkcloudsClient) VolumesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result VolumesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VolumesListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkCloud/volumes", 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 *[]Volume `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VolumesListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkcloudsClient) VolumesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (VolumesListBySubscriptionCompleteResult, error) { + return c.VolumesListBySubscriptionCompleteMatchingPredicate(ctx, id, VolumeOperationPredicate{}) +} + +// VolumesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkcloudsClient) VolumesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VolumeOperationPredicate) (result VolumesListBySubscriptionCompleteResult, err error) { + items := make([]Volume, 0) + + resp, err := c.VolumesListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = VolumesListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesupdate.go b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesupdate.go new file mode 100644 index 00000000000..980fe295971 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/method_volumesupdate.go @@ -0,0 +1,57 @@ +package networkclouds + +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 VolumesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Volume +} + +// VolumesUpdate ... +func (c NetworkcloudsClient) VolumesUpdate(ctx context.Context, id VolumeId, input VolumePatchParameters) (result VolumesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Volume + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_aadconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_aadconfiguration.go new file mode 100644 index 00000000000..25dd094aa72 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_aadconfiguration.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AadConfiguration struct { + AdminGroupObjectIds []string `json:"adminGroupObjectIds"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_administrativecredentials.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administrativecredentials.go new file mode 100644 index 00000000000..f5f1f1c99bb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administrativecredentials.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministrativeCredentials struct { + Password string `json:"password"` + Username string `json:"username"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfiguration.go new file mode 100644 index 00000000000..08a5812c548 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfiguration.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministratorConfiguration struct { + AdminUsername *string `json:"adminUsername,omitempty"` + SshPublicKeys *[]SshPublicKey `json:"sshPublicKeys,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfigurationpatch.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfigurationpatch.go new file mode 100644 index 00000000000..12a6ece0c5e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_administratorconfigurationpatch.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministratorConfigurationPatch struct { + SshPublicKeys *[]SshPublicKey `json:"sshPublicKeys,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentoptions.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentoptions.go new file mode 100644 index 00000000000..d59368acc38 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentoptions.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentOptions struct { + HugepagesCount int64 `json:"hugepagesCount"` + HugepagesSize *HugepagesSize `json:"hugepagesSize,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpool.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpool.go new file mode 100644 index 00000000000..4b6a920cfce --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpool.go @@ -0,0 +1,19 @@ +package networkclouds + +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 AgentPool struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AgentPoolProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchparameters.go new file mode 100644 index 00000000000..466d55f56d5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolPatchParameters struct { + Properties *AgentPoolPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchproperties.go new file mode 100644 index 00000000000..07a310eb95a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolpatchproperties.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolPatchProperties struct { + AdministratorConfiguration *NodePoolAdministratorConfigurationPatch `json:"administratorConfiguration,omitempty"` + Count *int64 `json:"count,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolproperties.go new file mode 100644 index 00000000000..978fce40799 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolproperties.go @@ -0,0 +1,25 @@ +package networkclouds + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolProperties struct { + AdministratorConfiguration *AdministratorConfiguration `json:"administratorConfiguration,omitempty"` + AgentOptions *AgentOptions `json:"agentOptions,omitempty"` + AttachedNetworkConfiguration *AttachedNetworkConfiguration `json:"attachedNetworkConfiguration,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + Count int64 `json:"count"` + DetailedStatus *AgentPoolDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + Labels *[]KubernetesLabel `json:"labels,omitempty"` + Mode AgentPoolMode `json:"mode"` + ProvisioningState *AgentPoolProvisioningState `json:"provisioningState,omitempty"` + Taints *[]KubernetesLabel `json:"taints,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSkuName string `json:"vmSkuName"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolupgradesettings.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolupgradesettings.go new file mode 100644 index 00000000000..303f468ca2e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_agentpoolupgradesettings.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeSettings struct { + DrainTimeout *int64 `json:"drainTimeout,omitempty"` + MaxSurge *string `json:"maxSurge,omitempty"` + MaxUnavailable *string `json:"maxUnavailable,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_attachednetworkconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_attachednetworkconfiguration.go new file mode 100644 index 00000000000..1e9ede750db --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_attachednetworkconfiguration.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedNetworkConfiguration struct { + L2Networks *[]L2NetworkAttachmentConfiguration `json:"l2Networks,omitempty"` + L3Networks *[]L3NetworkAttachmentConfiguration `json:"l3Networks,omitempty"` + TrunkedNetworks *[]TrunkedNetworkAttachmentConfiguration `json:"trunkedNetworks,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_availableupgrade.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_availableupgrade.go new file mode 100644 index 00000000000..894d9227604 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_availableupgrade.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableUpgrade struct { + AvailabilityLifecycle *AvailabilityLifecycle `json:"availabilityLifecycle,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachine.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachine.go new file mode 100644 index 00000000000..9c3a28f9c63 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachine.go @@ -0,0 +1,19 @@ +package networkclouds + +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 BareMetalMachine struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BareMetalMachineProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecommandspecification.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecommandspecification.go new file mode 100644 index 00000000000..f3b1e49c1df --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecommandspecification.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineCommandSpecification struct { + Arguments *[]string `json:"arguments,omitempty"` + Command string `json:"command"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineconfigurationdata.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineconfigurationdata.go new file mode 100644 index 00000000000..b7bedd10cef --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineconfigurationdata.go @@ -0,0 +1,15 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineConfigurationData struct { + BmcConnectionString *string `json:"bmcConnectionString,omitempty"` + BmcCredentials AdministrativeCredentials `json:"bmcCredentials"` + BmcMacAddress string `json:"bmcMacAddress"` + BootMacAddress string `json:"bootMacAddress"` + MachineDetails *string `json:"machineDetails,omitempty"` + MachineName *string `json:"machineName,omitempty"` + RackSlot int64 `json:"rackSlot"` + SerialNumber string `json:"serialNumber"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecordonparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecordonparameters.go new file mode 100644 index 00000000000..2eb6e3189e7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinecordonparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineCordonParameters struct { + Evacuate *BareMetalMachineEvacuate `json:"evacuate,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeyset.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeyset.go new file mode 100644 index 00000000000..996ff095b90 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeyset.go @@ -0,0 +1,19 @@ +package networkclouds + +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 BareMetalMachineKeySet struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BareMetalMachineKeySetProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchparameters.go new file mode 100644 index 00000000000..f71a365bb67 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineKeySetPatchParameters struct { + Properties *BareMetalMachineKeySetPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchproperties.go new file mode 100644 index 00000000000..b54047089f5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetpatchproperties.go @@ -0,0 +1,28 @@ +package networkclouds + +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 BareMetalMachineKeySetPatchProperties struct { + Expiration *string `json:"expiration,omitempty"` + JumpHostsAllowed *[]string `json:"jumpHostsAllowed,omitempty"` + UserList *[]KeySetUser `json:"userList,omitempty"` +} + +func (o *BareMetalMachineKeySetPatchProperties) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *BareMetalMachineKeySetPatchProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetproperties.go new file mode 100644 index 00000000000..4479e8b7d8f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinekeysetproperties.go @@ -0,0 +1,45 @@ +package networkclouds + +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 BareMetalMachineKeySetProperties struct { + AzureGroupId string `json:"azureGroupId"` + DetailedStatus *BareMetalMachineKeySetDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + Expiration string `json:"expiration"` + JumpHostsAllowed []string `json:"jumpHostsAllowed"` + LastValidation *string `json:"lastValidation,omitempty"` + OsGroupName *string `json:"osGroupName,omitempty"` + PrivilegeLevel BareMetalMachineKeySetPrivilegeLevel `json:"privilegeLevel"` + ProvisioningState *BareMetalMachineKeySetProvisioningState `json:"provisioningState,omitempty"` + UserList []KeySetUser `json:"userList"` + UserListStatus *[]KeySetUserStatus `json:"userListStatus,omitempty"` +} + +func (o *BareMetalMachineKeySetProperties) GetExpirationAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *BareMetalMachineKeySetProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = formatted +} + +func (o *BareMetalMachineKeySetProperties) GetLastValidationAsTime() (*time.Time, error) { + if o.LastValidation == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastValidation, "2006-01-02T15:04:05Z07:00") +} + +func (o *BareMetalMachineKeySetProperties) SetLastValidationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastValidation = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchparameters.go new file mode 100644 index 00000000000..79ee027f011 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachinePatchParameters struct { + Properties *BareMetalMachinePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchproperties.go new file mode 100644 index 00000000000..a3534a23e7b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepatchproperties.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachinePatchProperties struct { + MachineDetails *string `json:"machineDetails,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepoweroffparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepoweroffparameters.go new file mode 100644 index 00000000000..8bc348b5961 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinepoweroffparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachinePowerOffParameters struct { + SkipShutdown *BareMetalMachineSkipShutdown `json:"skipShutdown,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineproperties.go new file mode 100644 index 00000000000..e3700cdb9b9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineproperties.go @@ -0,0 +1,39 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineProperties struct { + AssociatedResourceIds *[]string `json:"associatedResourceIds,omitempty"` + BmcConnectionString string `json:"bmcConnectionString"` + BmcCredentials AdministrativeCredentials `json:"bmcCredentials"` + BmcMacAddress string `json:"bmcMacAddress"` + BootMacAddress string `json:"bootMacAddress"` + ClusterId *string `json:"clusterId,omitempty"` + CordonStatus *BareMetalMachineCordonStatus `json:"cordonStatus,omitempty"` + DetailedStatus *BareMetalMachineDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + HardwareInventory *HardwareInventory `json:"hardwareInventory,omitempty"` + HardwareValidationStatus *HardwareValidationStatus `json:"hardwareValidationStatus,omitempty"` + HybridAksClustersAssociatedIds *[]string `json:"hybridAksClustersAssociatedIds,omitempty"` + KubernetesNodeName *string `json:"kubernetesNodeName,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + MachineClusterVersion *string `json:"machineClusterVersion,omitempty"` + MachineDetails string `json:"machineDetails"` + MachineName string `json:"machineName"` + MachineRoles *[]string `json:"machineRoles,omitempty"` + MachineSkuId string `json:"machineSkuId"` + OamIPv4Address *string `json:"oamIpv4Address,omitempty"` + OamIPv6Address *string `json:"oamIpv6Address,omitempty"` + OsImage *string `json:"osImage,omitempty"` + PowerState *BareMetalMachinePowerState `json:"powerState,omitempty"` + ProvisioningState *BareMetalMachineProvisioningState `json:"provisioningState,omitempty"` + RackId string `json:"rackId"` + RackSlot int64 `json:"rackSlot"` + ReadyState *BareMetalMachineReadyState `json:"readyState,omitempty"` + RuntimeProtectionStatus *RuntimeProtectionStatus `json:"runtimeProtectionStatus,omitempty"` + SecretRotationStatus *[]SecretRotationStatus `json:"secretRotationStatus,omitempty"` + SerialNumber string `json:"serialNumber"` + ServiceTag *string `json:"serviceTag,omitempty"` + VirtualMachinesAssociatedIds *[]string `json:"virtualMachinesAssociatedIds,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinereplaceparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinereplaceparameters.go new file mode 100644 index 00000000000..d5817127854 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinereplaceparameters.go @@ -0,0 +1,12 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineReplaceParameters struct { + BmcCredentials *AdministrativeCredentials `json:"bmcCredentials,omitempty"` + BmcMacAddress *string `json:"bmcMacAddress,omitempty"` + BootMacAddress *string `json:"bootMacAddress,omitempty"` + MachineName *string `json:"machineName,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineruncommandparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineruncommandparameters.go new file mode 100644 index 00000000000..9f2edc4c590 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachineruncommandparameters.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineRunCommandParameters struct { + Arguments *[]string `json:"arguments,omitempty"` + LimitTimeSeconds int64 `json:"limitTimeSeconds"` + Script string `json:"script"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerundataextractsparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerundataextractsparameters.go new file mode 100644 index 00000000000..ffdbebfad75 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerundataextractsparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineRunDataExtractsParameters struct { + Commands []BareMetalMachineCommandSpecification `json:"commands"` + LimitTimeSeconds int64 `json:"limitTimeSeconds"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerunreadcommandsparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerunreadcommandsparameters.go new file mode 100644 index 00000000000..6899c9f7a86 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_baremetalmachinerunreadcommandsparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BareMetalMachineRunReadCommandsParameters struct { + Commands []BareMetalMachineCommandSpecification `json:"commands"` + LimitTimeSeconds int64 `json:"limitTimeSeconds"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpadvertisement.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpadvertisement.go new file mode 100644 index 00000000000..45c4232b9f3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpadvertisement.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpAdvertisement struct { + AdvertiseToFabric *AdvertiseToFabric `json:"advertiseToFabric,omitempty"` + Communities *[]string `json:"communities,omitempty"` + IPAddressPools []string `json:"ipAddressPools"` + Peers *[]string `json:"peers,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpserviceloadbalancerconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpserviceloadbalancerconfiguration.go new file mode 100644 index 00000000000..67595a2bf11 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bgpserviceloadbalancerconfiguration.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpServiceLoadBalancerConfiguration struct { + BgpAdvertisements *[]BgpAdvertisement `json:"bgpAdvertisements,omitempty"` + BgpPeers *[]ServiceLoadBalancerBgpPeer `json:"bgpPeers,omitempty"` + FabricPeeringEnabled *FabricPeeringEnabled `json:"fabricPeeringEnabled,omitempty"` + IPAddressPools *[]IPAddressPool `json:"ipAddressPools,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeyset.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeyset.go new file mode 100644 index 00000000000..744e2dbe3bf --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeyset.go @@ -0,0 +1,19 @@ +package networkclouds + +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 BmcKeySet struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BmcKeySetProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchparameters.go new file mode 100644 index 00000000000..d9278511bed --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BmcKeySetPatchParameters struct { + Properties *BmcKeySetPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchproperties.go new file mode 100644 index 00000000000..c57fcfce384 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetpatchproperties.go @@ -0,0 +1,27 @@ +package networkclouds + +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 BmcKeySetPatchProperties struct { + Expiration *string `json:"expiration,omitempty"` + UserList *[]KeySetUser `json:"userList,omitempty"` +} + +func (o *BmcKeySetPatchProperties) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *BmcKeySetPatchProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetproperties.go new file mode 100644 index 00000000000..d50e656dddd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_bmckeysetproperties.go @@ -0,0 +1,43 @@ +package networkclouds + +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 BmcKeySetProperties struct { + AzureGroupId string `json:"azureGroupId"` + DetailedStatus *BmcKeySetDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + Expiration string `json:"expiration"` + LastValidation *string `json:"lastValidation,omitempty"` + PrivilegeLevel BmcKeySetPrivilegeLevel `json:"privilegeLevel"` + ProvisioningState *BmcKeySetProvisioningState `json:"provisioningState,omitempty"` + UserList []KeySetUser `json:"userList"` + UserListStatus *[]KeySetUserStatus `json:"userListStatus,omitempty"` +} + +func (o *BmcKeySetProperties) GetExpirationAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *BmcKeySetProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = formatted +} + +func (o *BmcKeySetProperties) GetLastValidationAsTime() (*time.Time, error) { + if o.LastValidation == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastValidation, "2006-01-02T15:04:05Z07:00") +} + +func (o *BmcKeySetProperties) SetLastValidationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastValidation = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetwork.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetwork.go new file mode 100644 index 00000000000..ca28bbb07fd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetwork.go @@ -0,0 +1,19 @@ +package networkclouds + +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 CloudServicesNetwork struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudServicesNetworkProperties `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/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchparameters.go new file mode 100644 index 00000000000..15e11f41589 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudServicesNetworkPatchParameters struct { + Properties *CloudServicesNetworkPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchproperties.go new file mode 100644 index 00000000000..e83cda241e9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkpatchproperties.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudServicesNetworkPatchProperties struct { + AdditionalEgressEndpoints *[]EgressEndpoint `json:"additionalEgressEndpoints,omitempty"` + EnableDefaultEgressEndpoints *CloudServicesNetworkEnableDefaultEgressEndpoints `json:"enableDefaultEgressEndpoints,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkproperties.go new file mode 100644 index 00000000000..0fa7d71404d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cloudservicesnetworkproperties.go @@ -0,0 +1,18 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudServicesNetworkProperties struct { + AdditionalEgressEndpoints *[]EgressEndpoint `json:"additionalEgressEndpoints,omitempty"` + AssociatedResourceIds *[]string `json:"associatedResourceIds,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *CloudServicesNetworkDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + EnableDefaultEgressEndpoints *CloudServicesNetworkEnableDefaultEgressEndpoints `json:"enableDefaultEgressEndpoints,omitempty"` + EnabledEgressEndpoints *[]EgressEndpoint `json:"enabledEgressEndpoints,omitempty"` + HybridAksClustersAssociatedIds *[]string `json:"hybridAksClustersAssociatedIds,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + ProvisioningState *CloudServicesNetworkProvisioningState `json:"provisioningState,omitempty"` + VirtualMachinesAssociatedIds *[]string `json:"virtualMachinesAssociatedIds,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_cluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cluster.go new file mode 100644 index 00000000000..91fe63f0a4c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_cluster.go @@ -0,0 +1,21 @@ +package networkclouds + +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 Cluster struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ClusterProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableupgradeversion.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableupgradeversion.go new file mode 100644 index 00000000000..82484fd4819 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableupgradeversion.go @@ -0,0 +1,13 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterAvailableUpgradeVersion struct { + ControlImpact *ControlImpact `json:"controlImpact,omitempty"` + ExpectedDuration *string `json:"expectedDuration,omitempty"` + ImpactDescription *string `json:"impactDescription,omitempty"` + SupportExpiryDate *string `json:"supportExpiryDate,omitempty"` + TargetClusterVersion *string `json:"targetClusterVersion,omitempty"` + WorkloadImpact *WorkloadImpact `json:"workloadImpact,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableversion.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableversion.go new file mode 100644 index 00000000000..8be4a1b01f6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusteravailableversion.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterAvailableVersion struct { + SupportExpiryDate *string `json:"supportExpiryDate,omitempty"` + TargetClusterVersion *string `json:"targetClusterVersion,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercapacity.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercapacity.go new file mode 100644 index 00000000000..ee9995e06ea --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercapacity.go @@ -0,0 +1,15 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterCapacity struct { + AvailableApplianceStorageGB *int64 `json:"availableApplianceStorageGB,omitempty"` + AvailableCoreCount *int64 `json:"availableCoreCount,omitempty"` + AvailableHostStorageGB *int64 `json:"availableHostStorageGB,omitempty"` + AvailableMemoryGB *int64 `json:"availableMemoryGB,omitempty"` + TotalApplianceStorageGB *int64 `json:"totalApplianceStorageGB,omitempty"` + TotalCoreCount *int64 `json:"totalCoreCount,omitempty"` + TotalHostStorageGB *int64 `json:"totalHostStorageGB,omitempty"` + TotalMemoryGB *int64 `json:"totalMemoryGB,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercontinueupdateversionparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercontinueupdateversionparameters.go new file mode 100644 index 00000000000..d0f013446b5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustercontinueupdateversionparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterContinueUpdateVersionParameters struct { + MachineGroupTargetingMode *ClusterContinueUpdateVersionMachineGroupTargetingMode `json:"machineGroupTargetingMode,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterdeployparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterdeployparameters.go new file mode 100644 index 00000000000..4288cc4a5f6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterdeployparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterDeployParameters struct { + SkipValidationsForMachines *[]string `json:"skipValidationsForMachines,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanager.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanager.go new file mode 100644 index 00000000000..9c18ecb9673 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanager.go @@ -0,0 +1,20 @@ +package networkclouds + +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 ClusterManager struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ClusterManagerProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerpatchparameters.go new file mode 100644 index 00000000000..40027aad60b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerpatchparameters.go @@ -0,0 +1,13 @@ +package networkclouds + +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 ClusterManagerPatchParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerproperties.go new file mode 100644 index 00000000000..2d85b9bd9a6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermanagerproperties.go @@ -0,0 +1,21 @@ +package networkclouds + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterManagerProperties struct { + AnalyticsWorkspaceId *string `json:"analyticsWorkspaceId,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + ClusterVersions *[]ClusterAvailableVersion `json:"clusterVersions,omitempty"` + DetailedStatus *ClusterManagerDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + FabricControllerId string `json:"fabricControllerId"` + ManagedResourceGroupConfiguration *ManagedResourceGroupConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManagerExtendedLocation *ExtendedLocation `json:"managerExtendedLocation,omitempty"` + ProvisioningState *ClusterManagerProvisioningState `json:"provisioningState,omitempty"` + VMSize *string `json:"vmSize,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfiguration.go new file mode 100644 index 00000000000..8796826c545 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfiguration.go @@ -0,0 +1,19 @@ +package networkclouds + +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 ClusterMetricsConfiguration struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ClusterMetricsConfigurationProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchparameters.go new file mode 100644 index 00000000000..d8253b39bb3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterMetricsConfigurationPatchParameters struct { + Properties *ClusterMetricsConfigurationPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchproperties.go new file mode 100644 index 00000000000..bf2f89074ab --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationpatchproperties.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterMetricsConfigurationPatchProperties struct { + CollectionInterval *int64 `json:"collectionInterval,omitempty"` + EnabledMetrics *[]string `json:"enabledMetrics,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationproperties.go new file mode 100644 index 00000000000..4d46d5858ea --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustermetricsconfigurationproperties.go @@ -0,0 +1,13 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterMetricsConfigurationProperties struct { + CollectionInterval int64 `json:"collectionInterval"` + DetailedStatus *ClusterMetricsConfigurationDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + DisabledMetrics *[]string `json:"disabledMetrics,omitempty"` + EnabledMetrics *[]string `json:"enabledMetrics,omitempty"` + ProvisioningState *ClusterMetricsConfigurationProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchparameters.go new file mode 100644 index 00000000000..1ccfa5938fe --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchparameters.go @@ -0,0 +1,14 @@ +package networkclouds + +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 ClusterPatchParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ClusterPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchproperties.go new file mode 100644 index 00000000000..1fbead80f49 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterpatchproperties.go @@ -0,0 +1,16 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPatchProperties struct { + AggregatorOrSingleRackDefinition *RackDefinition `json:"aggregatorOrSingleRackDefinition,omitempty"` + ClusterLocation *string `json:"clusterLocation,omitempty"` + ClusterServicePrincipal *ServicePrincipalInformation `json:"clusterServicePrincipal,omitempty"` + CommandOutputSettings *CommandOutputSettings `json:"commandOutputSettings,omitempty"` + ComputeDeploymentThreshold *ValidationThreshold `json:"computeDeploymentThreshold,omitempty"` + ComputeRackDefinitions *[]RackDefinition `json:"computeRackDefinitions,omitempty"` + RuntimeProtectionConfiguration *RuntimeProtectionConfiguration `json:"runtimeProtectionConfiguration,omitempty"` + SecretArchive *ClusterSecretArchive `json:"secretArchive,omitempty"` + UpdateStrategy *ClusterUpdateStrategy `json:"updateStrategy,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterproperties.go new file mode 100644 index 00000000000..97e73257fbb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterproperties.go @@ -0,0 +1,34 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterProperties struct { + AggregatorOrSingleRackDefinition RackDefinition `json:"aggregatorOrSingleRackDefinition"` + AnalyticsWorkspaceId *string `json:"analyticsWorkspaceId,omitempty"` + AvailableUpgradeVersions *[]ClusterAvailableUpgradeVersion `json:"availableUpgradeVersions,omitempty"` + ClusterCapacity *ClusterCapacity `json:"clusterCapacity,omitempty"` + ClusterConnectionStatus *ClusterConnectionStatus `json:"clusterConnectionStatus,omitempty"` + ClusterExtendedLocation *ExtendedLocation `json:"clusterExtendedLocation,omitempty"` + ClusterLocation *string `json:"clusterLocation,omitempty"` + ClusterManagerConnectionStatus *ClusterManagerConnectionStatus `json:"clusterManagerConnectionStatus,omitempty"` + ClusterManagerId *string `json:"clusterManagerId,omitempty"` + ClusterServicePrincipal *ServicePrincipalInformation `json:"clusterServicePrincipal,omitempty"` + ClusterType ClusterType `json:"clusterType"` + ClusterVersion string `json:"clusterVersion"` + CommandOutputSettings *CommandOutputSettings `json:"commandOutputSettings,omitempty"` + ComputeDeploymentThreshold *ValidationThreshold `json:"computeDeploymentThreshold,omitempty"` + ComputeRackDefinitions *[]RackDefinition `json:"computeRackDefinitions,omitempty"` + DetailedStatus *ClusterDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + HybridAksExtendedLocation *ExtendedLocation `json:"hybridAksExtendedLocation,omitempty"` + ManagedResourceGroupConfiguration *ManagedResourceGroupConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManualActionCount *int64 `json:"manualActionCount,omitempty"` + NetworkFabricId string `json:"networkFabricId"` + ProvisioningState *ClusterProvisioningState `json:"provisioningState,omitempty"` + RuntimeProtectionConfiguration *RuntimeProtectionConfiguration `json:"runtimeProtectionConfiguration,omitempty"` + SecretArchive *ClusterSecretArchive `json:"secretArchive,omitempty"` + SupportExpiryDate *string `json:"supportExpiryDate,omitempty"` + UpdateStrategy *ClusterUpdateStrategy `json:"updateStrategy,omitempty"` + WorkloadResourceIds *[]string `json:"workloadResourceIds,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterscanruntimeparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterscanruntimeparameters.go new file mode 100644 index 00000000000..6b8eebfb473 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterscanruntimeparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterScanRuntimeParameters struct { + ScanActivity *ClusterScanRuntimeParametersScanActivity `json:"scanActivity,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustersecretarchive.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustersecretarchive.go new file mode 100644 index 00000000000..4c988a9402f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clustersecretarchive.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterSecretArchive struct { + KeyVaultId string `json:"keyVaultId"` + UseKeyVault *ClusterSecretArchiveEnabled `json:"useKeyVault,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdatestrategy.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdatestrategy.go new file mode 100644 index 00000000000..c467639c1d1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdatestrategy.go @@ -0,0 +1,12 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateStrategy struct { + MaxUnavailable *int64 `json:"maxUnavailable,omitempty"` + StrategyType ClusterUpdateStrategyType `json:"strategyType"` + ThresholdType ValidationThresholdType `json:"thresholdType"` + ThresholdValue int64 `json:"thresholdValue"` + WaitTimeMinutes *int64 `json:"waitTimeMinutes,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdateversionparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdateversionparameters.go new file mode 100644 index 00000000000..a0681f4bb9d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_clusterupdateversionparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateVersionParameters struct { + TargetClusterVersion string `json:"targetClusterVersion"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_commandoutputsettings.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_commandoutputsettings.go new file mode 100644 index 00000000000..1b0f7bf7884 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_commandoutputsettings.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommandOutputSettings struct { + AssociatedIdentity *IdentitySelector `json:"associatedIdentity,omitempty"` + ContainerURL *string `json:"containerUrl,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_console.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_console.go new file mode 100644 index 00000000000..167fbe92c2f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_console.go @@ -0,0 +1,19 @@ +package networkclouds + +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 Console struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ConsoleProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchparameters.go new file mode 100644 index 00000000000..58cc80829fd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConsolePatchParameters struct { + Properties *ConsolePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchproperties.go new file mode 100644 index 00000000000..24f274ea6e3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consolepatchproperties.go @@ -0,0 +1,28 @@ +package networkclouds + +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 ConsolePatchProperties struct { + Enabled *ConsoleEnabled `json:"enabled,omitempty"` + Expiration *string `json:"expiration,omitempty"` + SshPublicKey *SshPublicKey `json:"sshPublicKey,omitempty"` +} + +func (o *ConsolePatchProperties) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *ConsolePatchProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_consoleproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consoleproperties.go new file mode 100644 index 00000000000..18e26f95965 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_consoleproperties.go @@ -0,0 +1,33 @@ +package networkclouds + +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 ConsoleProperties struct { + DetailedStatus *ConsoleDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + Enabled ConsoleEnabled `json:"enabled"` + Expiration *string `json:"expiration,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ConsoleProvisioningState `json:"provisioningState,omitempty"` + SshPublicKey SshPublicKey `json:"sshPublicKey"` + VirtualMachineAccessId *string `json:"virtualMachineAccessId,omitempty"` +} + +func (o *ConsoleProperties) GetExpirationAsTime() (*time.Time, error) { + if o.Expiration == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expiration, "2006-01-02T15:04:05Z07:00") +} + +func (o *ConsoleProperties) SetExpirationAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expiration = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodeconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodeconfiguration.go new file mode 100644 index 00000000000..2e476f36944 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodeconfiguration.go @@ -0,0 +1,15 @@ +package networkclouds + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ControlPlaneNodeConfiguration struct { + AdministratorConfiguration *AdministratorConfiguration `json:"administratorConfiguration,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + Count int64 `json:"count"` + VMSkuName string `json:"vmSkuName"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodepatchconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodepatchconfiguration.go new file mode 100644 index 00000000000..be2598919ee --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_controlplanenodepatchconfiguration.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ControlPlaneNodePatchConfiguration struct { + AdministratorConfiguration *AdministratorConfigurationPatch `json:"administratorConfiguration,omitempty"` + Count *int64 `json:"count,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_egressendpoint.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_egressendpoint.go new file mode 100644 index 00000000000..db41a60fe6d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_egressendpoint.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EgressEndpoint struct { + Category string `json:"category"` + Endpoints []EndpointDependency `json:"endpoints"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_endpointdependency.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_endpointdependency.go new file mode 100644 index 00000000000..0296469962a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_endpointdependency.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName string `json:"domainName"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_extendedlocation.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_extendedlocation.go new file mode 100644 index 00000000000..1e9b95d7c32 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_extendedlocation.go @@ -0,0 +1,9 @@ +package networkclouds + +// 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"` + Type string `json:"type"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_featurestatus.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_featurestatus.go new file mode 100644 index 00000000000..3045cad7561 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_featurestatus.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureStatus struct { + DetailedStatus *FeatureDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventory.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventory.go new file mode 100644 index 00000000000..12623f1e08d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventory.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HardwareInventory struct { + AdditionalHostInformation *string `json:"additionalHostInformation,omitempty"` + Interfaces *[]HardwareInventoryNetworkInterface `json:"interfaces,omitempty"` + Nics *[]Nic `json:"nics,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventorynetworkinterface.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventorynetworkinterface.go new file mode 100644 index 00000000000..b00f92436ba --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwareinventorynetworkinterface.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HardwareInventoryNetworkInterface struct { + LinkStatus *string `json:"linkStatus,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + Name *string `json:"name,omitempty"` + NetworkInterfaceId *string `json:"networkInterfaceId,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwarevalidationstatus.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwarevalidationstatus.go new file mode 100644 index 00000000000..531dafc584f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_hardwarevalidationstatus.go @@ -0,0 +1,27 @@ +package networkclouds + +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 HardwareValidationStatus struct { + LastValidationTime *string `json:"lastValidationTime,omitempty"` + Result *BareMetalMachineHardwareValidationResult `json:"result,omitempty"` +} + +func (o *HardwareValidationStatus) GetLastValidationTimeAsTime() (*time.Time, error) { + if o.LastValidationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastValidationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *HardwareValidationStatus) SetLastValidationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastValidationTime = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_identityselector.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_identityselector.go new file mode 100644 index 00000000000..b85a409fbca --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_identityselector.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentitySelector struct { + IdentityType *ManagedServiceIdentitySelectorType `json:"identityType,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_imagerepositorycredentials.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_imagerepositorycredentials.go new file mode 100644 index 00000000000..59801505f31 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_imagerepositorycredentials.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageRepositoryCredentials struct { + Password string `json:"password"` + RegistryURL string `json:"registryUrl"` + Username string `json:"username"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_initialagentpoolconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_initialagentpoolconfiguration.go new file mode 100644 index 00000000000..f343487a497 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_initialagentpoolconfiguration.go @@ -0,0 +1,22 @@ +package networkclouds + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitialAgentPoolConfiguration struct { + AdministratorConfiguration *AdministratorConfiguration `json:"administratorConfiguration,omitempty"` + AgentOptions *AgentOptions `json:"agentOptions,omitempty"` + AttachedNetworkConfiguration *AttachedNetworkConfiguration `json:"attachedNetworkConfiguration,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + Count int64 `json:"count"` + Labels *[]KubernetesLabel `json:"labels,omitempty"` + Mode AgentPoolMode `json:"mode"` + Name string `json:"name"` + Taints *[]KubernetesLabel `json:"taints,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSkuName string `json:"vmSkuName"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_ipaddresspool.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_ipaddresspool.go new file mode 100644 index 00000000000..1656beaecf5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_ipaddresspool.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressPool struct { + Addresses []string `json:"addresses"` + AutoAssign *BfdEnabled `json:"autoAssign,omitempty"` + Name string `json:"name"` + OnlyUseHostIPs *BfdEnabled `json:"onlyUseHostIps,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuser.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuser.go new file mode 100644 index 00000000000..6060c4d1aa5 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuser.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeySetUser struct { + AzureUserName string `json:"azureUserName"` + Description *string `json:"description,omitempty"` + SshPublicKey SshPublicKey `json:"sshPublicKey"` + UserPrincipalName *string `json:"userPrincipalName,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuserstatus.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuserstatus.go new file mode 100644 index 00000000000..047e217cc1b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_keysetuserstatus.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeySetUserStatus struct { + AzureUserName *string `json:"azureUserName,omitempty"` + Status *BareMetalMachineKeySetUserSetupStatus `json:"status,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetescluster.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetescluster.go new file mode 100644 index 00000000000..92061bec7d4 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetescluster.go @@ -0,0 +1,19 @@ +package networkclouds + +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 KubernetesCluster struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties KubernetesClusterProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeature.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeature.go new file mode 100644 index 00000000000..be3cba783a1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeature.go @@ -0,0 +1,18 @@ +package networkclouds + +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 KubernetesClusterFeature struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *KubernetesClusterFeatureProperties `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/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchparameters.go new file mode 100644 index 00000000000..f9239eb8d7f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterFeaturePatchParameters struct { + Properties *KubernetesClusterFeaturePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchproperties.go new file mode 100644 index 00000000000..d107afa5528 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeaturepatchproperties.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterFeaturePatchProperties struct { + Options *[]StringKeyValuePair `json:"options,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeatureproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeatureproperties.go new file mode 100644 index 00000000000..139f236e8fa --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterfeatureproperties.go @@ -0,0 +1,14 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterFeatureProperties struct { + AvailabilityLifecycle *KubernetesClusterFeatureAvailabilityLifecycle `json:"availabilityLifecycle,omitempty"` + DetailedStatus *KubernetesClusterFeatureDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + Options *[]StringKeyValuePair `json:"options,omitempty"` + ProvisioningState *KubernetesClusterFeatureProvisioningState `json:"provisioningState,omitempty"` + Required *KubernetesClusterFeatureRequired `json:"required,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusternode.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusternode.go new file mode 100644 index 00000000000..6dcfbc5d902 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusternode.go @@ -0,0 +1,25 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterNode struct { + AgentPoolId *string `json:"agentPoolId,omitempty"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + BareMetalMachineId *string `json:"bareMetalMachineId,omitempty"` + CpuCores *int64 `json:"cpuCores,omitempty"` + DetailedStatus *KubernetesClusterNodeDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Image *string `json:"image,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + Labels *[]KubernetesLabel `json:"labels,omitempty"` + MemorySizeGB *int64 `json:"memorySizeGB,omitempty"` + Mode *AgentPoolMode `json:"mode,omitempty"` + Name *string `json:"name,omitempty"` + NetworkAttachments *[]NetworkAttachment `json:"networkAttachments,omitempty"` + PowerState *KubernetesNodePowerState `json:"powerState,omitempty"` + Role *KubernetesNodeRole `json:"role,omitempty"` + Taints *[]KubernetesLabel `json:"taints,omitempty"` + VMSkuName *string `json:"vmSkuName,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchparameters.go new file mode 100644 index 00000000000..2c223836a05 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterPatchParameters struct { + Properties *KubernetesClusterPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchproperties.go new file mode 100644 index 00000000000..421040af964 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterpatchproperties.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterPatchProperties struct { + AdministratorConfiguration *AdministratorConfigurationPatch `json:"administratorConfiguration,omitempty"` + ControlPlaneNodeConfiguration *ControlPlaneNodePatchConfiguration `json:"controlPlaneNodeConfiguration,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterproperties.go new file mode 100644 index 00000000000..74513821566 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterproperties.go @@ -0,0 +1,24 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterProperties struct { + AadConfiguration *AadConfiguration `json:"aadConfiguration,omitempty"` + AdministratorConfiguration *AdministratorConfiguration `json:"administratorConfiguration,omitempty"` + AttachedNetworkIds *[]string `json:"attachedNetworkIds,omitempty"` + AvailableUpgrades *[]AvailableUpgrade `json:"availableUpgrades,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + ConnectedClusterId *string `json:"connectedClusterId,omitempty"` + ControlPlaneKubernetesVersion *string `json:"controlPlaneKubernetesVersion,omitempty"` + ControlPlaneNodeConfiguration ControlPlaneNodeConfiguration `json:"controlPlaneNodeConfiguration"` + DetailedStatus *KubernetesClusterDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + FeatureStatuses *[]FeatureStatus `json:"featureStatuses,omitempty"` + InitialAgentPoolConfigurations []InitialAgentPoolConfiguration `json:"initialAgentPoolConfigurations"` + KubernetesVersion string `json:"kubernetesVersion"` + ManagedResourceGroupConfiguration *ManagedResourceGroupConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + NetworkConfiguration NetworkConfiguration `json:"networkConfiguration"` + Nodes *[]KubernetesClusterNode `json:"nodes,omitempty"` + ProvisioningState *KubernetesClusterProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterrestartnodeparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterrestartnodeparameters.go new file mode 100644 index 00000000000..42233a97a5b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kubernetesclusterrestartnodeparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesClusterRestartNodeParameters struct { + NodeName string `json:"nodeName"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_kuberneteslabel.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kuberneteslabel.go new file mode 100644 index 00000000000..ccd92eb88fe --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_kuberneteslabel.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesLabel struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2network.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2network.go new file mode 100644 index 00000000000..40c08f12217 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2network.go @@ -0,0 +1,19 @@ +package networkclouds + +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 L2Network struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties L2NetworkProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkattachmentconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkattachmentconfiguration.go new file mode 100644 index 00000000000..6366c6c222c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkattachmentconfiguration.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L2NetworkAttachmentConfiguration struct { + NetworkId string `json:"networkId"` + PluginType *KubernetesPluginType `json:"pluginType,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkpatchparameters.go new file mode 100644 index 00000000000..1b29c95c28c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkpatchparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L2NetworkPatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkproperties.go new file mode 100644 index 00000000000..4815620e1dd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2networkproperties.go @@ -0,0 +1,17 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L2NetworkProperties struct { + AssociatedResourceIds *[]string `json:"associatedResourceIds,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *L2NetworkDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + HybridAksClustersAssociatedIds *[]string `json:"hybridAksClustersAssociatedIds,omitempty"` + HybridAksPluginType *HybridAksPluginType `json:"hybridAksPluginType,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + L2IsolationDomainId string `json:"l2IsolationDomainId"` + ProvisioningState *L2NetworkProvisioningState `json:"provisioningState,omitempty"` + VirtualMachinesAssociatedIds *[]string `json:"virtualMachinesAssociatedIds,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2serviceloadbalancerconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2serviceloadbalancerconfiguration.go new file mode 100644 index 00000000000..82f41b29daa --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l2serviceloadbalancerconfiguration.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L2ServiceLoadBalancerConfiguration struct { + IPAddressPools *[]IPAddressPool `json:"ipAddressPools,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3network.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3network.go new file mode 100644 index 00000000000..11a7b87eacb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3network.go @@ -0,0 +1,19 @@ +package networkclouds + +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 L3Network struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties L3NetworkProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkattachmentconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkattachmentconfiguration.go new file mode 100644 index 00000000000..4b6be239b78 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkattachmentconfiguration.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L3NetworkAttachmentConfiguration struct { + IPamEnabled *L3NetworkConfigurationIPamEnabled `json:"ipamEnabled,omitempty"` + NetworkId string `json:"networkId"` + PluginType *KubernetesPluginType `json:"pluginType,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkpatchparameters.go new file mode 100644 index 00000000000..2c8fd09c5a8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkpatchparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L3NetworkPatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkproperties.go new file mode 100644 index 00000000000..7ff851860d1 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_l3networkproperties.go @@ -0,0 +1,22 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type L3NetworkProperties struct { + AssociatedResourceIds *[]string `json:"associatedResourceIds,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *L3NetworkDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + HybridAksClustersAssociatedIds *[]string `json:"hybridAksClustersAssociatedIds,omitempty"` + HybridAksIPamEnabled *HybridAksIPamEnabled `json:"hybridAksIpamEnabled,omitempty"` + HybridAksPluginType *HybridAksPluginType `json:"hybridAksPluginType,omitempty"` + IPAllocationType *IPAllocationType `json:"ipAllocationType,omitempty"` + IPv4ConnectedPrefix *string `json:"ipv4ConnectedPrefix,omitempty"` + IPv6ConnectedPrefix *string `json:"ipv6ConnectedPrefix,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + L3IsolationDomainId string `json:"l3IsolationDomainId"` + ProvisioningState *L3NetworkProvisioningState `json:"provisioningState,omitempty"` + VirtualMachinesAssociatedIds *[]string `json:"virtualMachinesAssociatedIds,omitempty"` + Vlan int64 `json:"vlan"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_lldpneighbor.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_lldpneighbor.go new file mode 100644 index 00000000000..7586af65ffb --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_lldpneighbor.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LldpNeighbor struct { + PortDescription *string `json:"portDescription,omitempty"` + PortName *string `json:"portName,omitempty"` + SystemDescription *string `json:"systemDescription,omitempty"` + SystemName *string `json:"systemName,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_machinedisk.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machinedisk.go new file mode 100644 index 00000000000..0b56885b425 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machinedisk.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineDisk struct { + CapacityGB *int64 `json:"capacityGB,omitempty"` + Connection *MachineSkuDiskConnectionType `json:"connection,omitempty"` + Type *DiskType `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuproperties.go new file mode 100644 index 00000000000..4440c9c4035 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuproperties.go @@ -0,0 +1,18 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineSkuProperties struct { + BootstrapProtocol *BootstrapProtocol `json:"bootstrapProtocol,omitempty"` + CpuCores *int64 `json:"cpuCores,omitempty"` + CpuSockets *int64 `json:"cpuSockets,omitempty"` + Disks *[]MachineDisk `json:"disks,omitempty"` + Generation *string `json:"generation,omitempty"` + HardwareVersion *string `json:"hardwareVersion,omitempty"` + MemoryCapacityGB *int64 `json:"memoryCapacityGB,omitempty"` + Model *string `json:"model,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + TotalThreads *int64 `json:"totalThreads,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuslot.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuslot.go new file mode 100644 index 00000000000..944e1e75dc0 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_machineskuslot.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineSkuSlot struct { + Properties *MachineSkuProperties `json:"properties,omitempty"` + RackSlot *int64 `json:"rackSlot,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_managedresourcegroupconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_managedresourcegroupconfiguration.go new file mode 100644 index 00000000000..dd071eedb2c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_managedresourcegroupconfiguration.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedResourceGroupConfiguration struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkattachment.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkattachment.go new file mode 100644 index 00000000000..01ee46ea5a8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkattachment.go @@ -0,0 +1,14 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkAttachment struct { + AttachedNetworkId string `json:"attachedNetworkId"` + DefaultGateway *DefaultGateway `json:"defaultGateway,omitempty"` + IPAllocationMethod VirtualMachineIPAllocationMethod `json:"ipAllocationMethod"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv6Address *string `json:"ipv6Address,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + NetworkAttachmentName *string `json:"networkAttachmentName,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkconfiguration.go new file mode 100644 index 00000000000..1a2b7f78d13 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkconfiguration.go @@ -0,0 +1,15 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfiguration struct { + AttachedNetworkConfiguration *AttachedNetworkConfiguration `json:"attachedNetworkConfiguration,omitempty"` + BgpServiceLoadBalancerConfiguration *BgpServiceLoadBalancerConfiguration `json:"bgpServiceLoadBalancerConfiguration,omitempty"` + CloudServicesNetworkId string `json:"cloudServicesNetworkId"` + CniNetworkId string `json:"cniNetworkId"` + DnsServiceIP *string `json:"dnsServiceIp,omitempty"` + L2ServiceLoadBalancerConfiguration *L2ServiceLoadBalancerConfiguration `json:"l2ServiceLoadBalancerConfiguration,omitempty"` + PodCidrs *[]string `json:"podCidrs,omitempty"` + ServiceCidrs *[]string `json:"serviceCidrs,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkinterface.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkinterface.go new file mode 100644 index 00000000000..e02a1ce5587 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_networkinterface.go @@ -0,0 +1,14 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Address *string `json:"address,omitempty"` + DeviceConnectionType *DeviceConnectionType `json:"deviceConnectionType,omitempty"` + Model *string `json:"model,omitempty"` + PhysicalSlot *int64 `json:"physicalSlot,omitempty"` + PortCount *int64 `json:"portCount,omitempty"` + PortSpeed *int64 `json:"portSpeed,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_nic.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_nic.go new file mode 100644 index 00000000000..01de1971e1a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_nic.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nic struct { + LldpNeighbor *LldpNeighbor `json:"lldpNeighbor,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_nodepooladministratorconfigurationpatch.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_nodepooladministratorconfigurationpatch.go new file mode 100644 index 00000000000..5516918d554 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_nodepooladministratorconfigurationpatch.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodePoolAdministratorConfigurationPatch struct { + SshPublicKeys *[]SshPublicKey `json:"sshPublicKeys,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_osdisk.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_osdisk.go new file mode 100644 index 00000000000..a99af638ee7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_osdisk.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsDisk struct { + CreateOption *OsDiskCreateOption `json:"createOption,omitempty"` + DeleteOption *OsDiskDeleteOption `json:"deleteOption,omitempty"` + DiskSizeGB int64 `json:"diskSizeGB"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rack.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rack.go new file mode 100644 index 00000000000..54818237fbe --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rack.go @@ -0,0 +1,19 @@ +package networkclouds + +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 Rack struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties RackProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackdefinition.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackdefinition.go new file mode 100644 index 00000000000..76b3b0c45d3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackdefinition.go @@ -0,0 +1,14 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RackDefinition struct { + AvailabilityZone *string `json:"availabilityZone,omitempty"` + BareMetalMachineConfigurationData *[]BareMetalMachineConfigurationData `json:"bareMetalMachineConfigurationData,omitempty"` + NetworkRackId string `json:"networkRackId"` + RackLocation *string `json:"rackLocation,omitempty"` + RackSerialNumber string `json:"rackSerialNumber"` + RackSkuId string `json:"rackSkuId"` + StorageApplianceConfigurationData *[]StorageApplianceConfigurationData `json:"storageApplianceConfigurationData,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackpatchparameters.go new file mode 100644 index 00000000000..6425d2140b0 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackpatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RackPatchParameters struct { + Properties *RacksPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackproperties.go new file mode 100644 index 00000000000..d0c195f5093 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackproperties.go @@ -0,0 +1,15 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RackProperties struct { + AvailabilityZone string `json:"availabilityZone"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *RackDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + ProvisioningState *RackProvisioningState `json:"provisioningState,omitempty"` + RackLocation string `json:"rackLocation"` + RackSerialNumber string `json:"rackSerialNumber"` + RackSkuId string `json:"rackSkuId"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_racksku.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_racksku.go new file mode 100644 index 00000000000..ed24bf4f17b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_racksku.go @@ -0,0 +1,16 @@ +package networkclouds + +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 RackSku struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties RackSkuProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackskuproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackskuproperties.go new file mode 100644 index 00000000000..929010446a8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackskuproperties.go @@ -0,0 +1,15 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RackSkuProperties struct { + ComputeMachines *[]MachineSkuSlot `json:"computeMachines,omitempty"` + ControllerMachines *[]MachineSkuSlot `json:"controllerMachines,omitempty"` + Description *string `json:"description,omitempty"` + MaxClusterSlots *int64 `json:"maxClusterSlots,omitempty"` + ProvisioningState *RackSkuProvisioningState `json:"provisioningState,omitempty"` + RackType *RackSkuType `json:"rackType,omitempty"` + StorageAppliances *[]StorageApplianceSkuSlot `json:"storageAppliances,omitempty"` + SupportedRackSkuIds *[]string `json:"supportedRackSkuIds,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackspatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackspatchproperties.go new file mode 100644 index 00000000000..264a7a367be --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_rackspatchproperties.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RacksPatchProperties struct { + RackLocation *string `json:"rackLocation,omitempty"` + RackSerialNumber *string `json:"rackSerialNumber,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionconfiguration.go new file mode 100644 index 00000000000..6d963f876a4 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionconfiguration.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuntimeProtectionConfiguration struct { + EnforcementLevel *RuntimeProtectionEnforcementLevel `json:"enforcementLevel,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionstatus.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionstatus.go new file mode 100644 index 00000000000..9df51079c3b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_runtimeprotectionstatus.go @@ -0,0 +1,66 @@ +package networkclouds + +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 RuntimeProtectionStatus struct { + DefinitionsLastUpdated *string `json:"definitionsLastUpdated,omitempty"` + DefinitionsVersion *string `json:"definitionsVersion,omitempty"` + ScanCompletedTime *string `json:"scanCompletedTime,omitempty"` + ScanScheduledTime *string `json:"scanScheduledTime,omitempty"` + ScanStartedTime *string `json:"scanStartedTime,omitempty"` +} + +func (o *RuntimeProtectionStatus) GetDefinitionsLastUpdatedAsTime() (*time.Time, error) { + if o.DefinitionsLastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DefinitionsLastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *RuntimeProtectionStatus) SetDefinitionsLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DefinitionsLastUpdated = &formatted +} + +func (o *RuntimeProtectionStatus) GetScanCompletedTimeAsTime() (*time.Time, error) { + if o.ScanCompletedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScanCompletedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RuntimeProtectionStatus) SetScanCompletedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScanCompletedTime = &formatted +} + +func (o *RuntimeProtectionStatus) GetScanScheduledTimeAsTime() (*time.Time, error) { + if o.ScanScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScanScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RuntimeProtectionStatus) SetScanScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScanScheduledTime = &formatted +} + +func (o *RuntimeProtectionStatus) GetScanStartedTimeAsTime() (*time.Time, error) { + if o.ScanStartedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScanStartedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RuntimeProtectionStatus) SetScanStartedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScanStartedTime = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretarchivereference.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretarchivereference.go new file mode 100644 index 00000000000..578020d99c3 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretarchivereference.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretArchiveReference struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + SecretName *string `json:"secretName,omitempty"` + SecretVersion *string `json:"secretVersion,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretrotationstatus.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretrotationstatus.go new file mode 100644 index 00000000000..bf0947eafaa --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_secretrotationstatus.go @@ -0,0 +1,30 @@ +package networkclouds + +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 SecretRotationStatus struct { + ExpirePeriodDays *int64 `json:"expirePeriodDays,omitempty"` + LastRotationTime *string `json:"lastRotationTime,omitempty"` + RotationPeriodDays *int64 `json:"rotationPeriodDays,omitempty"` + SecretArchiveReference *SecretArchiveReference `json:"secretArchiveReference,omitempty"` + SecretType *string `json:"secretType,omitempty"` +} + +func (o *SecretRotationStatus) GetLastRotationTimeAsTime() (*time.Time, error) { + if o.LastRotationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRotationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SecretRotationStatus) SetLastRotationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRotationTime = &formatted +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceloadbalancerbgppeer.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceloadbalancerbgppeer.go new file mode 100644 index 00000000000..2a26349fd59 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceloadbalancerbgppeer.go @@ -0,0 +1,17 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceLoadBalancerBgpPeer struct { + BfdEnabled *BfdEnabled `json:"bfdEnabled,omitempty"` + BgpMultiHop *BgpMultiHop `json:"bgpMultiHop,omitempty"` + HoldTime *string `json:"holdTime,omitempty"` + KeepAliveTime *string `json:"keepAliveTime,omitempty"` + MyAsn *int64 `json:"myAsn,omitempty"` + Name string `json:"name"` + Password *string `json:"password,omitempty"` + PeerAddress string `json:"peerAddress"` + PeerAsn int64 `json:"peerAsn"` + PeerPort *int64 `json:"peerPort,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceprincipalinformation.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceprincipalinformation.go new file mode 100644 index 00000000000..22cc2c29239 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_serviceprincipalinformation.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePrincipalInformation struct { + ApplicationId string `json:"applicationId"` + Password string `json:"password"` + PrincipalId string `json:"principalId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_sshpublickey.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_sshpublickey.go new file mode 100644 index 00000000000..3b994fed75e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_sshpublickey.go @@ -0,0 +1,8 @@ +package networkclouds + +// 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"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliance.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliance.go new file mode 100644 index 00000000000..58f49e2ccf2 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliance.go @@ -0,0 +1,19 @@ +package networkclouds + +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 StorageAppliance struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties StorageApplianceProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceconfigurationdata.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceconfigurationdata.go new file mode 100644 index 00000000000..c4fe0c174f8 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceconfigurationdata.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageApplianceConfigurationData struct { + AdminCredentials AdministrativeCredentials `json:"adminCredentials"` + RackSlot int64 `json:"rackSlot"` + SerialNumber string `json:"serialNumber"` + StorageApplianceName *string `json:"storageApplianceName,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceenableremotevendormanagementparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceenableremotevendormanagementparameters.go new file mode 100644 index 00000000000..ae86482363f --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceenableremotevendormanagementparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageApplianceEnableRemoteVendorManagementParameters struct { + SupportEndpoints *[]string `json:"supportEndpoints,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchparameters.go new file mode 100644 index 00000000000..4ae536b1a4b --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageAppliancePatchParameters struct { + Properties *StorageAppliancePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchproperties.go new file mode 100644 index 00000000000..cbe3a7b334a --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageappliancepatchproperties.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageAppliancePatchProperties struct { + SerialNumber *string `json:"serialNumber,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceproperties.go new file mode 100644 index 00000000000..f6b000f01c6 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceproperties.go @@ -0,0 +1,25 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageApplianceProperties struct { + AdministratorCredentials AdministrativeCredentials `json:"administratorCredentials"` + Capacity *int64 `json:"capacity,omitempty"` + CapacityUsed *int64 `json:"capacityUsed,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *StorageApplianceDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + ManagementIPv4Address *string `json:"managementIpv4Address,omitempty"` + Manufacturer *string `json:"manufacturer,omitempty"` + Model *string `json:"model,omitempty"` + ProvisioningState *StorageApplianceProvisioningState `json:"provisioningState,omitempty"` + RackId string `json:"rackId"` + RackSlot int64 `json:"rackSlot"` + RemoteVendorManagementFeature *RemoteVendorManagementFeature `json:"remoteVendorManagementFeature,omitempty"` + RemoteVendorManagementStatus *RemoteVendorManagementStatus `json:"remoteVendorManagementStatus,omitempty"` + SecretRotationStatus *[]SecretRotationStatus `json:"secretRotationStatus,omitempty"` + SerialNumber string `json:"serialNumber"` + StorageApplianceSkuId string `json:"storageApplianceSkuId"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuproperties.go new file mode 100644 index 00000000000..444a786c682 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuproperties.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageApplianceSkuProperties struct { + CapacityGB *int64 `json:"capacityGB,omitempty"` + Model *string `json:"model,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuslot.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuslot.go new file mode 100644 index 00000000000..d07b746db91 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageapplianceskuslot.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageApplianceSkuSlot struct { + Properties *StorageApplianceSkuProperties `json:"properties,omitempty"` + RackSlot *int64 `json:"rackSlot,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageprofile.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageprofile.go new file mode 100644 index 00000000000..1956718c580 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_storageprofile.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageProfile struct { + OsDisk OsDisk `json:"osDisk"` + VolumeAttachments *[]string `json:"volumeAttachments,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_stringkeyvaluepair.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_stringkeyvaluepair.go new file mode 100644 index 00000000000..27df8978e44 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_stringkeyvaluepair.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringKeyValuePair struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetwork.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetwork.go new file mode 100644 index 00000000000..b99105658dc --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetwork.go @@ -0,0 +1,19 @@ +package networkclouds + +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 TrunkedNetwork struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties TrunkedNetworkProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkattachmentconfiguration.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkattachmentconfiguration.go new file mode 100644 index 00000000000..307e3f3a09c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkattachmentconfiguration.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrunkedNetworkAttachmentConfiguration struct { + NetworkId string `json:"networkId"` + PluginType *KubernetesPluginType `json:"pluginType,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkpatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkpatchparameters.go new file mode 100644 index 00000000000..40799d5166d --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkpatchparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrunkedNetworkPatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkproperties.go new file mode 100644 index 00000000000..521b30a1bf9 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_trunkednetworkproperties.go @@ -0,0 +1,18 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrunkedNetworkProperties struct { + AssociatedResourceIds *[]string `json:"associatedResourceIds,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + DetailedStatus *TrunkedNetworkDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + HybridAksClustersAssociatedIds *[]string `json:"hybridAksClustersAssociatedIds,omitempty"` + HybridAksPluginType *HybridAksPluginType `json:"hybridAksPluginType,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + IsolationDomainIds []string `json:"isolationDomainIds"` + ProvisioningState *TrunkedNetworkProvisioningState `json:"provisioningState,omitempty"` + VirtualMachinesAssociatedIds *[]string `json:"virtualMachinesAssociatedIds,omitempty"` + Vlans []int64 `json:"vlans"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_validationthreshold.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_validationthreshold.go new file mode 100644 index 00000000000..775f1d32e76 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_validationthreshold.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidationThreshold struct { + Grouping ValidationThresholdGrouping `json:"grouping"` + Type ValidationThresholdType `json:"type"` + Value int64 `json:"value"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachine.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachine.go new file mode 100644 index 00000000000..4c8999f2b60 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachine.go @@ -0,0 +1,19 @@ +package networkclouds + +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 VirtualMachine struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties VirtualMachineProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchparameters.go new file mode 100644 index 00000000000..87e38b7ed7e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchparameters.go @@ -0,0 +1,9 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachinePatchParameters struct { + Properties *VirtualMachinePatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchproperties.go new file mode 100644 index 00000000000..13d795c02c7 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepatchproperties.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachinePatchProperties struct { + VMImageRepositoryCredentials *ImageRepositoryCredentials `json:"vmImageRepositoryCredentials,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineplacementhint.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineplacementhint.go new file mode 100644 index 00000000000..c72b6109031 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineplacementhint.go @@ -0,0 +1,11 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachinePlacementHint struct { + HintType VirtualMachinePlacementHintType `json:"hintType"` + ResourceId string `json:"resourceId"` + SchedulingExecution VirtualMachineSchedulingExecution `json:"schedulingExecution"` + Scope VirtualMachinePlacementHintPodAffinityScope `json:"scope"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepoweroffparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepoweroffparameters.go new file mode 100644 index 00000000000..4d565f9e841 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachinepoweroffparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachinePowerOffParameters struct { + SkipShutdown *SkipShutdown `json:"skipShutdown,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineproperties.go new file mode 100644 index 00000000000..21da057531e --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_virtualmachineproperties.go @@ -0,0 +1,31 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineProperties struct { + AdminUsername string `json:"adminUsername"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + BareMetalMachineId *string `json:"bareMetalMachineId,omitempty"` + BootMethod *VirtualMachineBootMethod `json:"bootMethod,omitempty"` + CloudServicesNetworkAttachment NetworkAttachment `json:"cloudServicesNetworkAttachment"` + ClusterId *string `json:"clusterId,omitempty"` + CpuCores int64 `json:"cpuCores"` + DetailedStatus *VirtualMachineDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + IsolateEmulatorThread *VirtualMachineIsolateEmulatorThread `json:"isolateEmulatorThread,omitempty"` + MemorySizeGB int64 `json:"memorySizeGB"` + NetworkAttachments *[]NetworkAttachment `json:"networkAttachments,omitempty"` + NetworkData *string `json:"networkData,omitempty"` + PlacementHints *[]VirtualMachinePlacementHint `json:"placementHints,omitempty"` + PowerState *VirtualMachinePowerState `json:"powerState,omitempty"` + ProvisioningState *VirtualMachineProvisioningState `json:"provisioningState,omitempty"` + SshPublicKeys *[]SshPublicKey `json:"sshPublicKeys,omitempty"` + StorageProfile StorageProfile `json:"storageProfile"` + UserData *string `json:"userData,omitempty"` + VMDeviceModel *VirtualMachineDeviceModelType `json:"vmDeviceModel,omitempty"` + VMImageRepositoryCredentials *ImageRepositoryCredentials `json:"vmImageRepositoryCredentials,omitempty"` + VirtioInterface *VirtualMachineVirtioInterfaceType `json:"virtioInterface,omitempty"` + VmImage string `json:"vmImage"` + Volumes *[]string `json:"volumes,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_volume.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volume.go new file mode 100644 index 00000000000..5810a1d6685 --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volume.go @@ -0,0 +1,19 @@ +package networkclouds + +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 Volume struct { + ExtendedLocation ExtendedLocation `json:"extendedLocation"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties VolumeProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumepatchparameters.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumepatchparameters.go new file mode 100644 index 00000000000..04db871252c --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumepatchparameters.go @@ -0,0 +1,8 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumePatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumeproperties.go b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumeproperties.go new file mode 100644 index 00000000000..6d759dc0fea --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/model_volumeproperties.go @@ -0,0 +1,13 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeProperties struct { + AttachedTo *[]string `json:"attachedTo,omitempty"` + DetailedStatus *VolumeDetailedStatus `json:"detailedStatus,omitempty"` + DetailedStatusMessage *string `json:"detailedStatusMessage,omitempty"` + ProvisioningState *VolumeProvisioningState `json:"provisioningState,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SizeMiB int64 `json:"sizeMiB"` +} diff --git a/resource-manager/networkcloud/2024-07-01/networkclouds/predicates.go b/resource-manager/networkcloud/2024-07-01/networkclouds/predicates.go new file mode 100644 index 00000000000..1df4332d1fd --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/predicates.go @@ -0,0 +1,531 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AgentPoolOperationPredicate) Matches(input AgentPool) 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 +} + +type BareMetalMachineOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BareMetalMachineOperationPredicate) Matches(input BareMetalMachine) 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 +} + +type BareMetalMachineKeySetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BareMetalMachineKeySetOperationPredicate) Matches(input BareMetalMachineKeySet) 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 +} + +type BmcKeySetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BmcKeySetOperationPredicate) Matches(input BmcKeySet) 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 +} + +type CloudServicesNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudServicesNetworkOperationPredicate) Matches(input CloudServicesNetwork) 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 +} + +type ClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterOperationPredicate) Matches(input Cluster) 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 +} + +type ClusterManagerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterManagerOperationPredicate) Matches(input ClusterManager) 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 +} + +type ClusterMetricsConfigurationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterMetricsConfigurationOperationPredicate) Matches(input ClusterMetricsConfiguration) 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 +} + +type ConsoleOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ConsoleOperationPredicate) Matches(input Console) 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 +} + +type KubernetesClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p KubernetesClusterOperationPredicate) Matches(input KubernetesCluster) 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 +} + +type KubernetesClusterFeatureOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p KubernetesClusterFeatureOperationPredicate) Matches(input KubernetesClusterFeature) 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 +} + +type L2NetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p L2NetworkOperationPredicate) Matches(input L2Network) 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 +} + +type L3NetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p L3NetworkOperationPredicate) Matches(input L3Network) 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 +} + +type RackOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RackOperationPredicate) Matches(input Rack) 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 +} + +type RackSkuOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RackSkuOperationPredicate) Matches(input RackSku) 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 +} + +type StorageApplianceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageApplianceOperationPredicate) Matches(input StorageAppliance) 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 +} + +type TrunkedNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p TrunkedNetworkOperationPredicate) Matches(input TrunkedNetwork) 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 +} + +type VirtualMachineOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualMachineOperationPredicate) Matches(input VirtualMachine) 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 +} + +type VolumeOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VolumeOperationPredicate) Matches(input Volume) 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/networkcloud/2024-07-01/networkclouds/version.go b/resource-manager/networkcloud/2024-07-01/networkclouds/version.go new file mode 100644 index 00000000000..7d0c00933ea --- /dev/null +++ b/resource-manager/networkcloud/2024-07-01/networkclouds/version.go @@ -0,0 +1,10 @@ +package networkclouds + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkclouds/2024-07-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md new file mode 100644 index 00000000000..9f7d761d0a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/availableservicetiers` Documentation + +The `availableservicetiers` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/availableservicetiers" +``` + + +### Client Initialization + +```go +client := availableservicetiers.NewAvailableServiceTiersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailableServiceTiersClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := availableservicetiers.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go new file mode 100644 index 00000000000..3396efc04c9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/client.go @@ -0,0 +1,26 @@ +package availableservicetiers + +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 AvailableServiceTiersClient struct { + Client *resourcemanager.Client +} + +func NewAvailableServiceTiersClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailableServiceTiersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "availableservicetiers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailableServiceTiersClient: %+v", err) + } + + return &AvailableServiceTiersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go new file mode 100644 index 00000000000..26729cec9cc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/constants.go @@ -0,0 +1,66 @@ +package availableservicetiers + +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 SkuNameEnum string + +const ( + SkuNameEnumCapacityReservation SkuNameEnum = "CapacityReservation" + SkuNameEnumFree SkuNameEnum = "Free" + SkuNameEnumPerGBTwoZeroOneEight SkuNameEnum = "PerGB2018" + SkuNameEnumPerNode SkuNameEnum = "PerNode" + SkuNameEnumPremium SkuNameEnum = "Premium" + SkuNameEnumStandalone SkuNameEnum = "Standalone" + SkuNameEnumStandard SkuNameEnum = "Standard" +) + +func PossibleValuesForSkuNameEnum() []string { + return []string{ + string(SkuNameEnumCapacityReservation), + string(SkuNameEnumFree), + string(SkuNameEnumPerGBTwoZeroOneEight), + string(SkuNameEnumPerNode), + string(SkuNameEnumPremium), + string(SkuNameEnumStandalone), + string(SkuNameEnumStandard), + } +} + +func (s *SkuNameEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuNameEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuNameEnum(input string) (*SkuNameEnum, error) { + vals := map[string]SkuNameEnum{ + "capacityreservation": SkuNameEnumCapacityReservation, + "free": SkuNameEnumFree, + "pergb2018": SkuNameEnumPerGBTwoZeroOneEight, + "pernode": SkuNameEnumPerNode, + "premium": SkuNameEnumPremium, + "standalone": SkuNameEnumStandalone, + "standard": SkuNameEnumStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuNameEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go new file mode 100644 index 00000000000..4600980eb71 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace.go @@ -0,0 +1,130 @@ +package availableservicetiers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go new file mode 100644 index 00000000000..34b0b9e1f18 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/id_workspace_test.go @@ -0,0 +1,282 @@ +package availableservicetiers + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go new file mode 100644 index 00000000000..431f2b6767c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package availableservicetiers + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableServiceTier +} + +// ListByWorkspace ... +func (c AvailableServiceTiersClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availableServiceTiers", 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 + } + + var model []AvailableServiceTier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go new file mode 100644 index 00000000000..b41b7f9b19a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/model_availableservicetier.go @@ -0,0 +1,14 @@ +package availableservicetiers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableServiceTier struct { + CapacityReservationLevel *int64 `json:"capacityReservationLevel,omitempty"` + DefaultRetention *int64 `json:"defaultRetention,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` + MaximumRetention *int64 `json:"maximumRetention,omitempty"` + MinimumRetention *int64 `json:"minimumRetention,omitempty"` + ServiceTier *SkuNameEnum `json:"serviceTier,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go new file mode 100644 index 00000000000..652caae04e9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/availableservicetiers/version.go @@ -0,0 +1,10 @@ +package availableservicetiers + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/availableservicetiers/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/client.go b/resource-manager/operationalinsights/2023-09-01/client.go index f32d4eeb2bf..b98bb5ea557 100644 --- a/resource-manager/operationalinsights/2023-09-01/client.go +++ b/resource-manager/operationalinsights/2023-09-01/client.go @@ -6,24 +6,120 @@ package v2023_09_01 import ( "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/availableservicetiers" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/dataexport" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/datasources" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/deletedworkspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/intelligencepacks" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypackqueries" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/savedsearches" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/storageinsights" + "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/tables" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/workspaces" "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { - DeletedWorkspaces *deletedworkspaces.DeletedWorkspacesClient - Workspaces *workspaces.WorkspacesClient + AvailableServiceTiers *availableservicetiers.AvailableServiceTiersClient + Clusters *clusters.ClustersClient + DataExport *dataexport.DataExportClient + DataSources *datasources.DataSourcesClient + DeletedWorkspaces *deletedworkspaces.DeletedWorkspacesClient + IntelligencePacks *intelligencepacks.IntelligencePacksClient + LinkedServices *linkedservices.LinkedServicesClient + LinkedStorageAccounts *linkedstorageaccounts.LinkedStorageAccountsClient + QueryPackQueries *querypackqueries.QueryPackQueriesClient + QueryPacks *querypacks.QueryPacksClient + SavedSearches *savedsearches.SavedSearchesClient + StorageInsights *storageinsights.StorageInsightsClient + Tables *tables.TablesClient + Workspaces *workspaces.WorkspacesClient } func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + availableServiceTiersClient, err := availableservicetiers.NewAvailableServiceTiersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailableServiceTiers client: %+v", err) + } + configureFunc(availableServiceTiersClient.Client) + + clustersClient, err := clusters.NewClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Clusters client: %+v", err) + } + configureFunc(clustersClient.Client) + + dataExportClient, err := dataexport.NewDataExportClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataExport client: %+v", err) + } + configureFunc(dataExportClient.Client) + + dataSourcesClient, err := datasources.NewDataSourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataSources client: %+v", err) + } + configureFunc(dataSourcesClient.Client) + deletedWorkspacesClient, err := deletedworkspaces.NewDeletedWorkspacesClientWithBaseURI(sdkApi) if err != nil { return nil, fmt.Errorf("building DeletedWorkspaces client: %+v", err) } configureFunc(deletedWorkspacesClient.Client) + intelligencePacksClient, err := intelligencepacks.NewIntelligencePacksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building IntelligencePacks client: %+v", err) + } + configureFunc(intelligencePacksClient.Client) + + linkedServicesClient, err := linkedservices.NewLinkedServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LinkedServices client: %+v", err) + } + configureFunc(linkedServicesClient.Client) + + linkedStorageAccountsClient, err := linkedstorageaccounts.NewLinkedStorageAccountsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LinkedStorageAccounts client: %+v", err) + } + configureFunc(linkedStorageAccountsClient.Client) + + queryPackQueriesClient, err := querypackqueries.NewQueryPackQueriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryPackQueries client: %+v", err) + } + configureFunc(queryPackQueriesClient.Client) + + queryPacksClient, err := querypacks.NewQueryPacksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryPacks client: %+v", err) + } + configureFunc(queryPacksClient.Client) + + savedSearchesClient, err := savedsearches.NewSavedSearchesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SavedSearches client: %+v", err) + } + configureFunc(savedSearchesClient.Client) + + storageInsightsClient, err := storageinsights.NewStorageInsightsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StorageInsights client: %+v", err) + } + configureFunc(storageInsightsClient.Client) + + tablesClient, err := tables.NewTablesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Tables client: %+v", err) + } + configureFunc(tablesClient.Client) + workspacesClient, err := workspaces.NewWorkspacesClientWithBaseURI(sdkApi) if err != nil { return nil, fmt.Errorf("building Workspaces client: %+v", err) @@ -31,7 +127,19 @@ func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanag configureFunc(workspacesClient.Client) return &Client{ - DeletedWorkspaces: deletedWorkspacesClient, - Workspaces: workspacesClient, + AvailableServiceTiers: availableServiceTiersClient, + Clusters: clustersClient, + DataExport: dataExportClient, + DataSources: dataSourcesClient, + DeletedWorkspaces: deletedWorkspacesClient, + IntelligencePacks: intelligencePacksClient, + LinkedServices: linkedServicesClient, + LinkedStorageAccounts: linkedStorageAccountsClient, + QueryPackQueries: queryPackQueriesClient, + QueryPacks: queryPacksClient, + SavedSearches: savedSearchesClient, + StorageInsights: storageInsightsClient, + Tables: tablesClient, + Workspaces: workspacesClient, }, nil } diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/README.md b/resource-manager/operationalinsights/2023-09-01/clusters/README.md new file mode 100644 index 00000000000..80011c33cb9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters` Documentation + +The `clusters` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/clusters" +``` + + +### Client Initialization + +```go +client := clusters.NewClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.Cluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Delete` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Get` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +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: `ClustersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `ClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.Update` + +```go +ctx := context.TODO() +id := clusters.NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.ClusterPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/client.go b/resource-manager/operationalinsights/2023-09-01/clusters/client.go new file mode 100644 index 00000000000..4ead092b486 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/client.go @@ -0,0 +1,26 @@ +package clusters + +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 ClustersClient struct { + Client *resourcemanager.Client +} + +func NewClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClustersClient: %+v", err) + } + + return &ClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/constants.go b/resource-manager/operationalinsights/2023-09-01/clusters/constants.go new file mode 100644 index 00000000000..8cc74416a55 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/constants.go @@ -0,0 +1,177 @@ +package clusters + +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 BillingType string + +const ( + BillingTypeCluster BillingType = "Cluster" + BillingTypeWorkspaces BillingType = "Workspaces" +) + +func PossibleValuesForBillingType() []string { + return []string{ + string(BillingTypeCluster), + string(BillingTypeWorkspaces), + } +} + +func (s *BillingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingType(input string) (*BillingType, error) { + vals := map[string]BillingType{ + "cluster": BillingTypeCluster, + "workspaces": BillingTypeWorkspaces, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingType(input) + return &out, nil +} + +type Capacity int64 + +const ( + CapacityFiveHundred Capacity = 500 + CapacityFiveThousand Capacity = 5000 + CapacityFiveZeroThousand Capacity = 50000 + CapacityFourHundred Capacity = 400 + CapacityOneHundred Capacity = 100 + CapacityOneThousand Capacity = 1000 + CapacityOneZeroThousand Capacity = 10000 + CapacityThreeHundred Capacity = 300 + CapacityTwoFiveThousand Capacity = 25000 + CapacityTwoHundred Capacity = 200 + CapacityTwoThousand Capacity = 2000 +) + +func PossibleValuesForCapacity() []int64 { + return []int64{ + int64(CapacityFiveHundred), + int64(CapacityFiveThousand), + int64(CapacityFiveZeroThousand), + int64(CapacityFourHundred), + int64(CapacityOneHundred), + int64(CapacityOneThousand), + int64(CapacityOneZeroThousand), + int64(CapacityThreeHundred), + int64(CapacityTwoFiveThousand), + int64(CapacityTwoHundred), + int64(CapacityTwoThousand), + } +} + +type ClusterEntityStatus string + +const ( + ClusterEntityStatusCanceled ClusterEntityStatus = "Canceled" + ClusterEntityStatusCreating ClusterEntityStatus = "Creating" + ClusterEntityStatusDeleting ClusterEntityStatus = "Deleting" + ClusterEntityStatusFailed ClusterEntityStatus = "Failed" + ClusterEntityStatusProvisioningAccount ClusterEntityStatus = "ProvisioningAccount" + ClusterEntityStatusSucceeded ClusterEntityStatus = "Succeeded" + ClusterEntityStatusUpdating ClusterEntityStatus = "Updating" +) + +func PossibleValuesForClusterEntityStatus() []string { + return []string{ + string(ClusterEntityStatusCanceled), + string(ClusterEntityStatusCreating), + string(ClusterEntityStatusDeleting), + string(ClusterEntityStatusFailed), + string(ClusterEntityStatusProvisioningAccount), + string(ClusterEntityStatusSucceeded), + string(ClusterEntityStatusUpdating), + } +} + +func (s *ClusterEntityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterEntityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterEntityStatus(input string) (*ClusterEntityStatus, error) { + vals := map[string]ClusterEntityStatus{ + "canceled": ClusterEntityStatusCanceled, + "creating": ClusterEntityStatusCreating, + "deleting": ClusterEntityStatusDeleting, + "failed": ClusterEntityStatusFailed, + "provisioningaccount": ClusterEntityStatusProvisioningAccount, + "succeeded": ClusterEntityStatusSucceeded, + "updating": ClusterEntityStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterEntityStatus(input) + return &out, nil +} + +type ClusterSkuNameEnum string + +const ( + ClusterSkuNameEnumCapacityReservation ClusterSkuNameEnum = "CapacityReservation" +) + +func PossibleValuesForClusterSkuNameEnum() []string { + return []string{ + string(ClusterSkuNameEnumCapacityReservation), + } +} + +func (s *ClusterSkuNameEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterSkuNameEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterSkuNameEnum(input string) (*ClusterSkuNameEnum, error) { + vals := map[string]ClusterSkuNameEnum{ + "capacityreservation": ClusterSkuNameEnumCapacityReservation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterSkuNameEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go new file mode 100644 index 00000000000..0bb42eab67c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster.go @@ -0,0 +1,130 @@ +package clusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ClusterId{}) +} + +var _ resourceids.ResourceId = &ClusterId{} + +// ClusterId is a struct representing the Resource ID for a Cluster +type ClusterId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string +} + +// NewClusterID returns a new ClusterId struct +func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { + return ClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + } +} + +// ParseClusterID parses 'input' into a ClusterId +func ParseClusterID(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId +// note: this method should only be used for API response data and not user input +func ParseClusterIDInsensitively(input string) (*ClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClusterId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + return nil +} + +// ValidateClusterID checks that 'input' can be parsed as a Cluster ID +func ValidateClusterID(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 := ParseClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cluster ID +func (id ClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/clusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cluster ID +func (id ClusterId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + } +} + +// String returns a human-readable description of this Cluster ID +func (id ClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + } + return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go new file mode 100644 index 00000000000..c450b8197c7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/id_cluster_test.go @@ -0,0 +1,282 @@ +package clusters + +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 = &ClusterId{} + +func TestNewClusterID(t *testing.T) { + id := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } +} + +func TestFormatClusterID(t *testing.T) { + actual := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestParseClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClusterId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/cLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/clusters/clusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/cLuStErS/cLuStErNaMe", + Expected: &ClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/cLuStErS/cLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClusterIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + } +} + +func TestSegmentsForClusterId(t *testing.T) { + segments := ClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ClusterId 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/operationalinsights/2023-09-01/clusters/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go new file mode 100644 index 00000000000..92394c4deb4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_createorupdate.go @@ -0,0 +1,76 @@ +package clusters + +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 + Model *Cluster +} + +// CreateOrUpdate ... +func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster) 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/operationalinsights/2023-09-01/clusters/method_delete.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go new file mode 100644 index 00000000000..13e2610ffd6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_delete.go @@ -0,0 +1,71 @@ +package clusters + +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 ClustersClient) Delete(ctx context.Context, id ClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ClustersClient) DeleteThenPoll(ctx context.Context, id ClusterId) 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/operationalinsights/2023-09-01/clusters/method_get.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_get.go new file mode 100644 index 00000000000..8265f74e863 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_get.go @@ -0,0 +1,53 @@ +package clusters + +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 *Cluster +} + +// Get ... +func (c ClustersClient) Get(ctx context.Context, id ClusterId) (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 + } + + var model Cluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go new file mode 100644 index 00000000000..84041722337 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_list.go @@ -0,0 +1,106 @@ +package clusters + +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 *[]Cluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", 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 *[]Cluster `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 ClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..2bd22023e91 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package clusters + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cluster +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/clusters", 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 *[]Cluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Cluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go b/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go new file mode 100644 index 00000000000..f11774e7c12 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/method_update.go @@ -0,0 +1,74 @@ +package clusters + +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 + Model *Cluster +} + +// Update ... +func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) 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/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go new file mode 100644 index 00000000000..ad5986522e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_associatedworkspace.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssociatedWorkspace struct { + AssociateDate *string `json:"associateDate,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceName *string `json:"workspaceName,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go new file mode 100644 index 00000000000..2e65bfb192f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_capacityreservationproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapacityReservationProperties struct { + LastSkuUpdate *string `json:"lastSkuUpdate,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go new file mode 100644 index 00000000000..be303015217 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_cluster.go @@ -0,0 +1,19 @@ +package clusters + +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 Cluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ClusterProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go new file mode 100644 index 00000000000..9524c09d0bc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatch.go @@ -0,0 +1,15 @@ +package clusters + +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 ClusterPatch struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *ClusterPatchProperties `json:"properties,omitempty"` + Sku *ClusterSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go new file mode 100644 index 00000000000..7960ea89b28 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterpatchproperties.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPatchProperties struct { + BillingType *BillingType `json:"billingType,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go new file mode 100644 index 00000000000..36f519cd0d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clusterproperties.go @@ -0,0 +1,17 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterProperties struct { + AssociatedWorkspaces *[]AssociatedWorkspace `json:"associatedWorkspaces,omitempty"` + BillingType *BillingType `json:"billingType,omitempty"` + CapacityReservationProperties *CapacityReservationProperties `json:"capacityReservationProperties,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + CreatedDate *string `json:"createdDate,omitempty"` + IsAvailabilityZonesEnabled *bool `json:"isAvailabilityZonesEnabled,omitempty"` + IsDoubleEncryptionEnabled *bool `json:"isDoubleEncryptionEnabled,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` + ProvisioningState *ClusterEntityStatus `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go new file mode 100644 index 00000000000..6f279c158d7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_clustersku.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterSku struct { + Capacity *Capacity `json:"capacity,omitempty"` + Name *ClusterSkuNameEnum `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go b/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go new file mode 100644 index 00000000000..b2cfa77b7d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName *string `json:"keyName,omitempty"` + KeyRsaSize *int64 `json:"keyRsaSize,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go b/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go new file mode 100644 index 00000000000..cc13b7c6220 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/predicates.go @@ -0,0 +1,32 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ClusterOperationPredicate) Matches(input Cluster) 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/operationalinsights/2023-09-01/clusters/version.go b/resource-manager/operationalinsights/2023-09-01/clusters/version.go new file mode 100644 index 00000000000..322b9e7b925 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/clusters/version.go @@ -0,0 +1,10 @@ +package clusters + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusters/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/README.md b/resource-manager/operationalinsights/2023-09-01/dataexport/README.md new file mode 100644 index 00000000000..58b96ca43e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/dataexport` Documentation + +The `dataexport` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/dataexport" +``` + + +### Client Initialization + +```go +client := dataexport.NewDataExportClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataExportClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +payload := dataexport.DataExport{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataExportClient.Delete` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataExportClient.Get` + +```go +ctx := context.TODO() +id := dataexport.NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + +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: `DataExportClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := dataexport.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/client.go b/resource-manager/operationalinsights/2023-09-01/dataexport/client.go new file mode 100644 index 00000000000..5113e66d9c0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/client.go @@ -0,0 +1,26 @@ +package dataexport + +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 DataExportClient struct { + Client *resourcemanager.Client +} + +func NewDataExportClientWithBaseURI(sdkApi sdkEnv.Api) (*DataExportClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dataexport", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataExportClient: %+v", err) + } + + return &DataExportClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go b/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go new file mode 100644 index 00000000000..c103dc9f1ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/constants.go @@ -0,0 +1,51 @@ +package dataexport + +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 Type string + +const ( + TypeEventHub Type = "EventHub" + TypeStorageAccount Type = "StorageAccount" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeEventHub), + string(TypeStorageAccount), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "eventhub": TypeEventHub, + "storageaccount": TypeStorageAccount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go new file mode 100644 index 00000000000..a8de549cff8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport.go @@ -0,0 +1,139 @@ +package dataexport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DataExportId{}) +} + +var _ resourceids.ResourceId = &DataExportId{} + +// DataExportId is a struct representing the Resource ID for a Data Export +type DataExportId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataExportName string +} + +// NewDataExportID returns a new DataExportId struct +func NewDataExportID(subscriptionId string, resourceGroupName string, workspaceName string, dataExportName string) DataExportId { + return DataExportId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataExportName: dataExportName, + } +} + +// ParseDataExportID parses 'input' into a DataExportId +func ParseDataExportID(input string) (*DataExportId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataExportId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataExportId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataExportIDInsensitively parses 'input' case-insensitively into a DataExportId +// note: this method should only be used for API response data and not user input +func ParseDataExportIDInsensitively(input string) (*DataExportId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataExportId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataExportId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataExportId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataExportName, ok = input.Parsed["dataExportName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataExportName", input) + } + + return nil +} + +// ValidateDataExportID checks that 'input' can be parsed as a Data Export ID +func ValidateDataExportID(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 := ParseDataExportID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Export ID +func (id DataExportId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataExports/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataExportName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Export ID +func (id DataExportId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticDataExports", "dataExports", "dataExports"), + resourceids.UserSpecifiedSegment("dataExportName", "dataExportName"), + } +} + +// String returns a human-readable description of this Data Export ID +func (id DataExportId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Export Name: %q", id.DataExportName), + } + return fmt.Sprintf("Data Export (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go new file mode 100644 index 00000000000..d88423d09bc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_dataexport_test.go @@ -0,0 +1,327 @@ +package dataexport + +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 = &DataExportId{} + +func TestNewDataExportID(t *testing.T) { + id := NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataExportName != "dataExportName" { + t.Fatalf("Expected %q but got %q for Segment 'DataExportName'", id.DataExportName, "dataExportName") + } +} + +func TestFormatDataExportID(t *testing.T) { + actual := NewDataExportID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataExportName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataExportID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataExportId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataExportName: "dataExportName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataExportID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataExportName != v.Expected.DataExportName { + t.Fatalf("Expected %q but got %q for DataExportName", v.Expected.DataExportName, actual.DataExportName) + } + + } +} + +func TestParseDataExportIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataExportId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataExportName: "dataExportName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataExports/dataExportName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs/dAtAeXpOrTnAmE", + Expected: &DataExportId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataExportName: "dAtAeXpOrTnAmE", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAeXpOrTs/dAtAeXpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataExportIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataExportName != v.Expected.DataExportName { + t.Fatalf("Expected %q but got %q for DataExportName", v.Expected.DataExportName, actual.DataExportName) + } + + } +} + +func TestSegmentsForDataExportId(t *testing.T) { + segments := DataExportId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataExportId 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/operationalinsights/2023-09-01/dataexport/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go new file mode 100644 index 00000000000..c2506a768f9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace.go @@ -0,0 +1,130 @@ +package dataexport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go new file mode 100644 index 00000000000..5373c883c57 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/id_workspace_test.go @@ -0,0 +1,282 @@ +package dataexport + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/dataexport/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go new file mode 100644 index 00000000000..6715bd687d9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_createorupdate.go @@ -0,0 +1,58 @@ +package dataexport + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataExport +} + +// CreateOrUpdate ... +func (c DataExportClient) CreateOrUpdate(ctx context.Context, id DataExportId, input DataExport) (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 + } + + var model DataExport + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go new file mode 100644 index 00000000000..0955b9b73ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_delete.go @@ -0,0 +1,46 @@ +package dataexport + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DataExportClient) Delete(ctx context.Context, id DataExportId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go new file mode 100644 index 00000000000..31181e61127 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_get.go @@ -0,0 +1,53 @@ +package dataexport + +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 *DataExport +} + +// Get ... +func (c DataExportClient) Get(ctx context.Context, id DataExportId) (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 + } + + var model DataExport + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go new file mode 100644 index 00000000000..aa783d2a041 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package dataexport + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataExportListResult +} + +// ListByWorkspace ... +func (c DataExportClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataExports", 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 + } + + var model DataExportListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go new file mode 100644 index 00000000000..b7f7ca1ec04 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexport.go @@ -0,0 +1,11 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExport struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DataExportProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go new file mode 100644 index 00000000000..0944681ef9d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportlistresult.go @@ -0,0 +1,8 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExportListResult struct { + Value *[]DataExport `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go new file mode 100644 index 00000000000..f3677b9395d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_dataexportproperties.go @@ -0,0 +1,13 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataExportProperties struct { + CreatedDate *string `json:"createdDate,omitempty"` + DataExportId *string `json:"dataExportId,omitempty"` + Destination *Destination `json:"destination,omitempty"` + Enable *bool `json:"enable,omitempty"` + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` + TableNames []string `json:"tableNames"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go new file mode 100644 index 00000000000..534e7081b71 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destination.go @@ -0,0 +1,10 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Destination struct { + MetaData *DestinationMetaData `json:"metaData,omitempty"` + ResourceId string `json:"resourceId"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go new file mode 100644 index 00000000000..abf5e37918e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/model_destinationmetadata.go @@ -0,0 +1,8 @@ +package dataexport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationMetaData struct { + EventHubName *string `json:"eventHubName,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/dataexport/version.go b/resource-manager/operationalinsights/2023-09-01/dataexport/version.go new file mode 100644 index 00000000000..0b8284c7976 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/dataexport/version.go @@ -0,0 +1,10 @@ +package dataexport + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dataexport/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/README.md b/resource-manager/operationalinsights/2023-09-01/datasources/README.md new file mode 100644 index 00000000000..a0f1ce4ccaf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/datasources` Documentation + +The `datasources` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/datasources" +``` + + +### Client Initialization + +```go +client := datasources.NewDataSourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataSourcesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +payload := datasources.DataSource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataSourcesClient.Delete` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataSourcesClient.Get` + +```go +ctx := context.TODO() +id := datasources.NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + +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: `DataSourcesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := datasources.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.ListByWorkspace(ctx, id, datasources.DefaultListByWorkspaceOperationOptions())` can be used to do batched pagination +items, err := client.ListByWorkspaceComplete(ctx, id, datasources.DefaultListByWorkspaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/client.go b/resource-manager/operationalinsights/2023-09-01/datasources/client.go new file mode 100644 index 00000000000..ab9ec31dddc --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/client.go @@ -0,0 +1,26 @@ +package datasources + +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 DataSourcesClient struct { + Client *resourcemanager.Client +} + +func NewDataSourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*DataSourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datasources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataSourcesClient: %+v", err) + } + + return &DataSourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/constants.go b/resource-manager/operationalinsights/2023-09-01/datasources/constants.go new file mode 100644 index 00000000000..91241eeca9f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/constants.go @@ -0,0 +1,144 @@ +package datasources + +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 DataSourceKind string + +const ( + DataSourceKindApplicationInsights DataSourceKind = "ApplicationInsights" + DataSourceKindAzureActivityLog DataSourceKind = "AzureActivityLog" + DataSourceKindAzureAuditLog DataSourceKind = "AzureAuditLog" + DataSourceKindChangeTrackingContentLocation DataSourceKind = "ChangeTrackingContentLocation" + DataSourceKindChangeTrackingCustomPath DataSourceKind = "ChangeTrackingCustomPath" + DataSourceKindChangeTrackingDataTypeConfiguration DataSourceKind = "ChangeTrackingDataTypeConfiguration" + DataSourceKindChangeTrackingDefaultRegistry DataSourceKind = "ChangeTrackingDefaultRegistry" + DataSourceKindChangeTrackingLinuxPath DataSourceKind = "ChangeTrackingLinuxPath" + DataSourceKindChangeTrackingPath DataSourceKind = "ChangeTrackingPath" + DataSourceKindChangeTrackingRegistry DataSourceKind = "ChangeTrackingRegistry" + DataSourceKindChangeTrackingServices DataSourceKind = "ChangeTrackingServices" + DataSourceKindCustomLog DataSourceKind = "CustomLog" + DataSourceKindCustomLogCollection DataSourceKind = "CustomLogCollection" + DataSourceKindDnsAnalytics DataSourceKind = "DnsAnalytics" + DataSourceKindGenericDataSource DataSourceKind = "GenericDataSource" + DataSourceKindIISLogs DataSourceKind = "IISLogs" + DataSourceKindImportComputerGroup DataSourceKind = "ImportComputerGroup" + DataSourceKindItsm DataSourceKind = "Itsm" + DataSourceKindLinuxChangeTrackingPath DataSourceKind = "LinuxChangeTrackingPath" + DataSourceKindLinuxPerformanceCollection DataSourceKind = "LinuxPerformanceCollection" + DataSourceKindLinuxPerformanceObject DataSourceKind = "LinuxPerformanceObject" + DataSourceKindLinuxSyslog DataSourceKind = "LinuxSyslog" + DataSourceKindLinuxSyslogCollection DataSourceKind = "LinuxSyslogCollection" + DataSourceKindNetworkMonitoring DataSourceKind = "NetworkMonitoring" + DataSourceKindOfficeThreeSixFive DataSourceKind = "Office365" + DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityCenterSecurityWindowsBaselineConfiguration" + DataSourceKindSecurityEventCollectionConfiguration DataSourceKind = "SecurityEventCollectionConfiguration" + DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration DataSourceKind = "SecurityInsightsSecurityEventCollectionConfiguration" + DataSourceKindSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityWindowsBaselineConfiguration" + DataSourceKindSqlDataClassification DataSourceKind = "SqlDataClassification" + DataSourceKindWindowsEvent DataSourceKind = "WindowsEvent" + DataSourceKindWindowsPerformanceCounter DataSourceKind = "WindowsPerformanceCounter" + DataSourceKindWindowsTelemetry DataSourceKind = "WindowsTelemetry" +) + +func PossibleValuesForDataSourceKind() []string { + return []string{ + string(DataSourceKindApplicationInsights), + string(DataSourceKindAzureActivityLog), + string(DataSourceKindAzureAuditLog), + string(DataSourceKindChangeTrackingContentLocation), + string(DataSourceKindChangeTrackingCustomPath), + string(DataSourceKindChangeTrackingDataTypeConfiguration), + string(DataSourceKindChangeTrackingDefaultRegistry), + string(DataSourceKindChangeTrackingLinuxPath), + string(DataSourceKindChangeTrackingPath), + string(DataSourceKindChangeTrackingRegistry), + string(DataSourceKindChangeTrackingServices), + string(DataSourceKindCustomLog), + string(DataSourceKindCustomLogCollection), + string(DataSourceKindDnsAnalytics), + string(DataSourceKindGenericDataSource), + string(DataSourceKindIISLogs), + string(DataSourceKindImportComputerGroup), + string(DataSourceKindItsm), + string(DataSourceKindLinuxChangeTrackingPath), + string(DataSourceKindLinuxPerformanceCollection), + string(DataSourceKindLinuxPerformanceObject), + string(DataSourceKindLinuxSyslog), + string(DataSourceKindLinuxSyslogCollection), + string(DataSourceKindNetworkMonitoring), + string(DataSourceKindOfficeThreeSixFive), + string(DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration), + string(DataSourceKindSecurityEventCollectionConfiguration), + string(DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration), + string(DataSourceKindSecurityWindowsBaselineConfiguration), + string(DataSourceKindSqlDataClassification), + string(DataSourceKindWindowsEvent), + string(DataSourceKindWindowsPerformanceCounter), + string(DataSourceKindWindowsTelemetry), + } +} + +func (s *DataSourceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSourceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSourceKind(input string) (*DataSourceKind, error) { + vals := map[string]DataSourceKind{ + "applicationinsights": DataSourceKindApplicationInsights, + "azureactivitylog": DataSourceKindAzureActivityLog, + "azureauditlog": DataSourceKindAzureAuditLog, + "changetrackingcontentlocation": DataSourceKindChangeTrackingContentLocation, + "changetrackingcustompath": DataSourceKindChangeTrackingCustomPath, + "changetrackingdatatypeconfiguration": DataSourceKindChangeTrackingDataTypeConfiguration, + "changetrackingdefaultregistry": DataSourceKindChangeTrackingDefaultRegistry, + "changetrackinglinuxpath": DataSourceKindChangeTrackingLinuxPath, + "changetrackingpath": DataSourceKindChangeTrackingPath, + "changetrackingregistry": DataSourceKindChangeTrackingRegistry, + "changetrackingservices": DataSourceKindChangeTrackingServices, + "customlog": DataSourceKindCustomLog, + "customlogcollection": DataSourceKindCustomLogCollection, + "dnsanalytics": DataSourceKindDnsAnalytics, + "genericdatasource": DataSourceKindGenericDataSource, + "iislogs": DataSourceKindIISLogs, + "importcomputergroup": DataSourceKindImportComputerGroup, + "itsm": DataSourceKindItsm, + "linuxchangetrackingpath": DataSourceKindLinuxChangeTrackingPath, + "linuxperformancecollection": DataSourceKindLinuxPerformanceCollection, + "linuxperformanceobject": DataSourceKindLinuxPerformanceObject, + "linuxsyslog": DataSourceKindLinuxSyslog, + "linuxsyslogcollection": DataSourceKindLinuxSyslogCollection, + "networkmonitoring": DataSourceKindNetworkMonitoring, + "office365": DataSourceKindOfficeThreeSixFive, + "securitycentersecuritywindowsbaselineconfiguration": DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration, + "securityeventcollectionconfiguration": DataSourceKindSecurityEventCollectionConfiguration, + "securityinsightssecurityeventcollectionconfiguration": DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration, + "securitywindowsbaselineconfiguration": DataSourceKindSecurityWindowsBaselineConfiguration, + "sqldataclassification": DataSourceKindSqlDataClassification, + "windowsevent": DataSourceKindWindowsEvent, + "windowsperformancecounter": DataSourceKindWindowsPerformanceCounter, + "windowstelemetry": DataSourceKindWindowsTelemetry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceKind(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go new file mode 100644 index 00000000000..2a95ddb8e6c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource.go @@ -0,0 +1,139 @@ +package datasources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DataSourceId{}) +} + +var _ resourceids.ResourceId = &DataSourceId{} + +// DataSourceId is a struct representing the Resource ID for a Data Source +type DataSourceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataSourceName string +} + +// NewDataSourceID returns a new DataSourceId struct +func NewDataSourceID(subscriptionId string, resourceGroupName string, workspaceName string, dataSourceName string) DataSourceId { + return DataSourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataSourceName: dataSourceName, + } +} + +// ParseDataSourceID parses 'input' into a DataSourceId +func ParseDataSourceID(input string) (*DataSourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataSourceIDInsensitively parses 'input' case-insensitively into a DataSourceId +// note: this method should only be used for API response data and not user input +func ParseDataSourceIDInsensitively(input string) (*DataSourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataSourceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataSourceName, ok = input.Parsed["dataSourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataSourceName", input) + } + + return nil +} + +// ValidateDataSourceID checks that 'input' can be parsed as a Data Source ID +func ValidateDataSourceID(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 := ParseDataSourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Source ID +func (id DataSourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/dataSources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataSourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Source ID +func (id DataSourceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticDataSources", "dataSources", "dataSources"), + resourceids.UserSpecifiedSegment("dataSourceName", "dataSourceName"), + } +} + +// String returns a human-readable description of this Data Source ID +func (id DataSourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Source Name: %q", id.DataSourceName), + } + return fmt.Sprintf("Data Source (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go new file mode 100644 index 00000000000..13a6a7a7e0c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_datasource_test.go @@ -0,0 +1,327 @@ +package datasources + +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 = &DataSourceId{} + +func TestNewDataSourceID(t *testing.T) { + id := NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataSourceName != "dataSourceName" { + t.Fatalf("Expected %q but got %q for Segment 'DataSourceName'", id.DataSourceName, "dataSourceName") + } +} + +func TestFormatDataSourceID(t *testing.T) { + actual := NewDataSourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataSourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataSourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceName: "dataSourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceName != v.Expected.DataSourceName { + t.Fatalf("Expected %q but got %q for DataSourceName", v.Expected.DataSourceName, actual.DataSourceName) + } + + } +} + +func TestParseDataSourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceName: "dataSourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/dataSources/dataSourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs/dAtAsOuRcEnAmE", + Expected: &DataSourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataSourceName: "dAtAsOuRcEnAmE", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsOuRcEs/dAtAsOuRcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceName != v.Expected.DataSourceName { + t.Fatalf("Expected %q but got %q for DataSourceName", v.Expected.DataSourceName, actual.DataSourceName) + } + + } +} + +func TestSegmentsForDataSourceId(t *testing.T) { + segments := DataSourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataSourceId 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/operationalinsights/2023-09-01/datasources/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go new file mode 100644 index 00000000000..5325c571db5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace.go @@ -0,0 +1,130 @@ +package datasources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go new file mode 100644 index 00000000000..a4e30459ef1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/id_workspace_test.go @@ -0,0 +1,282 @@ +package datasources + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/datasources/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go new file mode 100644 index 00000000000..0f409fcbaab --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_createorupdate.go @@ -0,0 +1,58 @@ +package datasources + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataSource +} + +// CreateOrUpdate ... +func (c DataSourcesClient) CreateOrUpdate(ctx context.Context, id DataSourceId, input DataSource) (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 + } + + var model DataSource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go new file mode 100644 index 00000000000..e997877cfd3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_delete.go @@ -0,0 +1,47 @@ +package datasources + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DataSourcesClient) Delete(ctx context.Context, id DataSourceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go new file mode 100644 index 00000000000..388310f131e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_get.go @@ -0,0 +1,53 @@ +package datasources + +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 *DataSource +} + +// Get ... +func (c DataSourcesClient) Get(ctx context.Context, id DataSourceId) (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 + } + + var model DataSource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go new file mode 100644 index 00000000000..909910b2332 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/method_listbyworkspace.go @@ -0,0 +1,134 @@ +package datasources + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataSource +} + +type ListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataSource +} + +type ListByWorkspaceOperationOptions struct { + Filter *string +} + +func DefaultListByWorkspaceOperationOptions() ListByWorkspaceOperationOptions { + return ListByWorkspaceOperationOptions{} +} + +func (o ListByWorkspaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByWorkspaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByWorkspaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByWorkspace ... +func (c DataSourcesClient) ListByWorkspace(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByWorkspaceCustomPager{}, + Path: fmt.Sprintf("%s/dataSources", 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 *[]DataSource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByWorkspaceComplete retrieves all the results into a single object +func (c DataSourcesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, options, DataSourceOperationPredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataSourcesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListByWorkspaceOperationOptions, predicate DataSourceOperationPredicate) (result ListByWorkspaceCompleteResult, err error) { + items := make([]DataSource, 0) + + resp, err := c.ListByWorkspace(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go b/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go new file mode 100644 index 00000000000..e091f526268 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/model_datasource.go @@ -0,0 +1,14 @@ +package datasources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind DataSourceKind `json:"kind"` + Name *string `json:"name,omitempty"` + Properties interface{} `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go b/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go new file mode 100644 index 00000000000..1fa7b8ec8d5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/predicates.go @@ -0,0 +1,37 @@ +package datasources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSourceOperationPredicate struct { + Etag *string + Id *string + Name *string + Properties *interface{} + Type *string +} + +func (p DataSourceOperationPredicate) Matches(input DataSource) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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.Properties != nil && *p.Properties != input.Properties { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/operationalinsights/2023-09-01/datasources/version.go b/resource-manager/operationalinsights/2023-09-01/datasources/version.go new file mode 100644 index 00000000000..c840691a378 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/datasources/version.go @@ -0,0 +1,10 @@ +package datasources + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datasources/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md new file mode 100644 index 00000000000..7cf1c62469a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/README.md @@ -0,0 +1,68 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/intelligencepacks` Documentation + +The `intelligencepacks` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/intelligencepacks" +``` + + +### Client Initialization + +```go +client := intelligencepacks.NewIntelligencePacksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `IntelligencePacksClient.Disable` + +```go +ctx := context.TODO() +id := intelligencepacks.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.Disable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IntelligencePacksClient.Enable` + +```go +ctx := context.TODO() +id := intelligencepacks.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.Enable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IntelligencePacksClient.List` + +```go +ctx := context.TODO() +id := intelligencepacks.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go new file mode 100644 index 00000000000..518c60eaae5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/client.go @@ -0,0 +1,26 @@ +package intelligencepacks + +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 IntelligencePacksClient struct { + Client *resourcemanager.Client +} + +func NewIntelligencePacksClientWithBaseURI(sdkApi sdkEnv.Api) (*IntelligencePacksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "intelligencepacks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IntelligencePacksClient: %+v", err) + } + + return &IntelligencePacksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go new file mode 100644 index 00000000000..ee98a42386d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack.go @@ -0,0 +1,139 @@ +package intelligencepacks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&IntelligencePackId{}) +} + +var _ resourceids.ResourceId = &IntelligencePackId{} + +// IntelligencePackId is a struct representing the Resource ID for a Intelligence Pack +type IntelligencePackId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IntelligencePackName string +} + +// NewIntelligencePackID returns a new IntelligencePackId struct +func NewIntelligencePackID(subscriptionId string, resourceGroupName string, workspaceName string, intelligencePackName string) IntelligencePackId { + return IntelligencePackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IntelligencePackName: intelligencePackName, + } +} + +// ParseIntelligencePackID parses 'input' into a IntelligencePackId +func ParseIntelligencePackID(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIntelligencePackIDInsensitively parses 'input' case-insensitively into a IntelligencePackId +// note: this method should only be used for API response data and not user input +func ParseIntelligencePackIDInsensitively(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IntelligencePackId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.IntelligencePackName, ok = input.Parsed["intelligencePackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "intelligencePackName", input) + } + + return nil +} + +// ValidateIntelligencePackID checks that 'input' can be parsed as a Intelligence Pack ID +func ValidateIntelligencePackID(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 := ParseIntelligencePackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Intelligence Pack ID +func (id IntelligencePackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/intelligencePacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IntelligencePackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Intelligence Pack ID +func (id IntelligencePackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticIntelligencePacks", "intelligencePacks", "intelligencePacks"), + resourceids.UserSpecifiedSegment("intelligencePackName", "intelligencePackName"), + } +} + +// String returns a human-readable description of this Intelligence Pack ID +func (id IntelligencePackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Intelligence Pack Name: %q", id.IntelligencePackName), + } + return fmt.Sprintf("Intelligence Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go new file mode 100644 index 00000000000..032f02668b8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_intelligencepack_test.go @@ -0,0 +1,327 @@ +package intelligencepacks + +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 = &IntelligencePackId{} + +func TestNewIntelligencePackID(t *testing.T) { + id := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.IntelligencePackName != "intelligencePackName" { + t.Fatalf("Expected %q but got %q for Segment 'IntelligencePackName'", id.IntelligencePackName, "intelligencePackName") + } +} + +func TestFormatIntelligencePackID(t *testing.T) { + actual := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIntelligencePackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestParseIntelligencePackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + IntelligencePackName: "iNtElLiGeNcEpAcKnAmE", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestSegmentsForIntelligencePackId(t *testing.T) { + segments := IntelligencePackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IntelligencePackId 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/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go new file mode 100644 index 00000000000..f771f3365e1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace.go @@ -0,0 +1,130 @@ +package intelligencepacks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go new file mode 100644 index 00000000000..d5445b09646 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/id_workspace_test.go @@ -0,0 +1,282 @@ +package intelligencepacks + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/intelligencepacks/method_disable.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go new file mode 100644 index 00000000000..1697c5db1e6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_disable.go @@ -0,0 +1,47 @@ +package intelligencepacks + +import ( + "context" + "fmt" + "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 DisableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Disable ... +func (c IntelligencePacksClient) Disable(ctx context.Context, id IntelligencePackId) (result DisableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go new file mode 100644 index 00000000000..cdae66e4a20 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_enable.go @@ -0,0 +1,47 @@ +package intelligencepacks + +import ( + "context" + "fmt" + "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 EnableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Enable ... +func (c IntelligencePacksClient) Enable(ctx context.Context, id IntelligencePackId) (result EnableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enable", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go new file mode 100644 index 00000000000..935b628393d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/method_list.go @@ -0,0 +1,54 @@ +package intelligencepacks + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IntelligencePack +} + +// List ... +func (c IntelligencePacksClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/intelligencePacks", 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 + } + + var model []IntelligencePack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go new file mode 100644 index 00000000000..258fdc2abbf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/model_intelligencepack.go @@ -0,0 +1,10 @@ +package intelligencepacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IntelligencePack struct { + DisplayName *string `json:"displayName,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go new file mode 100644 index 00000000000..0b39d9ca4e1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/intelligencepacks/version.go @@ -0,0 +1,10 @@ +package intelligencepacks + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/intelligencepacks/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md b/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md new file mode 100644 index 00000000000..1d6f2cc32db --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/README.md @@ -0,0 +1,81 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedservices` Documentation + +The `linkedservices` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/linkedservices" +``` + + +### Client Initialization + +```go +client := linkedservices.NewLinkedServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LinkedServicesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +payload := linkedservices.LinkedService{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LinkedServicesClient.Delete` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LinkedServicesClient.Get` + +```go +ctx := context.TODO() +id := linkedservices.NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + +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: `LinkedServicesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := linkedservices.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go new file mode 100644 index 00000000000..3dad68f5d5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/client.go @@ -0,0 +1,26 @@ +package linkedservices + +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 LinkedServicesClient struct { + Client *resourcemanager.Client +} + +func NewLinkedServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*LinkedServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "linkedservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LinkedServicesClient: %+v", err) + } + + return &LinkedServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go new file mode 100644 index 00000000000..8522d1f6ced --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/constants.go @@ -0,0 +1,57 @@ +package linkedservices + +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 LinkedServiceEntityStatus string + +const ( + LinkedServiceEntityStatusDeleting LinkedServiceEntityStatus = "Deleting" + LinkedServiceEntityStatusProvisioningAccount LinkedServiceEntityStatus = "ProvisioningAccount" + LinkedServiceEntityStatusSucceeded LinkedServiceEntityStatus = "Succeeded" + LinkedServiceEntityStatusUpdating LinkedServiceEntityStatus = "Updating" +) + +func PossibleValuesForLinkedServiceEntityStatus() []string { + return []string{ + string(LinkedServiceEntityStatusDeleting), + string(LinkedServiceEntityStatusProvisioningAccount), + string(LinkedServiceEntityStatusSucceeded), + string(LinkedServiceEntityStatusUpdating), + } +} + +func (s *LinkedServiceEntityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinkedServiceEntityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinkedServiceEntityStatus(input string) (*LinkedServiceEntityStatus, error) { + vals := map[string]LinkedServiceEntityStatus{ + "deleting": LinkedServiceEntityStatusDeleting, + "provisioningaccount": LinkedServiceEntityStatusProvisioningAccount, + "succeeded": LinkedServiceEntityStatusSucceeded, + "updating": LinkedServiceEntityStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinkedServiceEntityStatus(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go new file mode 100644 index 00000000000..a2f3b24e491 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice.go @@ -0,0 +1,139 @@ +package linkedservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LinkedServiceId{}) +} + +var _ resourceids.ResourceId = &LinkedServiceId{} + +// LinkedServiceId is a struct representing the Resource ID for a Linked Service +type LinkedServiceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + LinkedServiceName string +} + +// NewLinkedServiceID returns a new LinkedServiceId struct +func NewLinkedServiceID(subscriptionId string, resourceGroupName string, workspaceName string, linkedServiceName string) LinkedServiceId { + return LinkedServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + LinkedServiceName: linkedServiceName, + } +} + +// ParseLinkedServiceID parses 'input' into a LinkedServiceId +func ParseLinkedServiceID(input string) (*LinkedServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkedServiceIDInsensitively parses 'input' case-insensitively into a LinkedServiceId +// note: this method should only be used for API response data and not user input +func ParseLinkedServiceIDInsensitively(input string) (*LinkedServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkedServiceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.LinkedServiceName, ok = input.Parsed["linkedServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedServiceName", input) + } + + return nil +} + +// ValidateLinkedServiceID checks that 'input' can be parsed as a Linked Service ID +func ValidateLinkedServiceID(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 := ParseLinkedServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Linked Service ID +func (id LinkedServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.LinkedServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Linked Service ID +func (id LinkedServiceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticLinkedServices", "linkedServices", "linkedServices"), + resourceids.UserSpecifiedSegment("linkedServiceName", "linkedServiceName"), + } +} + +// String returns a human-readable description of this Linked Service ID +func (id LinkedServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Linked Service Name: %q", id.LinkedServiceName), + } + return fmt.Sprintf("Linked Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go new file mode 100644 index 00000000000..93e06914e53 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_linkedservice_test.go @@ -0,0 +1,327 @@ +package linkedservices + +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 = &LinkedServiceId{} + +func TestNewLinkedServiceID(t *testing.T) { + id := NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.LinkedServiceName != "linkedServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedServiceName'", id.LinkedServiceName, "linkedServiceName") + } +} + +func TestFormatLinkedServiceID(t *testing.T) { + actual := NewLinkedServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "linkedServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkedServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedServiceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + LinkedServiceName: "linkedServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedServiceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.LinkedServiceName != v.Expected.LinkedServiceName { + t.Fatalf("Expected %q but got %q for LinkedServiceName", v.Expected.LinkedServiceName, actual.LinkedServiceName) + } + + } +} + +func TestParseLinkedServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedServiceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + LinkedServiceName: "linkedServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedServices/linkedServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS/lInKeDsErViCeNaMe", + Expected: &LinkedServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + LinkedServiceName: "lInKeDsErViCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsErViCeS/lInKeDsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedServiceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.LinkedServiceName != v.Expected.LinkedServiceName { + t.Fatalf("Expected %q but got %q for LinkedServiceName", v.Expected.LinkedServiceName, actual.LinkedServiceName) + } + + } +} + +func TestSegmentsForLinkedServiceId(t *testing.T) { + segments := LinkedServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkedServiceId 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/operationalinsights/2023-09-01/linkedservices/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go new file mode 100644 index 00000000000..16b754510d2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace.go @@ -0,0 +1,130 @@ +package linkedservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go new file mode 100644 index 00000000000..7df7975ebf9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/id_workspace_test.go @@ -0,0 +1,282 @@ +package linkedservices + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go new file mode 100644 index 00000000000..18c4e4d1dd4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_createorupdate.go @@ -0,0 +1,76 @@ +package linkedservices + +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 + Model *LinkedService +} + +// CreateOrUpdate ... +func (c LinkedServicesClient) CreateOrUpdate(ctx context.Context, id LinkedServiceId, input LinkedService) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 LinkedServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id LinkedServiceId, input LinkedService) 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/operationalinsights/2023-09-01/linkedservices/method_delete.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go new file mode 100644 index 00000000000..65d01a5e7aa --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_delete.go @@ -0,0 +1,72 @@ +package linkedservices + +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 + Model *LinkedService +} + +// Delete ... +func (c LinkedServicesClient) Delete(ctx context.Context, id LinkedServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 LinkedServicesClient) DeleteThenPoll(ctx context.Context, id LinkedServiceId) 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/operationalinsights/2023-09-01/linkedservices/method_get.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go new file mode 100644 index 00000000000..f4d0d98ffdd --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_get.go @@ -0,0 +1,53 @@ +package linkedservices + +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 *LinkedService +} + +// Get ... +func (c LinkedServicesClient) Get(ctx context.Context, id LinkedServiceId) (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 + } + + var model LinkedService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go new file mode 100644 index 00000000000..9c72f2b544d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package linkedservices + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedServiceListResult +} + +// ListByWorkspace ... +func (c LinkedServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedServices", 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 + } + + var model LinkedServiceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go new file mode 100644 index 00000000000..f4b120ae7af --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservice.go @@ -0,0 +1,12 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedService struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties LinkedServiceProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go new file mode 100644 index 00000000000..8d5731b5785 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedservicelistresult.go @@ -0,0 +1,8 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedServiceListResult struct { + Value *[]LinkedService `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go new file mode 100644 index 00000000000..779209d9e11 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/model_linkedserviceproperties.go @@ -0,0 +1,10 @@ +package linkedservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedServiceProperties struct { + ProvisioningState *LinkedServiceEntityStatus `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + WriteAccessResourceId *string `json:"writeAccessResourceId,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go b/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go new file mode 100644 index 00000000000..9d1b1401113 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedservices/version.go @@ -0,0 +1,10 @@ +package linkedservices + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/linkedservices/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md new file mode 100644 index 00000000000..ebd03e52619 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts` Documentation + +The `linkedstorageaccounts` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/linkedstorageaccounts" +``` + + +### Client Initialization + +```go +client := linkedstorageaccounts.NewLinkedStorageAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LinkedStorageAccountsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +payload := linkedstorageaccounts.LinkedStorageAccountsResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LinkedStorageAccountsClient.Delete` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LinkedStorageAccountsClient.Get` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + +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: `LinkedStorageAccountsClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := linkedstorageaccounts.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go new file mode 100644 index 00000000000..951ac7536f6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/client.go @@ -0,0 +1,26 @@ +package linkedstorageaccounts + +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 LinkedStorageAccountsClient struct { + Client *resourcemanager.Client +} + +func NewLinkedStorageAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*LinkedStorageAccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "linkedstorageaccounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LinkedStorageAccountsClient: %+v", err) + } + + return &LinkedStorageAccountsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go new file mode 100644 index 00000000000..abf0284b4b7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/constants.go @@ -0,0 +1,60 @@ +package linkedstorageaccounts + +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 DataSourceType string + +const ( + DataSourceTypeAlerts DataSourceType = "Alerts" + DataSourceTypeAzureWatson DataSourceType = "AzureWatson" + DataSourceTypeCustomLogs DataSourceType = "CustomLogs" + DataSourceTypeIngestion DataSourceType = "Ingestion" + DataSourceTypeQuery DataSourceType = "Query" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAlerts), + string(DataSourceTypeAzureWatson), + string(DataSourceTypeCustomLogs), + string(DataSourceTypeIngestion), + string(DataSourceTypeQuery), + } +} + +func (s *DataSourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "alerts": DataSourceTypeAlerts, + "azurewatson": DataSourceTypeAzureWatson, + "customlogs": DataSourceTypeCustomLogs, + "ingestion": DataSourceTypeIngestion, + "query": DataSourceTypeQuery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go new file mode 100644 index 00000000000..42d6a1c2a50 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype.go @@ -0,0 +1,147 @@ +package linkedstorageaccounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DataSourceTypeId{}) +} + +var _ resourceids.ResourceId = &DataSourceTypeId{} + +// DataSourceTypeId is a struct representing the Resource ID for a Data Source Type +type DataSourceTypeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataSourceType DataSourceType +} + +// NewDataSourceTypeID returns a new DataSourceTypeId struct +func NewDataSourceTypeID(subscriptionId string, resourceGroupName string, workspaceName string, dataSourceType DataSourceType) DataSourceTypeId { + return DataSourceTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataSourceType: dataSourceType, + } +} + +// ParseDataSourceTypeID parses 'input' into a DataSourceTypeId +func ParseDataSourceTypeID(input string) (*DataSourceTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceTypeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataSourceTypeIDInsensitively parses 'input' case-insensitively into a DataSourceTypeId +// note: this method should only be used for API response data and not user input +func ParseDataSourceTypeIDInsensitively(input string) (*DataSourceTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataSourceTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataSourceTypeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataSourceTypeId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if v, ok := input.Parsed["dataSourceType"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataSourceType", input) + } + + dataSourceType, err := parseDataSourceType(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.DataSourceType = *dataSourceType + } + + return nil +} + +// ValidateDataSourceTypeID checks that 'input' can be parsed as a Data Source Type ID +func ValidateDataSourceTypeID(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 := ParseDataSourceTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Source Type ID +func (id DataSourceTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/linkedStorageAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, string(id.DataSourceType)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Source Type ID +func (id DataSourceTypeId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticLinkedStorageAccounts", "linkedStorageAccounts", "linkedStorageAccounts"), + resourceids.ConstantSegment("dataSourceType", PossibleValuesForDataSourceType(), "Alerts"), + } +} + +// String returns a human-readable description of this Data Source Type ID +func (id DataSourceTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Source Type: %q", string(id.DataSourceType)), + } + return fmt.Sprintf("Data Source Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go new file mode 100644 index 00000000000..dd022522a17 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_datasourcetype_test.go @@ -0,0 +1,327 @@ +package linkedstorageaccounts + +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 = &DataSourceTypeId{} + +func TestNewDataSourceTypeID(t *testing.T) { + id := NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataSourceType != "Alerts" { + t.Fatalf("Expected %q but got %q for Segment 'DataSourceType'", id.DataSourceType, "Alerts") + } +} + +func TestFormatDataSourceTypeID(t *testing.T) { + actual := NewDataSourceTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "Alerts").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataSourceTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceTypeId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceType: "Alerts", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceTypeID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceType != v.Expected.DataSourceType { + t.Fatalf("Expected %q but got %q for DataSourceType", v.Expected.DataSourceType, actual.DataSourceType) + } + + } +} + +func TestParseDataSourceTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataSourceTypeId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataSourceType: "Alerts", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/linkedStorageAccounts/Alerts/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs/aLeRtS", + Expected: &DataSourceTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataSourceType: "Alerts", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/lInKeDsToRaGeAcCoUnTs/aLeRtS/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataSourceTypeIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataSourceType != v.Expected.DataSourceType { + t.Fatalf("Expected %q but got %q for DataSourceType", v.Expected.DataSourceType, actual.DataSourceType) + } + + } +} + +func TestSegmentsForDataSourceTypeId(t *testing.T) { + segments := DataSourceTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataSourceTypeId 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/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go new file mode 100644 index 00000000000..1f6d261f8a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace.go @@ -0,0 +1,130 @@ +package linkedstorageaccounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go new file mode 100644 index 00000000000..9e32eb5abee --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/id_workspace_test.go @@ -0,0 +1,282 @@ +package linkedstorageaccounts + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go new file mode 100644 index 00000000000..713373c104f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_createorupdate.go @@ -0,0 +1,57 @@ +package linkedstorageaccounts + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedStorageAccountsResource +} + +// CreateOrUpdate ... +func (c LinkedStorageAccountsClient) CreateOrUpdate(ctx context.Context, id DataSourceTypeId, input LinkedStorageAccountsResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LinkedStorageAccountsResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go new file mode 100644 index 00000000000..65907ea3542 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_delete.go @@ -0,0 +1,46 @@ +package linkedstorageaccounts + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c LinkedStorageAccountsClient) Delete(ctx context.Context, id DataSourceTypeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go new file mode 100644 index 00000000000..085a74b9f9a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_get.go @@ -0,0 +1,53 @@ +package linkedstorageaccounts + +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 *LinkedStorageAccountsResource +} + +// Get ... +func (c LinkedStorageAccountsClient) Get(ctx context.Context, id DataSourceTypeId) (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 + } + + var model LinkedStorageAccountsResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go new file mode 100644 index 00000000000..2e40bd1dc6c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package linkedstorageaccounts + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LinkedStorageAccountsListResult +} + +// ListByWorkspace ... +func (c LinkedStorageAccountsClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedStorageAccounts", 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 + } + + var model LinkedStorageAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go new file mode 100644 index 00000000000..d9be9e74ab9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountslistresult.go @@ -0,0 +1,8 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsListResult struct { + Value *[]LinkedStorageAccountsResource `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go new file mode 100644 index 00000000000..43730125135 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsproperties.go @@ -0,0 +1,9 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsProperties struct { + DataSourceType *DataSourceType `json:"dataSourceType,omitempty"` + StorageAccountIds *[]string `json:"storageAccountIds,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go new file mode 100644 index 00000000000..c4a02711ff6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/model_linkedstorageaccountsresource.go @@ -0,0 +1,11 @@ +package linkedstorageaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkedStorageAccountsResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties LinkedStorageAccountsProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go new file mode 100644 index 00000000000..a3453f2616e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/linkedstorageaccounts/version.go @@ -0,0 +1,10 @@ +package linkedstorageaccounts + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/linkedstorageaccounts/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md b/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md new file mode 100644 index 00000000000..01cb5541ce6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypackqueries` Documentation + +The `querypackqueries` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/querypackqueries" +``` + + +### Client Initialization + +```go +client := querypackqueries.NewQueryPackQueriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesDelete` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +read, err := client.QueriesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesGet` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +read, err := client.QueriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesList` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +// alternatively `client.QueriesList(ctx, id, querypackqueries.DefaultQueriesListOperationOptions())` can be used to do batched pagination +items, err := client.QueriesListComplete(ctx, id, querypackqueries.DefaultQueriesListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesPut` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +payload := querypackqueries.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesPut(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesSearch` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypackqueries.LogAnalyticsQueryPackQuerySearchProperties{ + // ... +} + + +// alternatively `client.QueriesSearch(ctx, id, payload, querypackqueries.DefaultQueriesSearchOperationOptions())` can be used to do batched pagination +items, err := client.QueriesSearchComplete(ctx, id, payload, querypackqueries.DefaultQueriesSearchOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPackQueriesClient.QueriesUpdate` + +```go +ctx := context.TODO() +id := querypackqueries.NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + +payload := querypackqueries.LogAnalyticsQueryPackQuery{ + // ... +} + + +read, err := client.QueriesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go new file mode 100644 index 00000000000..d858936012f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/client.go @@ -0,0 +1,26 @@ +package querypackqueries + +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 QueryPackQueriesClient struct { + Client *resourcemanager.Client +} + +func NewQueryPackQueriesClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryPackQueriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querypackqueries", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryPackQueriesClient: %+v", err) + } + + return &QueryPackQueriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go new file mode 100644 index 00000000000..d28ec182a6d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query.go @@ -0,0 +1,139 @@ +package querypackqueries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&QueryId{}) +} + +var _ resourceids.ResourceId = &QueryId{} + +// QueryId is a struct representing the Resource ID for a Query +type QueryId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string + QueryName string +} + +// NewQueryID returns a new QueryId struct +func NewQueryID(subscriptionId string, resourceGroupName string, queryPackName string, queryName string) QueryId { + return QueryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + QueryName: queryName, + } +} + +// ParseQueryID parses 'input' into a QueryId +func ParseQueryID(input string) (*QueryId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryIDInsensitively parses 'input' case-insensitively into a QueryId +// note: this method should only be used for API response data and not user input +func ParseQueryIDInsensitively(input string) (*QueryId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + if id.QueryName, ok = input.Parsed["queryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryName", input) + } + + return nil +} + +// ValidateQueryID checks that 'input' can be parsed as a Query ID +func ValidateQueryID(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 := ParseQueryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query ID +func (id QueryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s/queries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName, id.QueryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query ID +func (id QueryId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + resourceids.StaticSegment("staticQueries", "queries", "queries"), + resourceids.UserSpecifiedSegment("queryName", "queryName"), + } +} + +// String returns a human-readable description of this Query ID +func (id QueryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + fmt.Sprintf("Query Name: %q", id.QueryName), + } + return fmt.Sprintf("Query (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go new file mode 100644 index 00000000000..41156889895 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_query_test.go @@ -0,0 +1,327 @@ +package querypackqueries + +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 = &QueryId{} + +func TestNewQueryID(t *testing.T) { + id := NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName") + + 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.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } + + if id.QueryName != "queryName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryName'", id.QueryName, "queryName") + } +} + +func TestFormatQueryID(t *testing.T) { + actual := NewQueryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName", "queryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + QueryName: "queryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryID(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + if actual.QueryName != v.Expected.QueryName { + t.Fatalf("Expected %q but got %q for QueryName", v.Expected.QueryName, actual.QueryName) + } + + } +} + +func TestParseQueryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + QueryName: "queryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/queries/queryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs/qUeRyNaMe", + Expected: &QueryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + QueryName: "qUeRyNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/qUeRiEs/qUeRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryIDInsensitively(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + if actual.QueryName != v.Expected.QueryName { + t.Fatalf("Expected %q but got %q for QueryName", v.Expected.QueryName, actual.QueryName) + } + + } +} + +func TestSegmentsForQueryId(t *testing.T) { + segments := QueryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryId 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/operationalinsights/2023-09-01/querypackqueries/id_querypack.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go new file mode 100644 index 00000000000..4f2002aa009 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack.go @@ -0,0 +1,130 @@ +package querypackqueries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&QueryPackId{}) +} + +var _ resourceids.ResourceId = &QueryPackId{} + +// QueryPackId is a struct representing the Resource ID for a Query Pack +type QueryPackId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string +} + +// NewQueryPackID returns a new QueryPackId struct +func NewQueryPackID(subscriptionId string, resourceGroupName string, queryPackName string) QueryPackId { + return QueryPackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + } +} + +// ParseQueryPackID parses 'input' into a QueryPackId +func ParseQueryPackID(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryPackIDInsensitively parses 'input' case-insensitively into a QueryPackId +// note: this method should only be used for API response data and not user input +func ParseQueryPackIDInsensitively(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryPackId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + return nil +} + +// ValidateQueryPackID checks that 'input' can be parsed as a Query Pack ID +func ValidateQueryPackID(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 := ParseQueryPackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query Pack ID +func (id QueryPackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query Pack ID +func (id QueryPackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + } +} + +// String returns a human-readable description of this Query Pack ID +func (id QueryPackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + } + return fmt.Sprintf("Query Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go new file mode 100644 index 00000000000..eef7759ac06 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/id_querypack_test.go @@ -0,0 +1,282 @@ +package querypackqueries + +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 = &QueryPackId{} + +func TestNewQueryPackID(t *testing.T) { + id := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + + 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.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } +} + +func TestFormatQueryPackID(t *testing.T) { + actual := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryPackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackID(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestParseQueryPackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackIDInsensitively(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestSegmentsForQueryPackId(t *testing.T) { + segments := QueryPackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryPackId 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/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go new file mode 100644 index 00000000000..39ddfb9e4d7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesdelete.go @@ -0,0 +1,47 @@ +package querypackqueries + +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 QueriesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// QueriesDelete ... +func (c QueryPackQueriesClient) QueriesDelete(ctx context.Context, id QueryId) (result QueriesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go new file mode 100644 index 00000000000..ff8ffe93a7a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesget.go @@ -0,0 +1,53 @@ +package querypackqueries + +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 QueriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesGet ... +func (c QueryPackQueriesClient) QueriesGet(ctx context.Context, id QueryId) (result QueriesGetOperationResponse, 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 + } + + var model LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go new file mode 100644 index 00000000000..f6173d9275c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_querieslist.go @@ -0,0 +1,138 @@ +package querypackqueries + +import ( + "context" + "fmt" + "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 QueriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogAnalyticsQueryPackQuery +} + +type QueriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPackQuery +} + +type QueriesListOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesListOperationOptions() QueriesListOperationOptions { + return QueriesListOperationOptions{} +} + +func (o QueriesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o QueriesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o QueriesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeBody != nil { + out.Append("includeBody", fmt.Sprintf("%v", *o.IncludeBody)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type QueriesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *QueriesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// QueriesList ... +func (c QueryPackQueriesClient) QueriesList(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (result QueriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &QueriesListCustomPager{}, + Path: fmt.Sprintf("%s/queries", 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 *[]LogAnalyticsQueryPackQuery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// QueriesListComplete retrieves all the results into a single object +func (c QueryPackQueriesClient) QueriesListComplete(ctx context.Context, id QueryPackId, options QueriesListOperationOptions) (QueriesListCompleteResult, error) { + return c.QueriesListCompleteMatchingPredicate(ctx, id, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPackQueriesClient) QueriesListCompleteMatchingPredicate(ctx context.Context, id QueryPackId, options QueriesListOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (result QueriesListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + resp, err := c.QueriesList(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = QueriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go new file mode 100644 index 00000000000..ecf150a8195 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesput.go @@ -0,0 +1,57 @@ +package querypackqueries + +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 QueriesPutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesPut ... +func (c QueryPackQueriesClient) QueriesPut(ctx context.Context, id QueryId, input LogAnalyticsQueryPackQuery) (result QueriesPutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go new file mode 100644 index 00000000000..7342fa8eeec --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriessearch.go @@ -0,0 +1,138 @@ +package querypackqueries + +import ( + "context" + "fmt" + "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 QueriesSearchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogAnalyticsQueryPackQuery +} + +type QueriesSearchCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPackQuery +} + +type QueriesSearchOperationOptions struct { + IncludeBody *bool + Top *int64 +} + +func DefaultQueriesSearchOperationOptions() QueriesSearchOperationOptions { + return QueriesSearchOperationOptions{} +} + +func (o QueriesSearchOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o QueriesSearchOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o QueriesSearchOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeBody != nil { + out.Append("includeBody", fmt.Sprintf("%v", *o.IncludeBody)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type QueriesSearchCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *QueriesSearchCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// QueriesSearch ... +func (c QueryPackQueriesClient) QueriesSearch(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (result QueriesSearchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &QueriesSearchCustomPager{}, + Path: fmt.Sprintf("%s/queries/search", 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 *[]LogAnalyticsQueryPackQuery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// QueriesSearchComplete retrieves all the results into a single object +func (c QueryPackQueriesClient) QueriesSearchComplete(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions) (QueriesSearchCompleteResult, error) { + return c.QueriesSearchCompleteMatchingPredicate(ctx, id, input, options, LogAnalyticsQueryPackQueryOperationPredicate{}) +} + +// QueriesSearchCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPackQueriesClient) QueriesSearchCompleteMatchingPredicate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPackQuerySearchProperties, options QueriesSearchOperationOptions, predicate LogAnalyticsQueryPackQueryOperationPredicate) (result QueriesSearchCompleteResult, err error) { + items := make([]LogAnalyticsQueryPackQuery, 0) + + resp, err := c.QueriesSearch(ctx, id, input, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = QueriesSearchCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go new file mode 100644 index 00000000000..8a547b353c8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/method_queriesupdate.go @@ -0,0 +1,57 @@ +package querypackqueries + +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 QueriesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPackQuery +} + +// QueriesUpdate ... +func (c QueryPackQueriesClient) QueriesUpdate(ctx context.Context, id QueryId, input LogAnalyticsQueryPackQuery) (result QueriesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPackQuery + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go new file mode 100644 index 00000000000..555d2bf023c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquery.go @@ -0,0 +1,16 @@ +package querypackqueries + +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 LogAnalyticsQueryPackQuery struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogAnalyticsQueryPackQueryProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go new file mode 100644 index 00000000000..25dc4ae2a31 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackqueryproperties.go @@ -0,0 +1,47 @@ +package querypackqueries + +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 LogAnalyticsQueryPackQueryProperties struct { + Author *string `json:"author,omitempty"` + Body string `json:"body"` + Description *string `json:"description,omitempty"` + DisplayName string `json:"displayName"` + Id *string `json:"id,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + Related *LogAnalyticsQueryPackQueryPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackQueryProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackQueryProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go new file mode 100644 index 00000000000..5efd7bd3027 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerypropertiesrelated.go @@ -0,0 +1,10 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go new file mode 100644 index 00000000000..5845c3f78ce --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchproperties.go @@ -0,0 +1,9 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchProperties struct { + Related *LogAnalyticsQueryPackQuerySearchPropertiesRelated `json:"related,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go new file mode 100644 index 00000000000..d2c6bc8c290 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/model_loganalyticsquerypackquerysearchpropertiesrelated.go @@ -0,0 +1,10 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQuerySearchPropertiesRelated struct { + Categories *[]string `json:"categories,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go new file mode 100644 index 00000000000..38fda83f51a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/predicates.go @@ -0,0 +1,27 @@ +package querypackqueries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackQueryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackQueryOperationPredicate) Matches(input LogAnalyticsQueryPackQuery) 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/operationalinsights/2023-09-01/querypackqueries/version.go b/resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go new file mode 100644 index 00000000000..7a6c807d036 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypackqueries/version.go @@ -0,0 +1,10 @@ +package querypackqueries + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querypackqueries/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/README.md b/resource-manager/operationalinsights/2023-09-01/querypacks/README.md new file mode 100644 index 00000000000..e320d71f521 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/README.md @@ -0,0 +1,150 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks` Documentation + +The `querypacks` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/querypacks" +``` + + +### Client Initialization + +```go +client := querypacks.NewQueryPacksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryPacksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypacks.LogAnalyticsQueryPack{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPacksClient.CreateOrUpdateWithoutName` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := querypacks.LogAnalyticsQueryPack{ + // ... +} + + +read, err := client.CreateOrUpdateWithoutName(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPacksClient.Delete` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryPacksClient.Get` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +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: `QueryPacksClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `QueryPacksClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueryPacksClient.UpdateTags` + +```go +ctx := context.TODO() +id := querypacks.NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + +payload := querypacks.TagsResource{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/client.go b/resource-manager/operationalinsights/2023-09-01/querypacks/client.go new file mode 100644 index 00000000000..5efc5278ddd --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/client.go @@ -0,0 +1,26 @@ +package querypacks + +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 QueryPacksClient struct { + Client *resourcemanager.Client +} + +func NewQueryPacksClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryPacksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querypacks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryPacksClient: %+v", err) + } + + return &QueryPacksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go new file mode 100644 index 00000000000..3fe4cc2c22f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack.go @@ -0,0 +1,130 @@ +package querypacks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&QueryPackId{}) +} + +var _ resourceids.ResourceId = &QueryPackId{} + +// QueryPackId is a struct representing the Resource ID for a Query Pack +type QueryPackId struct { + SubscriptionId string + ResourceGroupName string + QueryPackName string +} + +// NewQueryPackID returns a new QueryPackId struct +func NewQueryPackID(subscriptionId string, resourceGroupName string, queryPackName string) QueryPackId { + return QueryPackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + QueryPackName: queryPackName, + } +} + +// ParseQueryPackID parses 'input' into a QueryPackId +func ParseQueryPackID(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseQueryPackIDInsensitively parses 'input' case-insensitively into a QueryPackId +// note: this method should only be used for API response data and not user input +func ParseQueryPackIDInsensitively(input string) (*QueryPackId, error) { + parser := resourceids.NewParserFromResourceIdType(&QueryPackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := QueryPackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *QueryPackId) 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.QueryPackName, ok = input.Parsed["queryPackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "queryPackName", input) + } + + return nil +} + +// ValidateQueryPackID checks that 'input' can be parsed as a Query Pack ID +func ValidateQueryPackID(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 := ParseQueryPackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Query Pack ID +func (id QueryPackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/queryPacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.QueryPackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Query Pack ID +func (id QueryPackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticQueryPacks", "queryPacks", "queryPacks"), + resourceids.UserSpecifiedSegment("queryPackName", "queryPackName"), + } +} + +// String returns a human-readable description of this Query Pack ID +func (id QueryPackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Query Pack Name: %q", id.QueryPackName), + } + return fmt.Sprintf("Query Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go new file mode 100644 index 00000000000..e5be1caa33a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/id_querypack_test.go @@ -0,0 +1,282 @@ +package querypacks + +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 = &QueryPackId{} + +func TestNewQueryPackID(t *testing.T) { + id := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName") + + 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.QueryPackName != "queryPackName" { + t.Fatalf("Expected %q but got %q for Segment 'QueryPackName'", id.QueryPackName, "queryPackName") + } +} + +func TestFormatQueryPackID(t *testing.T) { + actual := NewQueryPackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "queryPackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseQueryPackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackID(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestParseQueryPackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *QueryPackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + QueryPackName: "queryPackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/queryPacks/queryPackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe", + Expected: &QueryPackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + QueryPackName: "qUeRyPaCkNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/qUeRyPaCkS/qUeRyPaCkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseQueryPackIDInsensitively(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.QueryPackName != v.Expected.QueryPackName { + t.Fatalf("Expected %q but got %q for QueryPackName", v.Expected.QueryPackName, actual.QueryPackName) + } + + } +} + +func TestSegmentsForQueryPackId(t *testing.T) { + segments := QueryPackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("QueryPackId 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/operationalinsights/2023-09-01/querypacks/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go new file mode 100644 index 00000000000..779d071fbae --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdate.go @@ -0,0 +1,57 @@ +package querypacks + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// CreateOrUpdate ... +func (c QueryPacksClient) CreateOrUpdate(ctx context.Context, id QueryPackId, input LogAnalyticsQueryPack) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go new file mode 100644 index 00000000000..08a4740145c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_createorupdatewithoutname.go @@ -0,0 +1,59 @@ +package querypacks + +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 CreateOrUpdateWithoutNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// CreateOrUpdateWithoutName ... +func (c QueryPacksClient) CreateOrUpdateWithoutName(ctx context.Context, id commonids.ResourceGroupId, input LogAnalyticsQueryPack) (result CreateOrUpdateWithoutNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go new file mode 100644 index 00000000000..c9137572bc3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_delete.go @@ -0,0 +1,47 @@ +package querypacks + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c QueryPacksClient) Delete(ctx context.Context, id QueryPackId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go new file mode 100644 index 00000000000..019de126545 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_get.go @@ -0,0 +1,53 @@ +package querypacks + +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 *LogAnalyticsQueryPack +} + +// Get ... +func (c QueryPacksClient) Get(ctx context.Context, id QueryPackId) (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 + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go new file mode 100644 index 00000000000..32b92f450e9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_list.go @@ -0,0 +1,106 @@ +package querypacks + +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 *[]LogAnalyticsQueryPack +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPack +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c QueryPacksClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 *[]LogAnalyticsQueryPack `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 QueryPacksClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPacksClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LogAnalyticsQueryPackOperationPredicate) (result ListCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e856e976ce0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package querypacks + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogAnalyticsQueryPack +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogAnalyticsQueryPack +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c QueryPacksClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.OperationalInsights/queryPacks", 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 *[]LogAnalyticsQueryPack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c QueryPacksClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, LogAnalyticsQueryPackOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryPacksClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LogAnalyticsQueryPackOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]LogAnalyticsQueryPack, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go b/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go new file mode 100644 index 00000000000..d4f83732840 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/method_updatetags.go @@ -0,0 +1,57 @@ +package querypacks + +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 UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogAnalyticsQueryPack +} + +// UpdateTags ... +func (c QueryPacksClient) UpdateTags(ctx context.Context, id QueryPackId, input TagsResource) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model LogAnalyticsQueryPack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go new file mode 100644 index 00000000000..d71c1289066 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypack.go @@ -0,0 +1,18 @@ +package querypacks + +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 LogAnalyticsQueryPack struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties LogAnalyticsQueryPackProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go new file mode 100644 index 00000000000..772445a81e8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_loganalyticsquerypackproperties.go @@ -0,0 +1,41 @@ +package querypacks + +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 LogAnalyticsQueryPackProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + QueryPackId *string `json:"queryPackId,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeModified *string `json:"timeModified,omitempty"` +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *LogAnalyticsQueryPackProperties) GetTimeModifiedAsTime() (*time.Time, error) { + if o.TimeModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogAnalyticsQueryPackProperties) SetTimeModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeModified = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go b/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go new file mode 100644 index 00000000000..7fdf7eeb6c5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/model_tagsresource.go @@ -0,0 +1,8 @@ +package querypacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsResource struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go b/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go new file mode 100644 index 00000000000..46c21c9f019 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/predicates.go @@ -0,0 +1,32 @@ +package querypacks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsQueryPackOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogAnalyticsQueryPackOperationPredicate) Matches(input LogAnalyticsQueryPack) 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/operationalinsights/2023-09-01/querypacks/version.go b/resource-manager/operationalinsights/2023-09-01/querypacks/version.go new file mode 100644 index 00000000000..d76fa54c4d4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/querypacks/version.go @@ -0,0 +1,10 @@ +package querypacks + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querypacks/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md b/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md new file mode 100644 index 00000000000..0809020bc26 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/savedsearches` Documentation + +The `savedsearches` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/savedsearches" +``` + + +### Client Initialization + +```go +client := savedsearches.NewSavedSearchesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SavedSearchesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +payload := savedsearches.SavedSearch{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SavedSearchesClient.Delete` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SavedSearchesClient.Get` + +```go +ctx := context.TODO() +id := savedsearches.NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + +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: `SavedSearchesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := savedsearches.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go new file mode 100644 index 00000000000..feb243cf4e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/client.go @@ -0,0 +1,26 @@ +package savedsearches + +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 SavedSearchesClient struct { + Client *resourcemanager.Client +} + +func NewSavedSearchesClientWithBaseURI(sdkApi sdkEnv.Api) (*SavedSearchesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "savedsearches", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SavedSearchesClient: %+v", err) + } + + return &SavedSearchesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go new file mode 100644 index 00000000000..ede0c729bf5 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch.go @@ -0,0 +1,139 @@ +package savedsearches + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SavedSearchId{}) +} + +var _ resourceids.ResourceId = &SavedSearchId{} + +// SavedSearchId is a struct representing the Resource ID for a Saved Search +type SavedSearchId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + SavedSearchId string +} + +// NewSavedSearchID returns a new SavedSearchId struct +func NewSavedSearchID(subscriptionId string, resourceGroupName string, workspaceName string, savedSearchId string) SavedSearchId { + return SavedSearchId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + SavedSearchId: savedSearchId, + } +} + +// ParseSavedSearchID parses 'input' into a SavedSearchId +func ParseSavedSearchID(input string) (*SavedSearchId, error) { + parser := resourceids.NewParserFromResourceIdType(&SavedSearchId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SavedSearchId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSavedSearchIDInsensitively parses 'input' case-insensitively into a SavedSearchId +// note: this method should only be used for API response data and not user input +func ParseSavedSearchIDInsensitively(input string) (*SavedSearchId, error) { + parser := resourceids.NewParserFromResourceIdType(&SavedSearchId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SavedSearchId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SavedSearchId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.SavedSearchId, ok = input.Parsed["savedSearchId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "savedSearchId", input) + } + + return nil +} + +// ValidateSavedSearchID checks that 'input' can be parsed as a Saved Search ID +func ValidateSavedSearchID(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 := ParseSavedSearchID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Saved Search ID +func (id SavedSearchId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/savedSearches/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.SavedSearchId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Saved Search ID +func (id SavedSearchId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticSavedSearches", "savedSearches", "savedSearches"), + resourceids.UserSpecifiedSegment("savedSearchId", "savedSearchId"), + } +} + +// String returns a human-readable description of this Saved Search ID +func (id SavedSearchId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Saved Search: %q", id.SavedSearchId), + } + return fmt.Sprintf("Saved Search (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go new file mode 100644 index 00000000000..6581bd1a01b --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_savedsearch_test.go @@ -0,0 +1,327 @@ +package savedsearches + +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 = &SavedSearchId{} + +func TestNewSavedSearchID(t *testing.T) { + id := NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.SavedSearchId != "savedSearchId" { + t.Fatalf("Expected %q but got %q for Segment 'SavedSearchId'", id.SavedSearchId, "savedSearchId") + } +} + +func TestFormatSavedSearchID(t *testing.T) { + actual := NewSavedSearchID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "savedSearchId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSavedSearchID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SavedSearchId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + SavedSearchId: "savedSearchId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSavedSearchID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.SavedSearchId != v.Expected.SavedSearchId { + t.Fatalf("Expected %q but got %q for SavedSearchId", v.Expected.SavedSearchId, actual.SavedSearchId) + } + + } +} + +func TestParseSavedSearchIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SavedSearchId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + SavedSearchId: "savedSearchId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/savedSearches/savedSearchId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs/sAvEdSeArChId", + Expected: &SavedSearchId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + SavedSearchId: "sAvEdSeArChId", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sAvEdSeArChEs/sAvEdSeArChId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSavedSearchIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.SavedSearchId != v.Expected.SavedSearchId { + t.Fatalf("Expected %q but got %q for SavedSearchId", v.Expected.SavedSearchId, actual.SavedSearchId) + } + + } +} + +func TestSegmentsForSavedSearchId(t *testing.T) { + segments := SavedSearchId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SavedSearchId 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/operationalinsights/2023-09-01/savedsearches/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go new file mode 100644 index 00000000000..bbbfffcfced --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace.go @@ -0,0 +1,130 @@ +package savedsearches + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go new file mode 100644 index 00000000000..906f8179a44 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/id_workspace_test.go @@ -0,0 +1,282 @@ +package savedsearches + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go new file mode 100644 index 00000000000..69d3a92a12d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_createorupdate.go @@ -0,0 +1,57 @@ +package savedsearches + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SavedSearch +} + +// CreateOrUpdate ... +func (c SavedSearchesClient) CreateOrUpdate(ctx context.Context, id SavedSearchId, input SavedSearch) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SavedSearch + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go new file mode 100644 index 00000000000..26ca123124e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_delete.go @@ -0,0 +1,46 @@ +package savedsearches + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SavedSearchesClient) Delete(ctx context.Context, id SavedSearchId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go new file mode 100644 index 00000000000..cd5ba498ecb --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_get.go @@ -0,0 +1,53 @@ +package savedsearches + +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 *SavedSearch +} + +// Get ... +func (c SavedSearchesClient) Get(ctx context.Context, id SavedSearchId) (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 + } + + var model SavedSearch + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go new file mode 100644 index 00000000000..6c253f74e3a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package savedsearches + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SavedSearchesListResult +} + +// ListByWorkspace ... +func (c SavedSearchesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/savedSearches", 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 + } + + var model SavedSearchesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go new file mode 100644 index 00000000000..0468b07d4a2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearch.go @@ -0,0 +1,12 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearch struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SavedSearchProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go new file mode 100644 index 00000000000..344ab1af380 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearcheslistresult.go @@ -0,0 +1,8 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearchesListResult struct { + Value *[]SavedSearch `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go new file mode 100644 index 00000000000..ab34bf3b4d1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_savedsearchproperties.go @@ -0,0 +1,14 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SavedSearchProperties struct { + Category string `json:"category"` + DisplayName string `json:"displayName"` + FunctionAlias *string `json:"functionAlias,omitempty"` + FunctionParameters *string `json:"functionParameters,omitempty"` + Query string `json:"query"` + Tags *[]Tag `json:"tags,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go new file mode 100644 index 00000000000..f2071dd9101 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/model_tag.go @@ -0,0 +1,9 @@ +package savedsearches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Tag struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go b/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go new file mode 100644 index 00000000000..99d62f25876 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/savedsearches/version.go @@ -0,0 +1,10 @@ +package savedsearches + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/savedsearches/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md b/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md new file mode 100644 index 00000000000..00ef7012b19 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/storageinsights` Documentation + +The `storageinsights` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/storageinsights" +``` + + +### Client Initialization + +```go +client := storageinsights.NewStorageInsightsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsCreateOrUpdate` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +payload := storageinsights.StorageInsight{ + // ... +} + + +read, err := client.StorageInsightConfigsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsDelete` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +read, err := client.StorageInsightConfigsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsGet` + +```go +ctx := context.TODO() +id := storageinsights.NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + +read, err := client.StorageInsightConfigsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageInsightsClient.StorageInsightConfigsListByWorkspace` + +```go +ctx := context.TODO() +id := storageinsights.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.StorageInsightConfigsListByWorkspace(ctx, id)` can be used to do batched pagination +items, err := client.StorageInsightConfigsListByWorkspaceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go new file mode 100644 index 00000000000..8db4661f572 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/client.go @@ -0,0 +1,26 @@ +package storageinsights + +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 StorageInsightsClient struct { + Client *resourcemanager.Client +} + +func NewStorageInsightsClientWithBaseURI(sdkApi sdkEnv.Api) (*StorageInsightsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "storageinsights", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StorageInsightsClient: %+v", err) + } + + return &StorageInsightsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go new file mode 100644 index 00000000000..64295d09d1f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/constants.go @@ -0,0 +1,51 @@ +package storageinsights + +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 StorageInsightState string + +const ( + StorageInsightStateERROR StorageInsightState = "ERROR" + StorageInsightStateOK StorageInsightState = "OK" +) + +func PossibleValuesForStorageInsightState() []string { + return []string{ + string(StorageInsightStateERROR), + string(StorageInsightStateOK), + } +} + +func (s *StorageInsightState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageInsightState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageInsightState(input string) (*StorageInsightState, error) { + vals := map[string]StorageInsightState{ + "error": StorageInsightStateERROR, + "ok": StorageInsightStateOK, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageInsightState(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go new file mode 100644 index 00000000000..93477fb129e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig.go @@ -0,0 +1,139 @@ +package storageinsights + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&StorageInsightConfigId{}) +} + +var _ resourceids.ResourceId = &StorageInsightConfigId{} + +// StorageInsightConfigId is a struct representing the Resource ID for a Storage Insight Config +type StorageInsightConfigId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + StorageInsightConfigName string +} + +// NewStorageInsightConfigID returns a new StorageInsightConfigId struct +func NewStorageInsightConfigID(subscriptionId string, resourceGroupName string, workspaceName string, storageInsightConfigName string) StorageInsightConfigId { + return StorageInsightConfigId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + StorageInsightConfigName: storageInsightConfigName, + } +} + +// ParseStorageInsightConfigID parses 'input' into a StorageInsightConfigId +func ParseStorageInsightConfigID(input string) (*StorageInsightConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageInsightConfigId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageInsightConfigId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageInsightConfigIDInsensitively parses 'input' case-insensitively into a StorageInsightConfigId +// note: this method should only be used for API response data and not user input +func ParseStorageInsightConfigIDInsensitively(input string) (*StorageInsightConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageInsightConfigId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageInsightConfigId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageInsightConfigId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.StorageInsightConfigName, ok = input.Parsed["storageInsightConfigName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageInsightConfigName", input) + } + + return nil +} + +// ValidateStorageInsightConfigID checks that 'input' can be parsed as a Storage Insight Config ID +func ValidateStorageInsightConfigID(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 := ParseStorageInsightConfigID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Insight Config ID +func (id StorageInsightConfigId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/storageInsightConfigs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.StorageInsightConfigName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Insight Config ID +func (id StorageInsightConfigId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticStorageInsightConfigs", "storageInsightConfigs", "storageInsightConfigs"), + resourceids.UserSpecifiedSegment("storageInsightConfigName", "storageInsightConfigName"), + } +} + +// String returns a human-readable description of this Storage Insight Config ID +func (id StorageInsightConfigId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Storage Insight Config Name: %q", id.StorageInsightConfigName), + } + return fmt.Sprintf("Storage Insight Config (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go new file mode 100644 index 00000000000..286f5f06c59 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_storageinsightconfig_test.go @@ -0,0 +1,327 @@ +package storageinsights + +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 = &StorageInsightConfigId{} + +func TestNewStorageInsightConfigID(t *testing.T) { + id := NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.StorageInsightConfigName != "storageInsightConfigName" { + t.Fatalf("Expected %q but got %q for Segment 'StorageInsightConfigName'", id.StorageInsightConfigName, "storageInsightConfigName") + } +} + +func TestFormatStorageInsightConfigID(t *testing.T) { + actual := NewStorageInsightConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "storageInsightConfigName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageInsightConfigID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageInsightConfigId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + StorageInsightConfigName: "storageInsightConfigName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageInsightConfigID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.StorageInsightConfigName != v.Expected.StorageInsightConfigName { + t.Fatalf("Expected %q but got %q for StorageInsightConfigName", v.Expected.StorageInsightConfigName, actual.StorageInsightConfigName) + } + + } +} + +func TestParseStorageInsightConfigIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageInsightConfigId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + StorageInsightConfigName: "storageInsightConfigName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/storageInsightConfigs/storageInsightConfigName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs/sToRaGeInSiGhTcOnFiGnAmE", + Expected: &StorageInsightConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + StorageInsightConfigName: "sToRaGeInSiGhTcOnFiGnAmE", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/sToRaGeInSiGhTcOnFiGs/sToRaGeInSiGhTcOnFiGnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageInsightConfigIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.StorageInsightConfigName != v.Expected.StorageInsightConfigName { + t.Fatalf("Expected %q but got %q for StorageInsightConfigName", v.Expected.StorageInsightConfigName, actual.StorageInsightConfigName) + } + + } +} + +func TestSegmentsForStorageInsightConfigId(t *testing.T) { + segments := StorageInsightConfigId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageInsightConfigId 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/operationalinsights/2023-09-01/storageinsights/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go new file mode 100644 index 00000000000..f90f45ddb97 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace.go @@ -0,0 +1,130 @@ +package storageinsights + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go new file mode 100644 index 00000000000..99dcec64147 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/id_workspace_test.go @@ -0,0 +1,282 @@ +package storageinsights + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go new file mode 100644 index 00000000000..8f2360466e4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigscreateorupdate.go @@ -0,0 +1,58 @@ +package storageinsights + +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 StorageInsightConfigsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageInsight +} + +// StorageInsightConfigsCreateOrUpdate ... +func (c StorageInsightsClient) StorageInsightConfigsCreateOrUpdate(ctx context.Context, id StorageInsightConfigId, input StorageInsight) (result StorageInsightConfigsCreateOrUpdateOperationResponse, 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 + } + + var model StorageInsight + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go new file mode 100644 index 00000000000..c77f95ac83c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsdelete.go @@ -0,0 +1,47 @@ +package storageinsights + +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 StorageInsightConfigsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StorageInsightConfigsDelete ... +func (c StorageInsightsClient) StorageInsightConfigsDelete(ctx context.Context, id StorageInsightConfigId) (result StorageInsightConfigsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go new file mode 100644 index 00000000000..ec74aa1f07c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigsget.go @@ -0,0 +1,53 @@ +package storageinsights + +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 StorageInsightConfigsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageInsight +} + +// StorageInsightConfigsGet ... +func (c StorageInsightsClient) StorageInsightConfigsGet(ctx context.Context, id StorageInsightConfigId) (result StorageInsightConfigsGetOperationResponse, 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 + } + + var model StorageInsight + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go new file mode 100644 index 00000000000..eaed4a10791 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/method_storageinsightconfigslistbyworkspace.go @@ -0,0 +1,105 @@ +package storageinsights + +import ( + "context" + "fmt" + "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 StorageInsightConfigsListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageInsight +} + +type StorageInsightConfigsListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageInsight +} + +type StorageInsightConfigsListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *StorageInsightConfigsListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// StorageInsightConfigsListByWorkspace ... +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspace(ctx context.Context, id WorkspaceId) (result StorageInsightConfigsListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &StorageInsightConfigsListByWorkspaceCustomPager{}, + Path: fmt.Sprintf("%s/storageInsightConfigs", 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 *[]StorageInsight `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// StorageInsightConfigsListByWorkspaceComplete retrieves all the results into a single object +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (StorageInsightConfigsListByWorkspaceCompleteResult, error) { + return c.StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate(ctx, id, StorageInsightOperationPredicate{}) +} + +// StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StorageInsightsClient) StorageInsightConfigsListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate StorageInsightOperationPredicate) (result StorageInsightConfigsListByWorkspaceCompleteResult, err error) { + items := make([]StorageInsight, 0) + + resp, err := c.StorageInsightConfigsListByWorkspace(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = StorageInsightConfigsListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go new file mode 100644 index 00000000000..101ce95c041 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageaccount.go @@ -0,0 +1,9 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageAccount struct { + Id string `json:"id"` + Key string `json:"key"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go new file mode 100644 index 00000000000..c1d70f2d0b6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsight.go @@ -0,0 +1,13 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsight struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageInsightProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go new file mode 100644 index 00000000000..7042ba2c8d2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightproperties.go @@ -0,0 +1,11 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightProperties struct { + Containers *[]string `json:"containers,omitempty"` + Status *StorageInsightStatus `json:"status,omitempty"` + StorageAccount StorageAccount `json:"storageAccount"` + Tables *[]string `json:"tables,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go new file mode 100644 index 00000000000..33051fdac25 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/model_storageinsightstatus.go @@ -0,0 +1,9 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightStatus struct { + Description *string `json:"description,omitempty"` + State StorageInsightState `json:"state"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go new file mode 100644 index 00000000000..c926b61601e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/predicates.go @@ -0,0 +1,32 @@ +package storageinsights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInsightOperationPredicate struct { + ETag *string + Id *string + Name *string + Type *string +} + +func (p StorageInsightOperationPredicate) Matches(input StorageInsight) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + 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/operationalinsights/2023-09-01/storageinsights/version.go b/resource-manager/operationalinsights/2023-09-01/storageinsights/version.go new file mode 100644 index 00000000000..16f66066b96 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/storageinsights/version.go @@ -0,0 +1,10 @@ +package storageinsights + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/storageinsights/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/README.md b/resource-manager/operationalinsights/2023-09-01/tables/README.md new file mode 100644 index 00000000000..15cdd64f27c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/README.md @@ -0,0 +1,130 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2023-09-01/tables` Documentation + +The `tables` SDK allows for interaction with Azure Resource Manager `operationalinsights` (API Version `2023-09-01`). + +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/operationalinsights/2023-09-01/tables" +``` + + +### Client Initialization + +```go +client := tables.NewTablesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TablesClient.CancelSearch` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +read, err := client.CancelSearch(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +payload := tables.Table{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TablesClient.Delete` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `TablesClient.Get` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +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: `TablesClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := tables.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListByWorkspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.Migrate` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +read, err := client.Migrate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TablesClient.Update` + +```go +ctx := context.TODO() +id := tables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + +payload := tables.Table{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/tables/client.go b/resource-manager/operationalinsights/2023-09-01/tables/client.go new file mode 100644 index 00000000000..d448018bd46 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/client.go @@ -0,0 +1,26 @@ +package tables + +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 TablesClient struct { + Client *resourcemanager.Client +} + +func NewTablesClientWithBaseURI(sdkApi sdkEnv.Api) (*TablesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "tables", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TablesClient: %+v", err) + } + + return &TablesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/constants.go b/resource-manager/operationalinsights/2023-09-01/tables/constants.go new file mode 100644 index 00000000000..3b59c402f7c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/constants.go @@ -0,0 +1,336 @@ +package tables + +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 ColumnDataTypeHintEnum string + +const ( + ColumnDataTypeHintEnumArmPath ColumnDataTypeHintEnum = "armPath" + ColumnDataTypeHintEnumGuid ColumnDataTypeHintEnum = "guid" + ColumnDataTypeHintEnumIP ColumnDataTypeHintEnum = "ip" + ColumnDataTypeHintEnumUri ColumnDataTypeHintEnum = "uri" +) + +func PossibleValuesForColumnDataTypeHintEnum() []string { + return []string{ + string(ColumnDataTypeHintEnumArmPath), + string(ColumnDataTypeHintEnumGuid), + string(ColumnDataTypeHintEnumIP), + string(ColumnDataTypeHintEnumUri), + } +} + +func (s *ColumnDataTypeHintEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseColumnDataTypeHintEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseColumnDataTypeHintEnum(input string) (*ColumnDataTypeHintEnum, error) { + vals := map[string]ColumnDataTypeHintEnum{ + "armpath": ColumnDataTypeHintEnumArmPath, + "guid": ColumnDataTypeHintEnumGuid, + "ip": ColumnDataTypeHintEnumIP, + "uri": ColumnDataTypeHintEnumUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ColumnDataTypeHintEnum(input) + return &out, nil +} + +type ColumnTypeEnum string + +const ( + ColumnTypeEnumBoolean ColumnTypeEnum = "boolean" + ColumnTypeEnumDateTime ColumnTypeEnum = "dateTime" + ColumnTypeEnumDynamic ColumnTypeEnum = "dynamic" + ColumnTypeEnumGuid ColumnTypeEnum = "guid" + ColumnTypeEnumInt ColumnTypeEnum = "int" + ColumnTypeEnumLong ColumnTypeEnum = "long" + ColumnTypeEnumReal ColumnTypeEnum = "real" + ColumnTypeEnumString ColumnTypeEnum = "string" +) + +func PossibleValuesForColumnTypeEnum() []string { + return []string{ + string(ColumnTypeEnumBoolean), + string(ColumnTypeEnumDateTime), + string(ColumnTypeEnumDynamic), + string(ColumnTypeEnumGuid), + string(ColumnTypeEnumInt), + string(ColumnTypeEnumLong), + string(ColumnTypeEnumReal), + string(ColumnTypeEnumString), + } +} + +func (s *ColumnTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseColumnTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseColumnTypeEnum(input string) (*ColumnTypeEnum, error) { + vals := map[string]ColumnTypeEnum{ + "boolean": ColumnTypeEnumBoolean, + "datetime": ColumnTypeEnumDateTime, + "dynamic": ColumnTypeEnumDynamic, + "guid": ColumnTypeEnumGuid, + "int": ColumnTypeEnumInt, + "long": ColumnTypeEnumLong, + "real": ColumnTypeEnumReal, + "string": ColumnTypeEnumString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ColumnTypeEnum(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" + ProvisioningStateEnumUpdating ProvisioningStateEnum = "Updating" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + string(ProvisioningStateEnumUpdating), + } +} + +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{ + "deleting": ProvisioningStateEnumDeleting, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + "updating": ProvisioningStateEnumUpdating, + } + 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 SourceEnum string + +const ( + SourceEnumCustomer SourceEnum = "customer" + SourceEnumMicrosoft SourceEnum = "microsoft" +) + +func PossibleValuesForSourceEnum() []string { + return []string{ + string(SourceEnumCustomer), + string(SourceEnumMicrosoft), + } +} + +func (s *SourceEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceEnum(input string) (*SourceEnum, error) { + vals := map[string]SourceEnum{ + "customer": SourceEnumCustomer, + "microsoft": SourceEnumMicrosoft, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceEnum(input) + return &out, nil +} + +type TablePlanEnum string + +const ( + TablePlanEnumAnalytics TablePlanEnum = "Analytics" + TablePlanEnumBasic TablePlanEnum = "Basic" +) + +func PossibleValuesForTablePlanEnum() []string { + return []string{ + string(TablePlanEnumAnalytics), + string(TablePlanEnumBasic), + } +} + +func (s *TablePlanEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTablePlanEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTablePlanEnum(input string) (*TablePlanEnum, error) { + vals := map[string]TablePlanEnum{ + "analytics": TablePlanEnumAnalytics, + "basic": TablePlanEnumBasic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TablePlanEnum(input) + return &out, nil +} + +type TableSubTypeEnum string + +const ( + TableSubTypeEnumAny TableSubTypeEnum = "Any" + TableSubTypeEnumClassic TableSubTypeEnum = "Classic" + TableSubTypeEnumDataCollectionRuleBased TableSubTypeEnum = "DataCollectionRuleBased" +) + +func PossibleValuesForTableSubTypeEnum() []string { + return []string{ + string(TableSubTypeEnumAny), + string(TableSubTypeEnumClassic), + string(TableSubTypeEnumDataCollectionRuleBased), + } +} + +func (s *TableSubTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTableSubTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTableSubTypeEnum(input string) (*TableSubTypeEnum, error) { + vals := map[string]TableSubTypeEnum{ + "any": TableSubTypeEnumAny, + "classic": TableSubTypeEnumClassic, + "datacollectionrulebased": TableSubTypeEnumDataCollectionRuleBased, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TableSubTypeEnum(input) + return &out, nil +} + +type TableTypeEnum string + +const ( + TableTypeEnumCustomLog TableTypeEnum = "CustomLog" + TableTypeEnumMicrosoft TableTypeEnum = "Microsoft" + TableTypeEnumRestoredLogs TableTypeEnum = "RestoredLogs" + TableTypeEnumSearchResults TableTypeEnum = "SearchResults" +) + +func PossibleValuesForTableTypeEnum() []string { + return []string{ + string(TableTypeEnumCustomLog), + string(TableTypeEnumMicrosoft), + string(TableTypeEnumRestoredLogs), + string(TableTypeEnumSearchResults), + } +} + +func (s *TableTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTableTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTableTypeEnum(input string) (*TableTypeEnum, error) { + vals := map[string]TableTypeEnum{ + "customlog": TableTypeEnumCustomLog, + "microsoft": TableTypeEnumMicrosoft, + "restoredlogs": TableTypeEnumRestoredLogs, + "searchresults": TableTypeEnumSearchResults, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TableTypeEnum(input) + return &out, nil +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_table.go b/resource-manager/operationalinsights/2023-09-01/tables/id_table.go new file mode 100644 index 00000000000..5dbc9e51d28 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_table.go @@ -0,0 +1,139 @@ +package tables + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TableId{}) +} + +var _ resourceids.ResourceId = &TableId{} + +// TableId is a struct representing the Resource ID for a Table +type TableId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + TableName string +} + +// NewTableID returns a new TableId struct +func NewTableID(subscriptionId string, resourceGroupName string, workspaceName string, tableName string) TableId { + return TableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + TableName: tableName, + } +} + +// ParseTableID parses 'input' into a TableId +func ParseTableID(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTableIDInsensitively parses 'input' case-insensitively into a TableId +// note: this method should only be used for API response data and not user input +func ParseTableIDInsensitively(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TableId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.TableName, ok = input.Parsed["tableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tableName", input) + } + + return nil +} + +// ValidateTableID checks that 'input' can be parsed as a Table ID +func ValidateTableID(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 := ParseTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Table ID +func (id TableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/tables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.TableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Table ID +func (id TableId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticTables", "tables", "tables"), + resourceids.UserSpecifiedSegment("tableName", "tableName"), + } +} + +// String returns a human-readable description of this Table ID +func (id TableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Table Name: %q", id.TableName), + } + return fmt.Sprintf("Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go b/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go new file mode 100644 index 00000000000..1cbf7d3ee33 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_table_test.go @@ -0,0 +1,327 @@ +package tables + +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 = &TableId{} + +func TestNewTableID(t *testing.T) { + id := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.TableName != "tableName" { + t.Fatalf("Expected %q but got %q for Segment 'TableName'", id.TableName, "tableName") + } +} + +func TestFormatTableID(t *testing.T) { + actual := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "tableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestParseTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/tables/tableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS/tAbLeNaMe", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + TableName: "tAbLeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/tAbLeS/tAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestSegmentsForTableId(t *testing.T) { + segments := TableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TableId 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/operationalinsights/2023-09-01/tables/id_workspace.go b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go new file mode 100644 index 00000000000..a7abfc487d3 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace.go @@ -0,0 +1,130 @@ +package tables + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(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 := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go new file mode 100644 index 00000000000..81bae7e5dab --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/id_workspace_test.go @@ -0,0 +1,282 @@ +package tables + +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 = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId 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/operationalinsights/2023-09-01/tables/method_cancelsearch.go b/resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go new file mode 100644 index 00000000000..5268e6542a7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_cancelsearch.go @@ -0,0 +1,47 @@ +package tables + +import ( + "context" + "fmt" + "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 CancelSearchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CancelSearch ... +func (c TablesClient) CancelSearch(ctx context.Context, id TableId) (result CancelSearchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelSearch", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go b/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go new file mode 100644 index 00000000000..9b7a84a5224 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_createorupdate.go @@ -0,0 +1,75 @@ +package tables + +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 + Model *Table +} + +// CreateOrUpdate ... +func (c TablesClient) CreateOrUpdate(ctx context.Context, id TableId, input Table) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 TablesClient) CreateOrUpdateThenPoll(ctx context.Context, id TableId, input Table) 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/operationalinsights/2023-09-01/tables/method_delete.go b/resource-manager/operationalinsights/2023-09-01/tables/method_delete.go new file mode 100644 index 00000000000..26e68dd6ed8 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_delete.go @@ -0,0 +1,71 @@ +package tables + +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 TablesClient) Delete(ctx context.Context, id TableId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 TablesClient) DeleteThenPoll(ctx context.Context, id TableId) 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/operationalinsights/2023-09-01/tables/method_get.go b/resource-manager/operationalinsights/2023-09-01/tables/method_get.go new file mode 100644 index 00000000000..6418a17d96d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_get.go @@ -0,0 +1,53 @@ +package tables + +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 *Table +} + +// Get ... +func (c TablesClient) Get(ctx context.Context, id TableId) (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 + } + + var model Table + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go b/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go new file mode 100644 index 00000000000..a22495c0a5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_listbyworkspace.go @@ -0,0 +1,54 @@ +package tables + +import ( + "context" + "fmt" + "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 ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TablesListResult +} + +// ListByWorkspace ... +func (c TablesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tables", 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 + } + + var model TablesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go b/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go new file mode 100644 index 00000000000..af5f8e9acd1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_migrate.go @@ -0,0 +1,47 @@ +package tables + +import ( + "context" + "fmt" + "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 MigrateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Migrate ... +func (c TablesClient) Migrate(ctx context.Context, id TableId) (result MigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrate", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/method_update.go b/resource-manager/operationalinsights/2023-09-01/tables/method_update.go new file mode 100644 index 00000000000..d863c869ec7 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/method_update.go @@ -0,0 +1,75 @@ +package tables + +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 + Model *Table +} + +// Update ... +func (c TablesClient) Update(ctx context.Context, id TableId, input Table) (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 TablesClient) UpdateThenPoll(ctx context.Context, id TableId, input Table) 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/operationalinsights/2023-09-01/tables/model_column.go b/resource-manager/operationalinsights/2023-09-01/tables/model_column.go new file mode 100644 index 00000000000..8ec13720b70 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_column.go @@ -0,0 +1,14 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Column struct { + DataTypeHint *ColumnDataTypeHintEnum `json:"dataTypeHint,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsDefaultDisplay *bool `json:"isDefaultDisplay,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + Name *string `json:"name,omitempty"` + Type *ColumnTypeEnum `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go b/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go new file mode 100644 index 00000000000..3d3bfc3f698 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_restoredlogs.go @@ -0,0 +1,41 @@ +package tables + +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 RestoredLogs struct { + AzureAsyncOperationId *string `json:"azureAsyncOperationId,omitempty"` + EndRestoreTime *string `json:"endRestoreTime,omitempty"` + SourceTable *string `json:"sourceTable,omitempty"` + StartRestoreTime *string `json:"startRestoreTime,omitempty"` +} + +func (o *RestoredLogs) GetEndRestoreTimeAsTime() (*time.Time, error) { + if o.EndRestoreTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndRestoreTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoredLogs) SetEndRestoreTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndRestoreTime = &formatted +} + +func (o *RestoredLogs) GetStartRestoreTimeAsTime() (*time.Time, error) { + if o.StartRestoreTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartRestoreTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoredLogs) SetStartRestoreTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartRestoreTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go b/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go new file mode 100644 index 00000000000..81582f6b191 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_resultstatistics.go @@ -0,0 +1,10 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResultStatistics struct { + IngestedRecords *int64 `json:"ingestedRecords,omitempty"` + Progress *float64 `json:"progress,omitempty"` + ScannedGb *float64 `json:"scannedGb,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go b/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go new file mode 100644 index 00000000000..13eb3820bd9 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_schema.go @@ -0,0 +1,18 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Schema struct { + Categories *[]string `json:"categories,omitempty"` + Columns *[]Column `json:"columns,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Labels *[]string `json:"labels,omitempty"` + Name *string `json:"name,omitempty"` + Solutions *[]string `json:"solutions,omitempty"` + Source *SourceEnum `json:"source,omitempty"` + StandardColumns *[]Column `json:"standardColumns,omitempty"` + TableSubType *TableSubTypeEnum `json:"tableSubType,omitempty"` + TableType *TableTypeEnum `json:"tableType,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go b/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go new file mode 100644 index 00000000000..8c11e8df14a --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_searchresults.go @@ -0,0 +1,44 @@ +package tables + +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 SearchResults struct { + AzureAsyncOperationId *string `json:"azureAsyncOperationId,omitempty"` + Description *string `json:"description,omitempty"` + EndSearchTime *string `json:"endSearchTime,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Query *string `json:"query,omitempty"` + SourceTable *string `json:"sourceTable,omitempty"` + StartSearchTime *string `json:"startSearchTime,omitempty"` +} + +func (o *SearchResults) GetEndSearchTimeAsTime() (*time.Time, error) { + if o.EndSearchTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndSearchTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchResults) SetEndSearchTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndSearchTime = &formatted +} + +func (o *SearchResults) GetStartSearchTimeAsTime() (*time.Time, error) { + if o.StartSearchTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartSearchTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchResults) SetStartSearchTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartSearchTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_table.go b/resource-manager/operationalinsights/2023-09-01/tables/model_table.go new file mode 100644 index 00000000000..b74a23702c4 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_table.go @@ -0,0 +1,16 @@ +package tables + +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 Table struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TableProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go b/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go new file mode 100644 index 00000000000..0b0714b4dac --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_tableproperties.go @@ -0,0 +1,19 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableProperties struct { + ArchiveRetentionInDays *int64 `json:"archiveRetentionInDays,omitempty"` + LastPlanModifiedDate *string `json:"lastPlanModifiedDate,omitempty"` + Plan *TablePlanEnum `json:"plan,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + RestoredLogs *RestoredLogs `json:"restoredLogs,omitempty"` + ResultStatistics *ResultStatistics `json:"resultStatistics,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + RetentionInDaysAsDefault *bool `json:"retentionInDaysAsDefault,omitempty"` + Schema *Schema `json:"schema,omitempty"` + SearchResults *SearchResults `json:"searchResults,omitempty"` + TotalRetentionInDays *int64 `json:"totalRetentionInDays,omitempty"` + TotalRetentionInDaysAsDefault *bool `json:"totalRetentionInDaysAsDefault,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go b/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go new file mode 100644 index 00000000000..06dec5265ef --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/model_tableslistresult.go @@ -0,0 +1,8 @@ +package tables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TablesListResult struct { + Value *[]Table `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/tables/version.go b/resource-manager/operationalinsights/2023-09-01/tables/version.go new file mode 100644 index 00000000000..e6d02624abf --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/tables/version.go @@ -0,0 +1,10 @@ +package tables + +// 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" + +func userAgent() string { + return "hashicorp/go-azure-sdk/tables/2023-09-01" +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/README.md b/resource-manager/operationalinsights/2023-09-01/workspaces/README.md index f98a6fbd379..8b165c1dea3 100644 --- a/resource-manager/operationalinsights/2023-09-01/workspaces/README.md +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/README.md @@ -50,6 +50,22 @@ if err := client.DeleteThenPoll(ctx, id, workspaces.DefaultDeleteOperationOption ``` +### Example Usage: `WorkspacesClient.GatewaysDelete` + +```go +ctx := context.TODO() +id := workspaces.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId") + +read, err := client.GatewaysDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.Get` ```go @@ -66,6 +82,54 @@ if model := read.Model; model != nil { ``` +### Example Usage: `WorkspacesClient.IntelligencePacksDisable` + +```go +ctx := context.TODO() +id := workspaces.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.IntelligencePacksDisable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.IntelligencePacksEnable` + +```go +ctx := context.TODO() +id := workspaces.NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + +read, err := client.IntelligencePacksEnable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.IntelligencePacksList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.IntelligencePacksList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.List` ```go @@ -98,6 +162,70 @@ if model := read.Model; model != nil { ``` +### Example Usage: `WorkspacesClient.ManagementGroupsList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ManagementGroupsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SchemaGet` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SchemaGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SharedKeysGetSharedKeys` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SharedKeysGetSharedKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.SharedKeysRegenerate` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.SharedKeysRegenerate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + ### Example Usage: `WorkspacesClient.Update` ```go @@ -117,3 +245,56 @@ if model := read.Model; model != nil { // do something with the model/response object } ``` + + +### Example Usage: `WorkspacesClient.UsagesList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.UsagesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.WorkspacePurgeGetPurgeStatus` + +```go +ctx := context.TODO() +id := workspaces.NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId") + +read, err := client.WorkspacePurgeGetPurgeStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.WorkspacePurgePurge` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspaces.WorkspacePurgeBody{ + // ... +} + + +read, err := client.WorkspacePurgePurge(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go b/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go index 220d049d398..f9a609da7dc 100644 --- a/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/constants.go @@ -135,6 +135,88 @@ func parsePublicNetworkAccessType(input string) (*PublicNetworkAccessType, error return &out, nil } +type PurgeState string + +const ( + PurgeStateCompleted PurgeState = "completed" + PurgeStatePending PurgeState = "pending" +) + +func PossibleValuesForPurgeState() []string { + return []string{ + string(PurgeStateCompleted), + string(PurgeStatePending), + } +} + +func (s *PurgeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePurgeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePurgeState(input string) (*PurgeState, error) { + vals := map[string]PurgeState{ + "completed": PurgeStateCompleted, + "pending": PurgeStatePending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PurgeState(input) + return &out, nil +} + +type SearchSortEnum string + +const ( + SearchSortEnumAsc SearchSortEnum = "asc" + SearchSortEnumDesc SearchSortEnum = "desc" +) + +func PossibleValuesForSearchSortEnum() []string { + return []string{ + string(SearchSortEnumAsc), + string(SearchSortEnumDesc), + } +} + +func (s *SearchSortEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchSortEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchSortEnum(input string) (*SearchSortEnum, error) { + vals := map[string]SearchSortEnum{ + "asc": SearchSortEnumAsc, + "desc": SearchSortEnumDesc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchSortEnum(input) + return &out, nil +} + type WorkspaceEntityStatus string const ( diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go new file mode 100644 index 00000000000..ca187d0ee65 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway.go @@ -0,0 +1,139 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&GatewayId{}) +} + +var _ resourceids.ResourceId = &GatewayId{} + +// GatewayId is a struct representing the Resource ID for a Gateway +type GatewayId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + GatewayId string +} + +// NewGatewayID returns a new GatewayId struct +func NewGatewayID(subscriptionId string, resourceGroupName string, workspaceName string, gatewayId string) GatewayId { + return GatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + GatewayId: gatewayId, + } +} + +// ParseGatewayID parses 'input' into a GatewayId +func ParseGatewayID(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGatewayIDInsensitively parses 'input' case-insensitively into a GatewayId +// note: this method should only be used for API response data and not user input +func ParseGatewayIDInsensitively(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GatewayId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.GatewayId, ok = input.Parsed["gatewayId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayId", input) + } + + return nil +} + +// ValidateGatewayID checks that 'input' can be parsed as a Gateway ID +func ValidateGatewayID(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 := ParseGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gateway ID +func (id GatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.GatewayId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gateway ID +func (id GatewayId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayId", "gatewayId"), + } +} + +// String returns a human-readable description of this Gateway ID +func (id GatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Gateway: %q", id.GatewayId), + } + return fmt.Sprintf("Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go new file mode 100644 index 00000000000..f74a41b0227 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_gateway_test.go @@ -0,0 +1,327 @@ +package workspaces + +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 = &GatewayId{} + +func TestNewGatewayID(t *testing.T) { + id := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.GatewayId != "gatewayId" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayId'", id.GatewayId, "gatewayId") + } +} + +func TestFormatGatewayID(t *testing.T) { + actual := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "gatewayId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + GatewayId: "gatewayId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GatewayId != v.Expected.GatewayId { + t.Fatalf("Expected %q but got %q for GatewayId", v.Expected.GatewayId, actual.GatewayId) + } + + } +} + +func TestParseGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + GatewayId: "gatewayId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/gateways/gatewayId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS/gAtEwAyId", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + GatewayId: "gAtEwAyId", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/gAtEwAyS/gAtEwAyId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GatewayId != v.Expected.GatewayId { + t.Fatalf("Expected %q but got %q for GatewayId", v.Expected.GatewayId, actual.GatewayId) + } + + } +} + +func TestSegmentsForGatewayId(t *testing.T) { + segments := GatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GatewayId 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/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go new file mode 100644 index 00000000000..5a01f4d44e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack.go @@ -0,0 +1,139 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&IntelligencePackId{}) +} + +var _ resourceids.ResourceId = &IntelligencePackId{} + +// IntelligencePackId is a struct representing the Resource ID for a Intelligence Pack +type IntelligencePackId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IntelligencePackName string +} + +// NewIntelligencePackID returns a new IntelligencePackId struct +func NewIntelligencePackID(subscriptionId string, resourceGroupName string, workspaceName string, intelligencePackName string) IntelligencePackId { + return IntelligencePackId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IntelligencePackName: intelligencePackName, + } +} + +// ParseIntelligencePackID parses 'input' into a IntelligencePackId +func ParseIntelligencePackID(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIntelligencePackIDInsensitively parses 'input' case-insensitively into a IntelligencePackId +// note: this method should only be used for API response data and not user input +func ParseIntelligencePackIDInsensitively(input string) (*IntelligencePackId, error) { + parser := resourceids.NewParserFromResourceIdType(&IntelligencePackId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IntelligencePackId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IntelligencePackId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.IntelligencePackName, ok = input.Parsed["intelligencePackName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "intelligencePackName", input) + } + + return nil +} + +// ValidateIntelligencePackID checks that 'input' can be parsed as a Intelligence Pack ID +func ValidateIntelligencePackID(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 := ParseIntelligencePackID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Intelligence Pack ID +func (id IntelligencePackId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/intelligencePacks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IntelligencePackName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Intelligence Pack ID +func (id IntelligencePackId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticIntelligencePacks", "intelligencePacks", "intelligencePacks"), + resourceids.UserSpecifiedSegment("intelligencePackName", "intelligencePackName"), + } +} + +// String returns a human-readable description of this Intelligence Pack ID +func (id IntelligencePackId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Intelligence Pack Name: %q", id.IntelligencePackName), + } + return fmt.Sprintf("Intelligence Pack (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go new file mode 100644 index 00000000000..12c700c9652 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_intelligencepack_test.go @@ -0,0 +1,327 @@ +package workspaces + +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 = &IntelligencePackId{} + +func TestNewIntelligencePackID(t *testing.T) { + id := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.IntelligencePackName != "intelligencePackName" { + t.Fatalf("Expected %q but got %q for Segment 'IntelligencePackName'", id.IntelligencePackName, "intelligencePackName") + } +} + +func TestFormatIntelligencePackID(t *testing.T) { + actual := NewIntelligencePackID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "intelligencePackName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIntelligencePackID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestParseIntelligencePackIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IntelligencePackId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + IntelligencePackName: "intelligencePackName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/intelligencePacks/intelligencePackName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE", + Expected: &IntelligencePackId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + IntelligencePackName: "iNtElLiGeNcEpAcKnAmE", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/iNtElLiGeNcEpAcKs/iNtElLiGeNcEpAcKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIntelligencePackIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IntelligencePackName != v.Expected.IntelligencePackName { + t.Fatalf("Expected %q but got %q for IntelligencePackName", v.Expected.IntelligencePackName, actual.IntelligencePackName) + } + + } +} + +func TestSegmentsForIntelligencePackId(t *testing.T) { + segments := IntelligencePackId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IntelligencePackId 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/operationalinsights/2023-09-01/workspaces/id_operation.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go new file mode 100644 index 00000000000..4a9ea94f6bb --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation.go @@ -0,0 +1,139 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&OperationId{}) +} + +var _ resourceids.ResourceId = &OperationId{} + +// OperationId is a struct representing the Resource ID for a Operation +type OperationId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PurgeId string +} + +// NewOperationID returns a new OperationId struct +func NewOperationID(subscriptionId string, resourceGroupName string, workspaceName string, purgeId string) OperationId { + return OperationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PurgeId: purgeId, + } +} + +// ParseOperationID parses 'input' into a OperationId +func ParseOperationID(input string) (*OperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOperationIDInsensitively parses 'input' case-insensitively into a OperationId +// note: this method should only be used for API response data and not user input +func ParseOperationIDInsensitively(input string) (*OperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OperationId) 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PurgeId, ok = input.Parsed["purgeId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "purgeId", input) + } + + return nil +} + +// ValidateOperationID checks that 'input' can be parsed as a Operation ID +func ValidateOperationID(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 := ParseOperationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Operation ID +func (id OperationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.OperationalInsights/workspaces/%s/operations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.PurgeId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Operation ID +func (id OperationId) 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("staticMicrosoftOperationalInsights", "Microsoft.OperationalInsights", "Microsoft.OperationalInsights"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOperations", "operations", "operations"), + resourceids.UserSpecifiedSegment("purgeId", "purgeId"), + } +} + +// String returns a human-readable description of this Operation ID +func (id OperationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Purge: %q", id.PurgeId), + } + return fmt.Sprintf("Operation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go new file mode 100644 index 00000000000..17ff4a0877f --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/id_operation_test.go @@ -0,0 +1,327 @@ +package workspaces + +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 = &OperationId{} + +func TestNewOperationID(t *testing.T) { + id := NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId") + + 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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.PurgeId != "purgeId" { + t.Fatalf("Expected %q but got %q for Segment 'PurgeId'", id.PurgeId, "purgeId") + } +} + +func TestFormatOperationID(t *testing.T) { + actual := NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "purgeId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOperationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PurgeId: "purgeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationID(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PurgeId != v.Expected.PurgeId { + t.Fatalf("Expected %q but got %q for PurgeId", v.Expected.PurgeId, actual.PurgeId) + } + + } +} + +func TestParseOperationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationId + }{ + { + // 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.OperationalInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PurgeId: "purgeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName/operations/purgeId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS/pUrGeId", + Expected: &OperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + PurgeId: "pUrGeId", + }, + }, + { + // 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.oPeRaTiOnAlInSiGhTs/wOrKsPaCeS/wOrKsPaCeNaMe/oPeRaTiOnS/pUrGeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationIDInsensitively(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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PurgeId != v.Expected.PurgeId { + t.Fatalf("Expected %q but got %q for PurgeId", v.Expected.PurgeId, actual.PurgeId) + } + + } +} + +func TestSegmentsForOperationId(t *testing.T) { + segments := OperationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OperationId 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/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go new file mode 100644 index 00000000000..2566a120d43 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_gatewaysdelete.go @@ -0,0 +1,46 @@ +package workspaces + +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 GatewaysDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GatewaysDelete ... +func (c WorkspacesClient) GatewaysDelete(ctx context.Context, id GatewayId) (result GatewaysDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go new file mode 100644 index 00000000000..ebf2ccdc377 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksdisable.go @@ -0,0 +1,47 @@ +package workspaces + +import ( + "context" + "fmt" + "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 IntelligencePacksDisableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// IntelligencePacksDisable ... +func (c WorkspacesClient) IntelligencePacksDisable(ctx context.Context, id IntelligencePackId) (result IntelligencePacksDisableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go new file mode 100644 index 00000000000..b28e1309455 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepacksenable.go @@ -0,0 +1,47 @@ +package workspaces + +import ( + "context" + "fmt" + "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 IntelligencePacksEnableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// IntelligencePacksEnable ... +func (c WorkspacesClient) IntelligencePacksEnable(ctx context.Context, id IntelligencePackId) (result IntelligencePacksEnableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/enable", 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 + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go new file mode 100644 index 00000000000..1e92df537ca --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_intelligencepackslist.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 IntelligencePacksListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IntelligencePack +} + +// IntelligencePacksList ... +func (c WorkspacesClient) IntelligencePacksList(ctx context.Context, id WorkspaceId) (result IntelligencePacksListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/intelligencePacks", 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 + } + + var model []IntelligencePack + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go new file mode 100644 index 00000000000..596c5d1dab1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_managementgroupslist.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 ManagementGroupsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceListManagementGroupsResult +} + +// ManagementGroupsList ... +func (c WorkspacesClient) ManagementGroupsList(ctx context.Context, id WorkspaceId) (result ManagementGroupsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managementGroups", 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 + } + + var model WorkspaceListManagementGroupsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go new file mode 100644 index 00000000000..eb7127f39af --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_schemaget.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 SchemaGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SearchGetSchemaResponse +} + +// SchemaGet ... +func (c WorkspacesClient) SchemaGet(ctx context.Context, id WorkspaceId) (result SchemaGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/schema", 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 + } + + var model SearchGetSchemaResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go new file mode 100644 index 00000000000..91f8d2b6d41 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysgetsharedkeys.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 SharedKeysGetSharedKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedKeys +} + +// SharedKeysGetSharedKeys ... +func (c WorkspacesClient) SharedKeysGetSharedKeys(ctx context.Context, id WorkspaceId) (result SharedKeysGetSharedKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sharedKeys", 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 + } + + var model SharedKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go new file mode 100644 index 00000000000..df4473f5007 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_sharedkeysregenerate.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 SharedKeysRegenerateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedKeys +} + +// SharedKeysRegenerate ... +func (c WorkspacesClient) SharedKeysRegenerate(ctx context.Context, id WorkspaceId) (result SharedKeysRegenerateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSharedKey", 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 + } + + var model SharedKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go new file mode 100644 index 00000000000..16742cf7284 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_usageslist.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "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 UsagesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceListUsagesResult +} + +// UsagesList ... +func (c WorkspacesClient) UsagesList(ctx context.Context, id WorkspaceId) (result UsagesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", 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 + } + + var model WorkspaceListUsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go new file mode 100644 index 00000000000..223c603de91 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgegetpurgestatus.go @@ -0,0 +1,53 @@ +package workspaces + +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 WorkspacePurgeGetPurgeStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspacePurgeStatusResponse +} + +// WorkspacePurgeGetPurgeStatus ... +func (c WorkspacesClient) WorkspacePurgeGetPurgeStatus(ctx context.Context, id OperationId) (result WorkspacePurgeGetPurgeStatusOperationResponse, 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 + } + + var model WorkspacePurgeStatusResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go new file mode 100644 index 00000000000..2899a83661e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/method_workspacepurgepurge.go @@ -0,0 +1,58 @@ +package workspaces + +import ( + "context" + "fmt" + "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 WorkspacePurgePurgeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspacePurgeResponse +} + +// WorkspacePurgePurge ... +func (c WorkspacesClient) WorkspacePurgePurge(ctx context.Context, id WorkspaceId, input WorkspacePurgeBody) (result WorkspacePurgePurgeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/purge", 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 + } + + var model WorkspacePurgeResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go new file mode 100644 index 00000000000..df29cb10b50 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_coresummary.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CoreSummary struct { + NumberOfDocuments int64 `json:"numberOfDocuments"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go new file mode 100644 index 00000000000..813f158bed6 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_intelligencepack.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IntelligencePack struct { + DisplayName *string `json:"displayName,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go new file mode 100644 index 00000000000..dcb938c5793 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroup.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroup struct { + Properties *ManagementGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go new file mode 100644 index 00000000000..3d1b0b13e6e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_managementgroupproperties.go @@ -0,0 +1,45 @@ +package workspaces + +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 ManagementGroupProperties struct { + Created *string `json:"created,omitempty"` + DataReceived *string `json:"dataReceived,omitempty"` + Id *string `json:"id,omitempty"` + IsGateway *bool `json:"isGateway,omitempty"` + Name *string `json:"name,omitempty"` + ServerCount *int64 `json:"serverCount,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ManagementGroupProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagementGroupProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} + +func (o *ManagementGroupProperties) GetDataReceivedAsTime() (*time.Time, error) { + if o.DataReceived == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataReceived, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagementGroupProperties) SetDataReceivedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataReceived = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go new file mode 100644 index 00000000000..f33cbbc5f5e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_metricname.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go new file mode 100644 index 00000000000..5cdb4d9f35d --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchgetschemaresponse.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchGetSchemaResponse struct { + Metadata *SearchMetadata `json:"metadata,omitempty"` + Value *[]SearchSchemaValue `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go new file mode 100644 index 00000000000..0929b2438d0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadata.go @@ -0,0 +1,54 @@ +package workspaces + +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 SearchMetadata struct { + AggregatedGroupingFields *string `json:"aggregatedGroupingFields,omitempty"` + AggregatedValueField *string `json:"aggregatedValueField,omitempty"` + CoreSummaries *[]CoreSummary `json:"coreSummaries,omitempty"` + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + Max *int64 `json:"max,omitempty"` + RequestId *string `json:"requestId,omitempty"` + RequestTime *int64 `json:"requestTime,omitempty"` + ResultType *string `json:"resultType,omitempty"` + Schema *SearchMetadataSchema `json:"schema,omitempty"` + Sort *[]SearchSort `json:"sort,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + Sum *int64 `json:"sum,omitempty"` + Top *int64 `json:"top,omitempty"` + Total *int64 `json:"total,omitempty"` +} + +func (o *SearchMetadata) GetLastUpdatedAsTime() (*time.Time, error) { + if o.LastUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchMetadata) SetLastUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdated = &formatted +} + +func (o *SearchMetadata) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SearchMetadata) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go new file mode 100644 index 00000000000..0e39da0d0e0 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchmetadataschema.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchMetadataSchema struct { + Name *string `json:"name,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go new file mode 100644 index 00000000000..86826b00b37 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchschemavalue.go @@ -0,0 +1,14 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchSchemaValue struct { + DisplayName *string `json:"displayName,omitempty"` + Facet bool `json:"facet"` + Indexed bool `json:"indexed"` + Name *string `json:"name,omitempty"` + OwnerType *[]string `json:"ownerType,omitempty"` + Stored bool `json:"stored"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go new file mode 100644 index 00000000000..a7740dc9365 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_searchsort.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchSort struct { + Name *string `json:"name,omitempty"` + Order *SearchSortEnum `json:"order,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go new file mode 100644 index 00000000000..c11550ea99e --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_sharedkeys.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedKeys struct { + PrimarySharedKey *string `json:"primarySharedKey,omitempty"` + SecondarySharedKey *string `json:"secondarySharedKey,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go new file mode 100644 index 00000000000..c2fb1de1937 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_usagemetric.go @@ -0,0 +1,31 @@ +package workspaces + +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 UsageMetric struct { + CurrentValue *float64 `json:"currentValue,omitempty"` + Limit *float64 `json:"limit,omitempty"` + Name *MetricName `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *UsageMetric) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsageMetric) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go new file mode 100644 index 00000000000..101e18a9b88 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistmanagementgroupsresult.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceListManagementGroupsResult struct { + Value *[]ManagementGroup `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go new file mode 100644 index 00000000000..2a0beb349b1 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacelistusagesresult.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceListUsagesResult struct { + Value *[]UsageMetric `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go new file mode 100644 index 00000000000..338b9dd175c --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebody.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeBody struct { + Filters []WorkspacePurgeBodyFilters `json:"filters"` + Table string `json:"table"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go new file mode 100644 index 00000000000..a9cded5abc2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgebodyfilters.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeBodyFilters struct { + Column *string `json:"column,omitempty"` + Key *string `json:"key,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go new file mode 100644 index 00000000000..0187a62e139 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgeresponse.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeResponse struct { + OperationId string `json:"operationId"` +} diff --git a/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go new file mode 100644 index 00000000000..b4c34494dc2 --- /dev/null +++ b/resource-manager/operationalinsights/2023-09-01/workspaces/model_workspacepurgestatusresponse.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePurgeStatusResponse struct { + Status PurgeState `json:"status"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go index 901e37d3b14..7be031b5131 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasecharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go index 075fdf79954..f55ed168e3f 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go @@ -4,5 +4,5 @@ package autonomousdatabasenationalcharactersets // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type AutonomousDatabaseNationalCharacterSetProperties struct { - CharacterSet *string `json:"characterSet,omitempty"` + CharacterSet string `json:"characterSet"` } diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go index 0a7cad672e7..a3d0639949b 100644 --- a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go @@ -9,5 +9,5 @@ type AutonomousDbVersionProperties struct { IsDefaultForPaid *bool `json:"isDefaultForPaid,omitempty"` IsFreeTierEnabled *bool `json:"isFreeTierEnabled,omitempty"` IsPaidEnabled *bool `json:"isPaidEnabled,omitempty"` - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go index 57c6546805b..f8ed526badb 100644 --- a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go @@ -17,34 +17,31 @@ type DbNodeProperties struct { CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` DbServerId *string `json:"dbServerId,omitempty"` - DbSystemId *string `json:"dbSystemId,omitempty"` + DbSystemId string `json:"dbSystemId"` FaultDomain *string `json:"faultDomain,omitempty"` HostIPId *string `json:"hostIpId,omitempty"` Hostname *string `json:"hostname,omitempty"` LifecycleDetails *string `json:"lifecycleDetails,omitempty"` - LifecycleState *DbNodeProvisioningState `json:"lifecycleState,omitempty"` + LifecycleState DbNodeProvisioningState `json:"lifecycleState"` MaintenanceType *DbNodeMaintenanceType `json:"maintenanceType,omitempty"` MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` - Ocid *string `json:"ocid,omitempty"` + Ocid string `json:"ocid"` ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` SoftwareStorageSizeInGb *int64 `json:"softwareStorageSizeInGb,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` + TimeCreated string `json:"timeCreated"` TimeMaintenanceWindowEnd *string `json:"timeMaintenanceWindowEnd,omitempty"` TimeMaintenanceWindowStart *string `json:"timeMaintenanceWindowStart,omitempty"` Vnic2Id *string `json:"vnic2Id,omitempty"` - VnicId *string `json:"vnicId,omitempty"` + VnicId string `json:"vnicId"` } func (o *DbNodeProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DbNodeProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DbNodeProperties) GetTimeMaintenanceWindowEndAsTime() (*time.Time, error) { diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go index a7642317091..126cec39c37 100644 --- a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go @@ -4,7 +4,7 @@ package dbsystemshapes // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DbSystemShapeProperties struct { - AvailableCoreCount *int64 `json:"availableCoreCount,omitempty"` + AvailableCoreCount int64 `json:"availableCoreCount"` AvailableCoreCountPerNode *int64 `json:"availableCoreCountPerNode,omitempty"` AvailableDataStorageInTbs *int64 `json:"availableDataStorageInTbs,omitempty"` AvailableDataStoragePerServerInTbs *float64 `json:"availableDataStoragePerServerInTbs,omitempty"` diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go index 40cd3cf0a93..6f06446ebce 100644 --- a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go @@ -10,36 +10,30 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateViewProperties struct { - DisplayName *string `json:"displayName,omitempty"` - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateViewsLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - TimeUpdated *string `json:"timeUpdated,omitempty"` + DisplayName string `json:"displayName"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateViewsLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + TimeCreated string `json:"timeCreated"` + TimeUpdated string `json:"timeUpdated"` } func (o *DnsPrivateViewProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } func (o *DnsPrivateViewProperties) GetTimeUpdatedAsTime() (*time.Time, error) { - if o.TimeUpdated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeUpdated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeUpdated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateViewProperties) SetTimeUpdatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeUpdated = &formatted + o.TimeUpdated = formatted } diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go index 680bff102fe..5c84986be86 100644 --- a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go @@ -10,26 +10,23 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DnsPrivateZoneProperties struct { - IsProtected *bool `json:"isProtected,omitempty"` - LifecycleState *DnsPrivateZonesLifecycleState `json:"lifecycleState,omitempty"` - Ocid *string `json:"ocid,omitempty"` - ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` - Self *string `json:"self,omitempty"` - Serial *int64 `json:"serial,omitempty"` - TimeCreated *string `json:"timeCreated,omitempty"` - Version *string `json:"version,omitempty"` - ViewId *string `json:"viewId,omitempty"` - ZoneType *ZoneType `json:"zoneType,omitempty"` + IsProtected bool `json:"isProtected"` + LifecycleState DnsPrivateZonesLifecycleState `json:"lifecycleState"` + Ocid string `json:"ocid"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self string `json:"self"` + Serial int64 `json:"serial"` + TimeCreated string `json:"timeCreated"` + Version string `json:"version"` + ViewId *string `json:"viewId,omitempty"` + ZoneType ZoneType `json:"zoneType"` } func (o *DnsPrivateZoneProperties) GetTimeCreatedAsTime() (*time.Time, error) { - if o.TimeCreated == nil { - return nil, nil - } - return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") + return dates.ParseAsFormat(&o.TimeCreated, "2006-01-02T15:04:05Z07:00") } func (o *DnsPrivateZoneProperties) SetTimeCreatedAsTime(input time.Time) { formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.TimeCreated = &formatted + o.TimeCreated = formatted } diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go index ca86e602826..0a54f3aaee2 100644 --- a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go @@ -4,5 +4,5 @@ package giversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type GiVersionProperties struct { - Version *string `json:"version,omitempty"` + Version string `json:"version"` } diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go index 5eda0476133..2684d8672ad 100644 --- a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go @@ -4,5 +4,5 @@ package systemversions // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type SystemVersionProperties struct { - SystemVersion *string `json:"systemVersion,omitempty"` + SystemVersion string `json:"systemVersion"` } diff --git a/resource-manager/policyinsights/2024-10-01/attestations/README.md b/resource-manager/policyinsights/2024-10-01/attestations/README.md new file mode 100644 index 00000000000..d2a890bbcf4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/README.md @@ -0,0 +1,219 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/attestations` Documentation + +The `attestations` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/attestations" +``` + + +### Client Initialization + +```go +client := attestations.NewAttestationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AttestationsClient.CreateOrUpdateAtResource` + +```go +ctx := context.TODO() +id := attestations.NewScopedAttestationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "attestationName") + +payload := attestations.Attestation{ + // ... +} + + +if err := client.CreateOrUpdateAtResourceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttestationsClient.CreateOrUpdateAtResourceGroup` + +```go +ctx := context.TODO() +id := attestations.NewProviderAttestationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "attestationName") + +payload := attestations.Attestation{ + // ... +} + + +if err := client.CreateOrUpdateAtResourceGroupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttestationsClient.CreateOrUpdateAtSubscription` + +```go +ctx := context.TODO() +id := attestations.NewAttestationID("12345678-1234-9876-4563-123456789012", "attestationName") + +payload := attestations.Attestation{ + // ... +} + + +if err := client.CreateOrUpdateAtSubscriptionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttestationsClient.DeleteAtResource` + +```go +ctx := context.TODO() +id := attestations.NewScopedAttestationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "attestationName") + +read, err := client.DeleteAtResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.DeleteAtResourceGroup` + +```go +ctx := context.TODO() +id := attestations.NewProviderAttestationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "attestationName") + +read, err := client.DeleteAtResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.DeleteAtSubscription` + +```go +ctx := context.TODO() +id := attestations.NewAttestationID("12345678-1234-9876-4563-123456789012", "attestationName") + +read, err := client.DeleteAtSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.GetAtResource` + +```go +ctx := context.TODO() +id := attestations.NewScopedAttestationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "attestationName") + +read, err := client.GetAtResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.GetAtResourceGroup` + +```go +ctx := context.TODO() +id := attestations.NewProviderAttestationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "attestationName") + +read, err := client.GetAtResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.GetAtSubscription` + +```go +ctx := context.TODO() +id := attestations.NewAttestationID("12345678-1234-9876-4563-123456789012", "attestationName") + +read, err := client.GetAtSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttestationsClient.ListForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListForResource(ctx, id, attestations.DefaultListForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceComplete(ctx, id, attestations.DefaultListForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AttestationsClient.ListForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListForResourceGroup(ctx, id, attestations.DefaultListForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceGroupComplete(ctx, id, attestations.DefaultListForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AttestationsClient.ListForSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListForSubscription(ctx, id, attestations.DefaultListForSubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListForSubscriptionComplete(ctx, id, attestations.DefaultListForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/attestations/client.go b/resource-manager/policyinsights/2024-10-01/attestations/client.go new file mode 100644 index 00000000000..f9da7ffb8bf --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/client.go @@ -0,0 +1,26 @@ +package attestations + +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 AttestationsClient struct { + Client *resourcemanager.Client +} + +func NewAttestationsClientWithBaseURI(sdkApi sdkEnv.Api) (*AttestationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "attestations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AttestationsClient: %+v", err) + } + + return &AttestationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/constants.go b/resource-manager/policyinsights/2024-10-01/attestations/constants.go new file mode 100644 index 00000000000..bde19363f6e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/constants.go @@ -0,0 +1,54 @@ +package attestations + +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 ComplianceState string + +const ( + ComplianceStateCompliant ComplianceState = "Compliant" + ComplianceStateNonCompliant ComplianceState = "NonCompliant" + ComplianceStateUnknown ComplianceState = "Unknown" +) + +func PossibleValuesForComplianceState() []string { + return []string{ + string(ComplianceStateCompliant), + string(ComplianceStateNonCompliant), + string(ComplianceStateUnknown), + } +} + +func (s *ComplianceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComplianceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComplianceState(input string) (*ComplianceState, error) { + vals := map[string]ComplianceState{ + "compliant": ComplianceStateCompliant, + "noncompliant": ComplianceStateNonCompliant, + "unknown": ComplianceStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComplianceState(input) + return &out, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/id_attestation.go b/resource-manager/policyinsights/2024-10-01/attestations/id_attestation.go new file mode 100644 index 00000000000..e28668a046d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_attestation.go @@ -0,0 +1,121 @@ +package attestations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AttestationId{}) +} + +var _ resourceids.ResourceId = &AttestationId{} + +// AttestationId is a struct representing the Resource ID for a Attestation +type AttestationId struct { + SubscriptionId string + AttestationName string +} + +// NewAttestationID returns a new AttestationId struct +func NewAttestationID(subscriptionId string, attestationName string) AttestationId { + return AttestationId{ + SubscriptionId: subscriptionId, + AttestationName: attestationName, + } +} + +// ParseAttestationID parses 'input' into a AttestationId +func ParseAttestationID(input string) (*AttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttestationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAttestationIDInsensitively parses 'input' case-insensitively into a AttestationId +// note: this method should only be used for API response data and not user input +func ParseAttestationIDInsensitively(input string) (*AttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttestationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AttestationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.AttestationName, ok = input.Parsed["attestationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "attestationName", input) + } + + return nil +} + +// ValidateAttestationID checks that 'input' can be parsed as a Attestation ID +func ValidateAttestationID(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 := ParseAttestationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Attestation ID +func (id AttestationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.PolicyInsights/attestations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.AttestationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Attestation ID +func (id AttestationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticAttestations", "attestations", "attestations"), + resourceids.UserSpecifiedSegment("attestationName", "attestationName"), + } +} + +// String returns a human-readable description of this Attestation ID +func (id AttestationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Attestation Name: %q", id.AttestationName), + } + return fmt.Sprintf("Attestation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/id_attestation_test.go b/resource-manager/policyinsights/2024-10-01/attestations/id_attestation_test.go new file mode 100644 index 00000000000..cc92f5881d1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_attestation_test.go @@ -0,0 +1,237 @@ +package attestations + +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 = &AttestationId{} + +func TestNewAttestationID(t *testing.T) { + id := NewAttestationID("12345678-1234-9876-4563-123456789012", "attestationName") + + 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.AttestationName != "attestationName" { + t.Fatalf("Expected %q but got %q for Segment 'AttestationName'", id.AttestationName, "attestationName") + } +} + +func TestFormatAttestationID(t *testing.T) { + actual := NewAttestationID("12345678-1234-9876-4563-123456789012", "attestationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations/attestationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAttestationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttestationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &AttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttestationID(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.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestParseAttestationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttestationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &AttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe", + Expected: &AttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AttestationName: "aTtEsTaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttestationIDInsensitively(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.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestSegmentsForAttestationId(t *testing.T) { + segments := AttestationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AttestationId 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/policyinsights/2024-10-01/attestations/id_providerattestation.go b/resource-manager/policyinsights/2024-10-01/attestations/id_providerattestation.go new file mode 100644 index 00000000000..6d546a8cdfc --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_providerattestation.go @@ -0,0 +1,130 @@ +package attestations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderAttestationId{}) +} + +var _ resourceids.ResourceId = &ProviderAttestationId{} + +// ProviderAttestationId is a struct representing the Resource ID for a Provider Attestation +type ProviderAttestationId struct { + SubscriptionId string + ResourceGroupName string + AttestationName string +} + +// NewProviderAttestationID returns a new ProviderAttestationId struct +func NewProviderAttestationID(subscriptionId string, resourceGroupName string, attestationName string) ProviderAttestationId { + return ProviderAttestationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AttestationName: attestationName, + } +} + +// ParseProviderAttestationID parses 'input' into a ProviderAttestationId +func ParseProviderAttestationID(input string) (*ProviderAttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderAttestationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderAttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderAttestationIDInsensitively parses 'input' case-insensitively into a ProviderAttestationId +// note: this method should only be used for API response data and not user input +func ParseProviderAttestationIDInsensitively(input string) (*ProviderAttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderAttestationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderAttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderAttestationId) 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.AttestationName, ok = input.Parsed["attestationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "attestationName", input) + } + + return nil +} + +// ValidateProviderAttestationID checks that 'input' can be parsed as a Provider Attestation ID +func ValidateProviderAttestationID(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 := ParseProviderAttestationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Attestation ID +func (id ProviderAttestationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.PolicyInsights/attestations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AttestationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Attestation ID +func (id ProviderAttestationId) 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("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticAttestations", "attestations", "attestations"), + resourceids.UserSpecifiedSegment("attestationName", "attestationName"), + } +} + +// String returns a human-readable description of this Provider Attestation ID +func (id ProviderAttestationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Attestation Name: %q", id.AttestationName), + } + return fmt.Sprintf("Provider Attestation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/id_providerattestation_test.go b/resource-manager/policyinsights/2024-10-01/attestations/id_providerattestation_test.go new file mode 100644 index 00000000000..0fa1fbdc911 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_providerattestation_test.go @@ -0,0 +1,282 @@ +package attestations + +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 = &ProviderAttestationId{} + +func TestNewProviderAttestationID(t *testing.T) { + id := NewProviderAttestationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "attestationName") + + 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.AttestationName != "attestationName" { + t.Fatalf("Expected %q but got %q for Segment 'AttestationName'", id.AttestationName, "attestationName") + } +} + +func TestFormatProviderAttestationID(t *testing.T) { + actual := NewProviderAttestationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "attestationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderAttestationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderAttestationId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &ProviderAttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderAttestationID(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.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestParseProviderAttestationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderAttestationId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &ProviderAttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe", + Expected: &ProviderAttestationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AttestationName: "aTtEsTaTiOnNaMe", + }, + }, + { + // 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.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderAttestationIDInsensitively(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.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestSegmentsForProviderAttestationId(t *testing.T) { + segments := ProviderAttestationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderAttestationId 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/policyinsights/2024-10-01/attestations/id_scopedattestation.go b/resource-manager/policyinsights/2024-10-01/attestations/id_scopedattestation.go new file mode 100644 index 00000000000..de3125e6e34 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_scopedattestation.go @@ -0,0 +1,120 @@ +package attestations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ScopedAttestationId{}) +} + +var _ resourceids.ResourceId = &ScopedAttestationId{} + +// ScopedAttestationId is a struct representing the Resource ID for a Scoped Attestation +type ScopedAttestationId struct { + ResourceId string + AttestationName string +} + +// NewScopedAttestationID returns a new ScopedAttestationId struct +func NewScopedAttestationID(resourceId string, attestationName string) ScopedAttestationId { + return ScopedAttestationId{ + ResourceId: resourceId, + AttestationName: attestationName, + } +} + +// ParseScopedAttestationID parses 'input' into a ScopedAttestationId +func ParseScopedAttestationID(input string) (*ScopedAttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedAttestationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedAttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopedAttestationIDInsensitively parses 'input' case-insensitively into a ScopedAttestationId +// note: this method should only be used for API response data and not user input +func ParseScopedAttestationIDInsensitively(input string) (*ScopedAttestationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedAttestationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedAttestationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopedAttestationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ResourceId, ok = input.Parsed["resourceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceId", input) + } + + if id.AttestationName, ok = input.Parsed["attestationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "attestationName", input) + } + + return nil +} + +// ValidateScopedAttestationID checks that 'input' can be parsed as a Scoped Attestation ID +func ValidateScopedAttestationID(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 := ParseScopedAttestationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Attestation ID +func (id ScopedAttestationId) ID() string { + fmtString := "/%s/providers/Microsoft.PolicyInsights/attestations/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.ResourceId, "/"), id.AttestationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Attestation ID +func (id ScopedAttestationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("resourceId", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticAttestations", "attestations", "attestations"), + resourceids.UserSpecifiedSegment("attestationName", "attestationName"), + } +} + +// String returns a human-readable description of this Scoped Attestation ID +func (id ScopedAttestationId) String() string { + components := []string{ + fmt.Sprintf("Resource: %q", id.ResourceId), + fmt.Sprintf("Attestation Name: %q", id.AttestationName), + } + return fmt.Sprintf("Scoped Attestation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/id_scopedattestation_test.go b/resource-manager/policyinsights/2024-10-01/attestations/id_scopedattestation_test.go new file mode 100644 index 00000000000..e8759e8c4d6 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/id_scopedattestation_test.go @@ -0,0 +1,222 @@ +package attestations + +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 = &ScopedAttestationId{} + +func TestNewScopedAttestationID(t *testing.T) { + id := NewScopedAttestationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "attestationName") + + if id.ResourceId != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceId'", id.ResourceId, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } + + if id.AttestationName != "attestationName" { + t.Fatalf("Expected %q but got %q for Segment 'AttestationName'", id.AttestationName, "attestationName") + } +} + +func TestFormatScopedAttestationID(t *testing.T) { + actual := NewScopedAttestationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "attestationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopedAttestationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedAttestationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &ScopedAttestationId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedAttestationID(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestParseScopedAttestationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedAttestationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName", + Expected: &ScopedAttestationId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + AttestationName: "attestationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/attestations/attestationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe", + Expected: &ScopedAttestationId{ + ResourceId: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + AttestationName: "aTtEsTaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/aTtEsTaTiOnS/aTtEsTaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedAttestationIDInsensitively(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.AttestationName != v.Expected.AttestationName { + t.Fatalf("Expected %q but got %q for AttestationName", v.Expected.AttestationName, actual.AttestationName) + } + + } +} + +func TestSegmentsForScopedAttestationId(t *testing.T) { + segments := ScopedAttestationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopedAttestationId 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/policyinsights/2024-10-01/attestations/method_createorupdateatresource.go b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatresource.go new file mode 100644 index 00000000000..b693115307e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatresource.go @@ -0,0 +1,75 @@ +package attestations + +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 CreateOrUpdateAtResourceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// CreateOrUpdateAtResource ... +func (c AttestationsClient) CreateOrUpdateAtResource(ctx context.Context, id ScopedAttestationId, input Attestation) (result CreateOrUpdateAtResourceOperationResponse, 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 +} + +// CreateOrUpdateAtResourceThenPoll performs CreateOrUpdateAtResource then polls until it's completed +func (c AttestationsClient) CreateOrUpdateAtResourceThenPoll(ctx context.Context, id ScopedAttestationId, input Attestation) error { + result, err := c.CreateOrUpdateAtResource(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateAtResource: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateAtResource: %+v", err) + } + + return nil +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatresourcegroup.go new file mode 100644 index 00000000000..7c53f99b52e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatresourcegroup.go @@ -0,0 +1,75 @@ +package attestations + +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 CreateOrUpdateAtResourceGroupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// CreateOrUpdateAtResourceGroup ... +func (c AttestationsClient) CreateOrUpdateAtResourceGroup(ctx context.Context, id ProviderAttestationId, input Attestation) (result CreateOrUpdateAtResourceGroupOperationResponse, 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 +} + +// CreateOrUpdateAtResourceGroupThenPoll performs CreateOrUpdateAtResourceGroup then polls until it's completed +func (c AttestationsClient) CreateOrUpdateAtResourceGroupThenPoll(ctx context.Context, id ProviderAttestationId, input Attestation) error { + result, err := c.CreateOrUpdateAtResourceGroup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateAtResourceGroup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateAtResourceGroup: %+v", err) + } + + return nil +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatsubscription.go b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatsubscription.go new file mode 100644 index 00000000000..4197b62437e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_createorupdateatsubscription.go @@ -0,0 +1,75 @@ +package attestations + +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 CreateOrUpdateAtSubscriptionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// CreateOrUpdateAtSubscription ... +func (c AttestationsClient) CreateOrUpdateAtSubscription(ctx context.Context, id AttestationId, input Attestation) (result CreateOrUpdateAtSubscriptionOperationResponse, 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 +} + +// CreateOrUpdateAtSubscriptionThenPoll performs CreateOrUpdateAtSubscription then polls until it's completed +func (c AttestationsClient) CreateOrUpdateAtSubscriptionThenPoll(ctx context.Context, id AttestationId, input Attestation) error { + result, err := c.CreateOrUpdateAtSubscription(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateAtSubscription: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateAtSubscription: %+v", err) + } + + return nil +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresource.go b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresource.go new file mode 100644 index 00000000000..1769a1415e1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresource.go @@ -0,0 +1,47 @@ +package attestations + +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 DeleteAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtResource ... +func (c AttestationsClient) DeleteAtResource(ctx context.Context, id ScopedAttestationId) (result DeleteAtResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresourcegroup.go new file mode 100644 index 00000000000..f21e0bda5ac --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatresourcegroup.go @@ -0,0 +1,47 @@ +package attestations + +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 DeleteAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtResourceGroup ... +func (c AttestationsClient) DeleteAtResourceGroup(ctx context.Context, id ProviderAttestationId) (result DeleteAtResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatsubscription.go b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatsubscription.go new file mode 100644 index 00000000000..3f4fd7a5589 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_deleteatsubscription.go @@ -0,0 +1,47 @@ +package attestations + +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 DeleteAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAtSubscription ... +func (c AttestationsClient) DeleteAtSubscription(ctx context.Context, id AttestationId) (result DeleteAtSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_getatresource.go b/resource-manager/policyinsights/2024-10-01/attestations/method_getatresource.go new file mode 100644 index 00000000000..287084b0562 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_getatresource.go @@ -0,0 +1,53 @@ +package attestations + +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 GetAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// GetAtResource ... +func (c AttestationsClient) GetAtResource(ctx context.Context, id ScopedAttestationId) (result GetAtResourceOperationResponse, 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 + } + + var model Attestation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_getatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/attestations/method_getatresourcegroup.go new file mode 100644 index 00000000000..3c64ea9ee10 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_getatresourcegroup.go @@ -0,0 +1,53 @@ +package attestations + +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 GetAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// GetAtResourceGroup ... +func (c AttestationsClient) GetAtResourceGroup(ctx context.Context, id ProviderAttestationId) (result GetAtResourceGroupOperationResponse, 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 + } + + var model Attestation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_getatsubscription.go b/resource-manager/policyinsights/2024-10-01/attestations/method_getatsubscription.go new file mode 100644 index 00000000000..84d3ad10d13 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_getatsubscription.go @@ -0,0 +1,53 @@ +package attestations + +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 GetAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Attestation +} + +// GetAtSubscription ... +func (c AttestationsClient) GetAtSubscription(ctx context.Context, id AttestationId) (result GetAtSubscriptionOperationResponse, 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 + } + + var model Attestation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_listforresource.go b/resource-manager/policyinsights/2024-10-01/attestations/method_listforresource.go new file mode 100644 index 00000000000..75dfb5c3db4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_listforresource.go @@ -0,0 +1,139 @@ +package attestations + +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 ListForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Attestation +} + +type ListForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []Attestation +} + +type ListForResourceOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceOperationOptions() ListForResourceOperationOptions { + return ListForResourceOperationOptions{} +} + +func (o ListForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResource ... +func (c AttestationsClient) ListForResource(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (result ListForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/attestations", 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 *[]Attestation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceComplete retrieves all the results into a single object +func (c AttestationsClient) ListForResourceComplete(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (ListForResourceCompleteResult, error) { + return c.ListForResourceCompleteMatchingPredicate(ctx, id, options, AttestationOperationPredicate{}) +} + +// ListForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttestationsClient) ListForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions, predicate AttestationOperationPredicate) (result ListForResourceCompleteResult, err error) { + items := make([]Attestation, 0) + + resp, err := c.ListForResource(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_listforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/attestations/method_listforresourcegroup.go new file mode 100644 index 00000000000..ae1ec293496 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_listforresourcegroup.go @@ -0,0 +1,139 @@ +package attestations + +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 ListForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Attestation +} + +type ListForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Attestation +} + +type ListForResourceGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceGroupOperationOptions() ListForResourceGroupOperationOptions { + return ListForResourceGroupOperationOptions{} +} + +func (o ListForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResourceGroup ... +func (c AttestationsClient) ListForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (result ListForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/attestations", 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 *[]Attestation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceGroupComplete retrieves all the results into a single object +func (c AttestationsClient) ListForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (ListForResourceGroupCompleteResult, error) { + return c.ListForResourceGroupCompleteMatchingPredicate(ctx, id, options, AttestationOperationPredicate{}) +} + +// ListForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttestationsClient) ListForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions, predicate AttestationOperationPredicate) (result ListForResourceGroupCompleteResult, err error) { + items := make([]Attestation, 0) + + resp, err := c.ListForResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/method_listforsubscription.go b/resource-manager/policyinsights/2024-10-01/attestations/method_listforsubscription.go new file mode 100644 index 00000000000..dac31257079 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/method_listforsubscription.go @@ -0,0 +1,139 @@ +package attestations + +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 ListForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Attestation +} + +type ListForSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Attestation +} + +type ListForSubscriptionOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForSubscriptionOperationOptions() ListForSubscriptionOperationOptions { + return ListForSubscriptionOperationOptions{} +} + +func (o ListForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForSubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForSubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForSubscription ... +func (c AttestationsClient) ListForSubscription(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions) (result ListForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForSubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/attestations", 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 *[]Attestation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForSubscriptionComplete retrieves all the results into a single object +func (c AttestationsClient) ListForSubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions) (ListForSubscriptionCompleteResult, error) { + return c.ListForSubscriptionCompleteMatchingPredicate(ctx, id, options, AttestationOperationPredicate{}) +} + +// ListForSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttestationsClient) ListForSubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions, predicate AttestationOperationPredicate) (result ListForSubscriptionCompleteResult, err error) { + items := make([]Attestation, 0) + + resp, err := c.ListForSubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/model_attestation.go b/resource-manager/policyinsights/2024-10-01/attestations/model_attestation.go new file mode 100644 index 00000000000..78673aebe63 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/model_attestation.go @@ -0,0 +1,16 @@ +package attestations + +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 Attestation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AttestationProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/model_attestationevidence.go b/resource-manager/policyinsights/2024-10-01/attestations/model_attestationevidence.go new file mode 100644 index 00000000000..f45696a0022 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/model_attestationevidence.go @@ -0,0 +1,9 @@ +package attestations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttestationEvidence struct { + Description *string `json:"description,omitempty"` + SourceUri *string `json:"sourceUri,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/model_attestationproperties.go b/resource-manager/policyinsights/2024-10-01/attestations/model_attestationproperties.go new file mode 100644 index 00000000000..8a0f93fb9f4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/model_attestationproperties.go @@ -0,0 +1,60 @@ +package attestations + +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 AttestationProperties struct { + AssessmentDate *string `json:"assessmentDate,omitempty"` + Comments *string `json:"comments,omitempty"` + ComplianceState *ComplianceState `json:"complianceState,omitempty"` + Evidence *[]AttestationEvidence `json:"evidence,omitempty"` + ExpiresOn *string `json:"expiresOn,omitempty"` + LastComplianceStateChangeAt *string `json:"lastComplianceStateChangeAt,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Owner *string `json:"owner,omitempty"` + PolicyAssignmentId string `json:"policyAssignmentId"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +func (o *AttestationProperties) GetAssessmentDateAsTime() (*time.Time, error) { + if o.AssessmentDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AssessmentDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *AttestationProperties) SetAssessmentDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AssessmentDate = &formatted +} + +func (o *AttestationProperties) GetExpiresOnAsTime() (*time.Time, error) { + if o.ExpiresOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiresOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AttestationProperties) SetExpiresOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiresOn = &formatted +} + +func (o *AttestationProperties) GetLastComplianceStateChangeAtAsTime() (*time.Time, error) { + if o.LastComplianceStateChangeAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastComplianceStateChangeAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *AttestationProperties) SetLastComplianceStateChangeAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastComplianceStateChangeAt = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/attestations/predicates.go b/resource-manager/policyinsights/2024-10-01/attestations/predicates.go new file mode 100644 index 00000000000..cec5a9985ee --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/predicates.go @@ -0,0 +1,27 @@ +package attestations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttestationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AttestationOperationPredicate) Matches(input Attestation) 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/policyinsights/2024-10-01/attestations/version.go b/resource-manager/policyinsights/2024-10-01/attestations/version.go new file mode 100644 index 00000000000..b687809aa07 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/attestations/version.go @@ -0,0 +1,10 @@ +package attestations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/attestations/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/README.md b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/README.md new file mode 100644 index 00000000000..43546914cd6 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/README.md @@ -0,0 +1,84 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions` Documentation + +The `checkpolicyrestrictions` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions" +``` + + +### Client Initialization + +```go +client := checkpolicyrestrictions.NewCheckPolicyRestrictionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckPolicyRestrictionsClient.PolicyRestrictionsCheckAtManagementGroupScope` + +```go +ctx := context.TODO() +id := checkpolicyrestrictions.NewManagementGroupID("managementGroupId") + +payload := checkpolicyrestrictions.CheckManagementGroupRestrictionsRequest{ + // ... +} + + +read, err := client.PolicyRestrictionsCheckAtManagementGroupScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CheckPolicyRestrictionsClient.PolicyRestrictionsCheckAtResourceGroupScope` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := checkpolicyrestrictions.CheckRestrictionsRequest{ + // ... +} + + +read, err := client.PolicyRestrictionsCheckAtResourceGroupScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CheckPolicyRestrictionsClient.PolicyRestrictionsCheckAtSubscriptionScope` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := checkpolicyrestrictions.CheckRestrictionsRequest{ + // ... +} + + +read, err := client.PolicyRestrictionsCheckAtSubscriptionScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/client.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/client.go new file mode 100644 index 00000000000..37ee09e164e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/client.go @@ -0,0 +1,26 @@ +package checkpolicyrestrictions + +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 CheckPolicyRestrictionsClient struct { + Client *resourcemanager.Client +} + +func NewCheckPolicyRestrictionsClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckPolicyRestrictionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checkpolicyrestrictions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckPolicyRestrictionsClient: %+v", err) + } + + return &CheckPolicyRestrictionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/constants.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/constants.go new file mode 100644 index 00000000000..326f6256ec3 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/constants.go @@ -0,0 +1,57 @@ +package checkpolicyrestrictions + +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 FieldRestrictionResult string + +const ( + FieldRestrictionResultAudit FieldRestrictionResult = "Audit" + FieldRestrictionResultDeny FieldRestrictionResult = "Deny" + FieldRestrictionResultRemoved FieldRestrictionResult = "Removed" + FieldRestrictionResultRequired FieldRestrictionResult = "Required" +) + +func PossibleValuesForFieldRestrictionResult() []string { + return []string{ + string(FieldRestrictionResultAudit), + string(FieldRestrictionResultDeny), + string(FieldRestrictionResultRemoved), + string(FieldRestrictionResultRequired), + } +} + +func (s *FieldRestrictionResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFieldRestrictionResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFieldRestrictionResult(input string) (*FieldRestrictionResult, error) { + vals := map[string]FieldRestrictionResult{ + "audit": FieldRestrictionResultAudit, + "deny": FieldRestrictionResultDeny, + "removed": FieldRestrictionResultRemoved, + "required": FieldRestrictionResultRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FieldRestrictionResult(input) + return &out, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup.go new file mode 100644 index 00000000000..2bad7438ea0 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup.go @@ -0,0 +1,112 @@ +package checkpolicyrestrictions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementGroupId{}) +} + +var _ resourceids.ResourceId = &ManagementGroupId{} + +// ManagementGroupId is a struct representing the Resource ID for a Management Group +type ManagementGroupId struct { + ManagementGroupId string +} + +// NewManagementGroupID returns a new ManagementGroupId struct +func NewManagementGroupID(managementGroupId string) ManagementGroupId { + return ManagementGroupId{ + ManagementGroupId: managementGroupId, + } +} + +// ParseManagementGroupID parses 'input' into a ManagementGroupId +func ParseManagementGroupID(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementGroupIDInsensitively parses 'input' case-insensitively into a ManagementGroupId +// note: this method should only be used for API response data and not user input +func ParseManagementGroupIDInsensitively(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + return nil +} + +// ValidateManagementGroupID checks that 'input' can be parsed as a Management Group ID +func ValidateManagementGroupID(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 := ParseManagementGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Group ID +func (id ManagementGroupId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Group ID +func (id ManagementGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + } +} + +// String returns a human-readable description of this Management Group ID +func (id ManagementGroupId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + } + return fmt.Sprintf("Management Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup_test.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup_test.go new file mode 100644 index 00000000000..85ae7c7095e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/id_managementgroup_test.go @@ -0,0 +1,192 @@ +package checkpolicyrestrictions + +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 = &ManagementGroupId{} + +func TestNewManagementGroupID(t *testing.T) { + id := NewManagementGroupID("managementGroupId") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } +} + +func TestFormatManagementGroupID(t *testing.T) { + actual := NewManagementGroupID("managementGroupId").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupID(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestParseManagementGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Expected: &ManagementGroupId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupIDInsensitively(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestSegmentsForManagementGroupId(t *testing.T) { + segments := ManagementGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementGroupId 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/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatmanagementgroupscope.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatmanagementgroupscope.go new file mode 100644 index 00000000000..87fbc362061 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatmanagementgroupscope.go @@ -0,0 +1,58 @@ +package checkpolicyrestrictions + +import ( + "context" + "fmt" + "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 PolicyRestrictionsCheckAtManagementGroupScopeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckRestrictionsResult +} + +// PolicyRestrictionsCheckAtManagementGroupScope ... +func (c CheckPolicyRestrictionsClient) PolicyRestrictionsCheckAtManagementGroupScope(ctx context.Context, id ManagementGroupId, input CheckManagementGroupRestrictionsRequest) (result PolicyRestrictionsCheckAtManagementGroupScopeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", 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 + } + + var model CheckRestrictionsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatresourcegroupscope.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatresourcegroupscope.go new file mode 100644 index 00000000000..0cdfae60d8f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatresourcegroupscope.go @@ -0,0 +1,59 @@ +package checkpolicyrestrictions + +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 PolicyRestrictionsCheckAtResourceGroupScopeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckRestrictionsResult +} + +// PolicyRestrictionsCheckAtResourceGroupScope ... +func (c CheckPolicyRestrictionsClient) PolicyRestrictionsCheckAtResourceGroupScope(ctx context.Context, id commonids.ResourceGroupId, input CheckRestrictionsRequest) (result PolicyRestrictionsCheckAtResourceGroupScopeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", 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 + } + + var model CheckRestrictionsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatsubscriptionscope.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatsubscriptionscope.go new file mode 100644 index 00000000000..e90b7f46d50 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/method_policyrestrictionscheckatsubscriptionscope.go @@ -0,0 +1,59 @@ +package checkpolicyrestrictions + +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 PolicyRestrictionsCheckAtSubscriptionScopeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckRestrictionsResult +} + +// PolicyRestrictionsCheckAtSubscriptionScope ... +func (c CheckPolicyRestrictionsClient) PolicyRestrictionsCheckAtSubscriptionScope(ctx context.Context, id commonids.SubscriptionId, input CheckRestrictionsRequest) (result PolicyRestrictionsCheckAtSubscriptionScopeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", 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 + } + + var model CheckRestrictionsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkmanagementgrouprestrictionsrequest.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkmanagementgrouprestrictionsrequest.go new file mode 100644 index 00000000000..224d2776712 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkmanagementgrouprestrictionsrequest.go @@ -0,0 +1,9 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckManagementGroupRestrictionsRequest struct { + PendingFields *[]PendingField `json:"pendingFields,omitempty"` + ResourceDetails *CheckRestrictionsResourceDetails `json:"resourceDetails,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionevaluationdetails.go new file mode 100644 index 00000000000..e892db40f9e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionevaluationdetails.go @@ -0,0 +1,10 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckRestrictionEvaluationDetails struct { + EvaluatedExpressions *[]ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` + IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsrequest.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsrequest.go new file mode 100644 index 00000000000..6bc09ca6868 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsrequest.go @@ -0,0 +1,10 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckRestrictionsRequest struct { + IncludeAuditEffect *bool `json:"includeAuditEffect,omitempty"` + PendingFields *[]PendingField `json:"pendingFields,omitempty"` + ResourceDetails CheckRestrictionsResourceDetails `json:"resourceDetails"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresourcedetails.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresourcedetails.go new file mode 100644 index 00000000000..8a130e6b656 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresourcedetails.go @@ -0,0 +1,10 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckRestrictionsResourceDetails struct { + ApiVersion *string `json:"apiVersion,omitempty"` + ResourceContent interface{} `json:"resourceContent"` + Scope *string `json:"scope,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresult.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresult.go new file mode 100644 index 00000000000..ea20838f30d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresult.go @@ -0,0 +1,9 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckRestrictionsResult struct { + ContentEvaluationResult *CheckRestrictionsResultContentEvaluationResult `json:"contentEvaluationResult,omitempty"` + FieldRestrictions *[]FieldRestrictions `json:"fieldRestrictions,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresultcontentevaluationresult.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresultcontentevaluationresult.go new file mode 100644 index 00000000000..2bd5f1fb391 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_checkrestrictionsresultcontentevaluationresult.go @@ -0,0 +1,8 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckRestrictionsResultContentEvaluationResult struct { + PolicyEvaluations *[]PolicyEvaluationResult `json:"policyEvaluations,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_expressionevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_expressionevaluationdetails.go new file mode 100644 index 00000000000..1d3688346c9 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_expressionevaluationdetails.go @@ -0,0 +1,14 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressionEvaluationDetails struct { + Expression *string `json:"expression,omitempty"` + ExpressionKind *string `json:"expressionKind,omitempty"` + ExpressionValue *interface{} `json:"expressionValue,omitempty"` + Operator *string `json:"operator,omitempty"` + Path *string `json:"path,omitempty"` + Result *string `json:"result,omitempty"` + TargetValue *interface{} `json:"targetValue,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestriction.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestriction.go new file mode 100644 index 00000000000..027f53fe830 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestriction.go @@ -0,0 +1,13 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FieldRestriction struct { + DefaultValue *string `json:"defaultValue,omitempty"` + Policy *PolicyReference `json:"policy,omitempty"` + PolicyEffect *string `json:"policyEffect,omitempty"` + Reason *string `json:"reason,omitempty"` + Result *FieldRestrictionResult `json:"result,omitempty"` + Values *[]string `json:"values,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestrictions.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestrictions.go new file mode 100644 index 00000000000..788062d2e86 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_fieldrestrictions.go @@ -0,0 +1,9 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FieldRestrictions struct { + Field *string `json:"field,omitempty"` + Restrictions *[]FieldRestriction `json:"restrictions,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_ifnotexistsevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_ifnotexistsevaluationdetails.go new file mode 100644 index 00000000000..6b09ba23b71 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_ifnotexistsevaluationdetails.go @@ -0,0 +1,9 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IfNotExistsEvaluationDetails struct { + ResourceId *string `json:"resourceId,omitempty"` + TotalResources *int64 `json:"totalResources,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_pendingfield.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_pendingfield.go new file mode 100644 index 00000000000..fd5a7e64c73 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_pendingfield.go @@ -0,0 +1,9 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingField struct { + Field string `json:"field"` + Values *[]string `json:"values,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyeffectdetails.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyeffectdetails.go new file mode 100644 index 00000000000..7bdbec3e274 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyeffectdetails.go @@ -0,0 +1,8 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyEffectDetails struct { + PolicyEffect *string `json:"policyEffect,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyevaluationresult.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyevaluationresult.go new file mode 100644 index 00000000000..d4b0556b8d4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyevaluationresult.go @@ -0,0 +1,11 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyEvaluationResult struct { + EffectDetails *PolicyEffectDetails `json:"effectDetails,omitempty"` + EvaluationDetails *CheckRestrictionEvaluationDetails `json:"evaluationDetails,omitempty"` + EvaluationResult *string `json:"evaluationResult,omitempty"` + PolicyInfo *PolicyReference `json:"policyInfo,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyreference.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyreference.go new file mode 100644 index 00000000000..3ec2ad9dd6e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/model_policyreference.go @@ -0,0 +1,11 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyReference struct { + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/version.go b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/version.go new file mode 100644 index 00000000000..da679493efe --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions/version.go @@ -0,0 +1,10 @@ +package checkpolicyrestrictions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checkpolicyrestrictions/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/client.go b/resource-manager/policyinsights/2024-10-01/client.go new file mode 100644 index 00000000000..b9bf418facf --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/client.go @@ -0,0 +1,82 @@ +package v2024_10_01 + +// 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/policyinsights/2024-10-01/attestations" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/checkpolicyrestrictions" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/componentpolicystates" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policyevents" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policymetadata" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policystates" + "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/remediations" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Attestations *attestations.AttestationsClient + CheckPolicyRestrictions *checkpolicyrestrictions.CheckPolicyRestrictionsClient + ComponentPolicyStates *componentpolicystates.ComponentPolicyStatesClient + PolicyEvents *policyevents.PolicyEventsClient + PolicyMetadata *policymetadata.PolicyMetadataClient + PolicyStates *policystates.PolicyStatesClient + Remediations *remediations.RemediationsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + attestationsClient, err := attestations.NewAttestationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Attestations client: %+v", err) + } + configureFunc(attestationsClient.Client) + + checkPolicyRestrictionsClient, err := checkpolicyrestrictions.NewCheckPolicyRestrictionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckPolicyRestrictions client: %+v", err) + } + configureFunc(checkPolicyRestrictionsClient.Client) + + componentPolicyStatesClient, err := componentpolicystates.NewComponentPolicyStatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ComponentPolicyStates client: %+v", err) + } + configureFunc(componentPolicyStatesClient.Client) + + policyEventsClient, err := policyevents.NewPolicyEventsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyEvents client: %+v", err) + } + configureFunc(policyEventsClient.Client) + + policyMetadataClient, err := policymetadata.NewPolicyMetadataClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyMetadata client: %+v", err) + } + configureFunc(policyMetadataClient.Client) + + policyStatesClient, err := policystates.NewPolicyStatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyStates client: %+v", err) + } + configureFunc(policyStatesClient.Client) + + remediationsClient, err := remediations.NewRemediationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Remediations client: %+v", err) + } + configureFunc(remediationsClient.Client) + + return &Client{ + Attestations: attestationsClient, + CheckPolicyRestrictions: checkPolicyRestrictionsClient, + ComponentPolicyStates: componentPolicyStatesClient, + PolicyEvents: policyEventsClient, + PolicyMetadata: policyMetadataClient, + PolicyStates: policyStatesClient, + Remediations: remediationsClient, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/README.md b/resource-manager/policyinsights/2024-10-01/componentpolicystates/README.md new file mode 100644 index 00000000000..3a53b8b0e03 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/componentpolicystates` Documentation + +The `componentpolicystates` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/componentpolicystates" +``` + + +### Client Initialization + +```go +client := componentpolicystates.NewComponentPolicyStatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForPolicyDefinition` + +```go +ctx := context.TODO() +id := componentpolicystates.NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +read, err := client.ListQueryResultsForPolicyDefinition(ctx, id, componentpolicystates.DefaultListQueryResultsForPolicyDefinitionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.ListQueryResultsForResource(ctx, id, componentpolicystates.DefaultListQueryResultsForResourceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.ListQueryResultsForResourceGroup(ctx, id, componentpolicystates.DefaultListQueryResultsForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := componentpolicystates.NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + +read, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, id, componentpolicystates.DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListQueryResultsForSubscription(ctx, id, componentpolicystates.DefaultListQueryResultsForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentPolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := componentpolicystates.NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + +read, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, id, componentpolicystates.DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/client.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/client.go new file mode 100644 index 00000000000..6a9656a2abd --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/client.go @@ -0,0 +1,26 @@ +package componentpolicystates + +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 ComponentPolicyStatesClient struct { + Client *resourcemanager.Client +} + +func NewComponentPolicyStatesClientWithBaseURI(sdkApi sdkEnv.Api) (*ComponentPolicyStatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "componentpolicystates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ComponentPolicyStatesClient: %+v", err) + } + + return &ComponentPolicyStatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment.go new file mode 100644 index 00000000000..e0d360d88b8 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment.go @@ -0,0 +1,130 @@ +package componentpolicystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AuthorizationNamespacePolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &AuthorizationNamespacePolicyAssignmentId{} + +// AuthorizationNamespacePolicyAssignmentId is a struct representing the Resource ID for a Authorization Namespace Policy Assignment +type AuthorizationNamespacePolicyAssignmentId struct { + SubscriptionId string + ResourceGroupName string + PolicyAssignmentName string +} + +// NewAuthorizationNamespacePolicyAssignmentID returns a new AuthorizationNamespacePolicyAssignmentId struct +func NewAuthorizationNamespacePolicyAssignmentID(subscriptionId string, resourceGroupName string, policyAssignmentName string) AuthorizationNamespacePolicyAssignmentId { + return AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParseAuthorizationNamespacePolicyAssignmentID parses 'input' into a AuthorizationNamespacePolicyAssignmentId +func ParseAuthorizationNamespacePolicyAssignmentID(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthorizationNamespacePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a AuthorizationNamespacePolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthorizationNamespacePolicyAssignmentId) 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.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidateAuthorizationNamespacePolicyAssignmentID checks that 'input' can be parsed as a Authorization Namespace Policy Assignment ID +func ValidateAuthorizationNamespacePolicyAssignmentID(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 := ParseAuthorizationNamespacePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) 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.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Authorization Namespace Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment_test.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment_test.go new file mode 100644 index 00000000000..19b23dd055a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_authorizationnamespacepolicyassignment_test.go @@ -0,0 +1,282 @@ +package componentpolicystates + +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 = &AuthorizationNamespacePolicyAssignmentId{} + +func TestNewAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + id := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + actual := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // 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.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForAuthorizationNamespacePolicyAssignmentId(t *testing.T) { + segments := AuthorizationNamespacePolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthorizationNamespacePolicyAssignmentId 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/policyinsights/2024-10-01/componentpolicystates/id_policyassignment.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policyassignment.go new file mode 100644 index 00000000000..fee0cddaa95 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policyassignment.go @@ -0,0 +1,121 @@ +package componentpolicystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentId{} + +// PolicyAssignmentId is a struct representing the Resource ID for a Policy Assignment +type PolicyAssignmentId struct { + SubscriptionId string + PolicyAssignmentName string +} + +// NewPolicyAssignmentID returns a new PolicyAssignmentId struct +func NewPolicyAssignmentID(subscriptionId string, policyAssignmentName string) PolicyAssignmentId { + return PolicyAssignmentId{ + SubscriptionId: subscriptionId, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParsePolicyAssignmentID parses 'input' into a PolicyAssignmentId +func ParsePolicyAssignmentID(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentIDInsensitively(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidatePolicyAssignmentID checks that 'input' can be parsed as a Policy Assignment ID +func ValidatePolicyAssignmentID(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 := ParsePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment ID +func (id PolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment ID +func (id PolicyAssignmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Policy Assignment ID +func (id PolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policyassignment_test.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policyassignment_test.go new file mode 100644 index 00000000000..6cd7356eadb --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policyassignment_test.go @@ -0,0 +1,237 @@ +package componentpolicystates + +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 = &PolicyAssignmentId{} + +func TestNewPolicyAssignmentID(t *testing.T) { + id := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatPolicyAssignmentID(t *testing.T) { + actual := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParsePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForPolicyAssignmentId(t *testing.T) { + segments := PolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentId 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/policyinsights/2024-10-01/componentpolicystates/id_policydefinition.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policydefinition.go new file mode 100644 index 00000000000..5a6765b93af --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policydefinition.go @@ -0,0 +1,121 @@ +package componentpolicystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +// PolicyDefinitionId is a struct representing the Resource ID for a Policy Definition +type PolicyDefinitionId struct { + SubscriptionId string + PolicyDefinitionName string +} + +// NewPolicyDefinitionID returns a new PolicyDefinitionId struct +func NewPolicyDefinitionID(subscriptionId string, policyDefinitionName string) PolicyDefinitionId { + return PolicyDefinitionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParsePolicyDefinitionID parses 'input' into a PolicyDefinitionId +func ParsePolicyDefinitionID(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionIDInsensitively(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionID checks that 'input' can be parsed as a Policy Definition ID +func ValidatePolicyDefinitionID(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 := ParsePolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition ID +func (id PolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition ID +func (id PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Definition ID +func (id PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policydefinition_test.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policydefinition_test.go new file mode 100644 index 00000000000..2dc93e7c608 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/id_policydefinition_test.go @@ -0,0 +1,237 @@ +package componentpolicystates + +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 = &PolicyDefinitionId{} + +func TestNewPolicyDefinitionID(t *testing.T) { + id := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + + 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.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatPolicyDefinitionID(t *testing.T) { + actual := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionID(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParsePolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionIDInsensitively(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionId(t *testing.T) { + segments := PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionId 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/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforpolicydefinition.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforpolicydefinition.go new file mode 100644 index 00000000000..75f4cc37321 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforpolicydefinition.go @@ -0,0 +1,107 @@ +package componentpolicystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForPolicyDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForPolicyDefinitionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForPolicyDefinitionOperationOptions() ListQueryResultsForPolicyDefinitionOperationOptions { + return ListQueryResultsForPolicyDefinitionOperationOptions{} +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForPolicyDefinition ... +func (c ComponentPolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context.Context, id PolicyDefinitionId, options ListQueryResultsForPolicyDefinitionOperationOptions) (result ListQueryResultsForPolicyDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresource.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresource.go new file mode 100644 index 00000000000..d3d457e464f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresource.go @@ -0,0 +1,112 @@ +package componentpolicystates + +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 ListQueryResultsForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForResourceOperationOptions struct { + Apply *string + Expand *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceOperationOptions() ListQueryResultsForResourceOperationOptions { + return ListQueryResultsForResourceOperationOptions{} +} + +func (o ListQueryResultsForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForResource ... +func (c ComponentPolicyStatesClient) ListQueryResultsForResource(ctx context.Context, id commonids.ScopeId, options ListQueryResultsForResourceOperationOptions) (result ListQueryResultsForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegroup.go new file mode 100644 index 00000000000..3216e9c637d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegroup.go @@ -0,0 +1,108 @@ +package componentpolicystates + +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 ListQueryResultsForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForResourceGroupOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupOperationOptions() ListQueryResultsForResourceGroupOperationOptions { + return ListQueryResultsForResourceGroupOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForResourceGroup ... +func (c ComponentPolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListQueryResultsForResourceGroupOperationOptions) (result ListQueryResultsForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go new file mode 100644 index 00000000000..61abe7306ad --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go @@ -0,0 +1,107 @@ +package componentpolicystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions() ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment ... +func (c ComponentPolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, id AuthorizationNamespacePolicyAssignmentId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscription.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscription.go new file mode 100644 index 00000000000..8eed4a77ee4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscription.go @@ -0,0 +1,108 @@ +package componentpolicystates + +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 ListQueryResultsForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForSubscriptionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionOperationOptions() ListQueryResultsForSubscriptionOperationOptions { + return ListQueryResultsForSubscriptionOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForSubscription ... +func (c ComponentPolicyStatesClient) ListQueryResultsForSubscription(ctx context.Context, id commonids.SubscriptionId, options ListQueryResultsForSubscriptionOperationOptions) (result ListQueryResultsForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go new file mode 100644 index 00000000000..24433198420 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go @@ -0,0 +1,107 @@ +package componentpolicystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentPolicyStatesQueryResults +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions() ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment ... +func (c ComponentPolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, id PolicyAssignmentId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/componentPolicyStates/latest/queryResults", 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 + } + + var model ComponentPolicyStatesQueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentexpressionevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentexpressionevaluationdetails.go new file mode 100644 index 00000000000..045aa9b1a67 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentexpressionevaluationdetails.go @@ -0,0 +1,14 @@ +package componentpolicystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentExpressionEvaluationDetails struct { + Expression *string `json:"expression,omitempty"` + ExpressionKind *string `json:"expressionKind,omitempty"` + ExpressionValue *interface{} `json:"expressionValue,omitempty"` + Operator *string `json:"operator,omitempty"` + Path *string `json:"path,omitempty"` + Result *string `json:"result,omitempty"` + TargetValue *interface{} `json:"targetValue,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicyevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicyevaluationdetails.go new file mode 100644 index 00000000000..67eda899d29 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicyevaluationdetails.go @@ -0,0 +1,9 @@ +package componentpolicystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentPolicyEvaluationDetails struct { + EvaluatedExpressions *[]ComponentExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystate.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystate.go new file mode 100644 index 00000000000..93689cbc72c --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystate.go @@ -0,0 +1,57 @@ +package componentpolicystates + +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 ComponentPolicyState struct { + ComplianceState *string `json:"complianceState,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComponentName *string `json:"componentName,omitempty"` + ComponentType *string `json:"componentType,omitempty"` + OdataContext *string `json:"@odata.context,omitempty"` + OdataId *string `json:"@odata.id,omitempty"` + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty"` + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty"` + PolicyEvaluationDetails *ComponentPolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` + PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` +} + +func (o *ComponentPolicyState) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComponentPolicyState) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystatesqueryresults.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystatesqueryresults.go new file mode 100644 index 00000000000..b2ad28a8071 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/model_componentpolicystatesqueryresults.go @@ -0,0 +1,10 @@ +package componentpolicystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentPolicyStatesQueryResults struct { + OdataContext *string `json:"@odata.context,omitempty"` + OdataCount *int64 `json:"@odata.count,omitempty"` + Value *[]ComponentPolicyState `json:"value,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/componentpolicystates/version.go b/resource-manager/policyinsights/2024-10-01/componentpolicystates/version.go new file mode 100644 index 00000000000..c5afb624abc --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/componentpolicystates/version.go @@ -0,0 +1,10 @@ +package componentpolicystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/componentpolicystates/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/README.md b/resource-manager/policyinsights/2024-10-01/policyevents/README.md new file mode 100644 index 00000000000..f697afe6791 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/README.md @@ -0,0 +1,157 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policyevents` Documentation + +The `policyevents` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policyevents" +``` + + +### Client Initialization + +```go +client := policyevents.NewPolicyEventsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForManagementGroup` + +```go +ctx := context.TODO() +id := policyevents.NewManagementGroupID("managementGroupId") + +// alternatively `client.ListQueryResultsForManagementGroup(ctx, id, policyevents.DefaultListQueryResultsForManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForManagementGroupComplete(ctx, id, policyevents.DefaultListQueryResultsForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForPolicyDefinition` + +```go +ctx := context.TODO() +id := policyevents.NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +// alternatively `client.ListQueryResultsForPolicyDefinition(ctx, id, policyevents.DefaultListQueryResultsForPolicyDefinitionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForPolicyDefinitionComplete(ctx, id, policyevents.DefaultListQueryResultsForPolicyDefinitionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForPolicySetDefinition` + +```go +ctx := context.TODO() +id := policyevents.NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +// alternatively `client.ListQueryResultsForPolicySetDefinition(ctx, id, policyevents.DefaultListQueryResultsForPolicySetDefinitionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForPolicySetDefinitionComplete(ctx, id, policyevents.DefaultListQueryResultsForPolicySetDefinitionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListQueryResultsForResource(ctx, id, policyevents.DefaultListQueryResultsForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceComplete(ctx, id, policyevents.DefaultListQueryResultsForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListQueryResultsForResourceGroup(ctx, id, policyevents.DefaultListQueryResultsForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceGroupComplete(ctx, id, policyevents.DefaultListQueryResultsForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForResourceGroupLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policyevents.NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + +// alternatively `client.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, id, policyevents.DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(ctx, id, policyevents.DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListQueryResultsForSubscription(ctx, id, policyevents.DefaultListQueryResultsForSubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForSubscriptionComplete(ctx, id, policyevents.DefaultListQueryResultsForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyEventsClient.ListQueryResultsForSubscriptionLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policyevents.NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + +// alternatively `client.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, id, policyevents.DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx, id, policyevents.DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/client.go b/resource-manager/policyinsights/2024-10-01/policyevents/client.go new file mode 100644 index 00000000000..d5ab61dab52 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/client.go @@ -0,0 +1,26 @@ +package policyevents + +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 PolicyEventsClient struct { + Client *resourcemanager.Client +} + +func NewPolicyEventsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyEventsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policyevents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyEventsClient: %+v", err) + } + + return &PolicyEventsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment.go new file mode 100644 index 00000000000..726180e096e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment.go @@ -0,0 +1,130 @@ +package policyevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AuthorizationNamespacePolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &AuthorizationNamespacePolicyAssignmentId{} + +// AuthorizationNamespacePolicyAssignmentId is a struct representing the Resource ID for a Authorization Namespace Policy Assignment +type AuthorizationNamespacePolicyAssignmentId struct { + SubscriptionId string + ResourceGroupName string + PolicyAssignmentName string +} + +// NewAuthorizationNamespacePolicyAssignmentID returns a new AuthorizationNamespacePolicyAssignmentId struct +func NewAuthorizationNamespacePolicyAssignmentID(subscriptionId string, resourceGroupName string, policyAssignmentName string) AuthorizationNamespacePolicyAssignmentId { + return AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParseAuthorizationNamespacePolicyAssignmentID parses 'input' into a AuthorizationNamespacePolicyAssignmentId +func ParseAuthorizationNamespacePolicyAssignmentID(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthorizationNamespacePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a AuthorizationNamespacePolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthorizationNamespacePolicyAssignmentId) 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.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidateAuthorizationNamespacePolicyAssignmentID checks that 'input' can be parsed as a Authorization Namespace Policy Assignment ID +func ValidateAuthorizationNamespacePolicyAssignmentID(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 := ParseAuthorizationNamespacePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) 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.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Authorization Namespace Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment_test.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment_test.go new file mode 100644 index 00000000000..b157570b588 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_authorizationnamespacepolicyassignment_test.go @@ -0,0 +1,282 @@ +package policyevents + +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 = &AuthorizationNamespacePolicyAssignmentId{} + +func TestNewAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + id := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + actual := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // 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.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForAuthorizationNamespacePolicyAssignmentId(t *testing.T) { + segments := AuthorizationNamespacePolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthorizationNamespacePolicyAssignmentId 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/policyinsights/2024-10-01/policyevents/id_managementgroup.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_managementgroup.go new file mode 100644 index 00000000000..d87a9ca477b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_managementgroup.go @@ -0,0 +1,112 @@ +package policyevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementGroupId{}) +} + +var _ resourceids.ResourceId = &ManagementGroupId{} + +// ManagementGroupId is a struct representing the Resource ID for a Management Group +type ManagementGroupId struct { + ManagementGroupId string +} + +// NewManagementGroupID returns a new ManagementGroupId struct +func NewManagementGroupID(managementGroupId string) ManagementGroupId { + return ManagementGroupId{ + ManagementGroupId: managementGroupId, + } +} + +// ParseManagementGroupID parses 'input' into a ManagementGroupId +func ParseManagementGroupID(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementGroupIDInsensitively parses 'input' case-insensitively into a ManagementGroupId +// note: this method should only be used for API response data and not user input +func ParseManagementGroupIDInsensitively(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + return nil +} + +// ValidateManagementGroupID checks that 'input' can be parsed as a Management Group ID +func ValidateManagementGroupID(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 := ParseManagementGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Group ID +func (id ManagementGroupId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Group ID +func (id ManagementGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + } +} + +// String returns a human-readable description of this Management Group ID +func (id ManagementGroupId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + } + return fmt.Sprintf("Management Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_managementgroup_test.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_managementgroup_test.go new file mode 100644 index 00000000000..3ecdd1bbf84 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_managementgroup_test.go @@ -0,0 +1,192 @@ +package policyevents + +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 = &ManagementGroupId{} + +func TestNewManagementGroupID(t *testing.T) { + id := NewManagementGroupID("managementGroupId") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } +} + +func TestFormatManagementGroupID(t *testing.T) { + actual := NewManagementGroupID("managementGroupId").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupID(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestParseManagementGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Expected: &ManagementGroupId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupIDInsensitively(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestSegmentsForManagementGroupId(t *testing.T) { + segments := ManagementGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementGroupId 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/policyinsights/2024-10-01/policyevents/id_policyassignment.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policyassignment.go new file mode 100644 index 00000000000..36d90fac484 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policyassignment.go @@ -0,0 +1,121 @@ +package policyevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentId{} + +// PolicyAssignmentId is a struct representing the Resource ID for a Policy Assignment +type PolicyAssignmentId struct { + SubscriptionId string + PolicyAssignmentName string +} + +// NewPolicyAssignmentID returns a new PolicyAssignmentId struct +func NewPolicyAssignmentID(subscriptionId string, policyAssignmentName string) PolicyAssignmentId { + return PolicyAssignmentId{ + SubscriptionId: subscriptionId, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParsePolicyAssignmentID parses 'input' into a PolicyAssignmentId +func ParsePolicyAssignmentID(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentIDInsensitively(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidatePolicyAssignmentID checks that 'input' can be parsed as a Policy Assignment ID +func ValidatePolicyAssignmentID(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 := ParsePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment ID +func (id PolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment ID +func (id PolicyAssignmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Policy Assignment ID +func (id PolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_policyassignment_test.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policyassignment_test.go new file mode 100644 index 00000000000..08f71edbcdb --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policyassignment_test.go @@ -0,0 +1,237 @@ +package policyevents + +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 = &PolicyAssignmentId{} + +func TestNewPolicyAssignmentID(t *testing.T) { + id := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatPolicyAssignmentID(t *testing.T) { + actual := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParsePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForPolicyAssignmentId(t *testing.T) { + segments := PolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentId 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/policyinsights/2024-10-01/policyevents/id_policydefinition.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policydefinition.go new file mode 100644 index 00000000000..21627251c5d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policydefinition.go @@ -0,0 +1,121 @@ +package policyevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +// PolicyDefinitionId is a struct representing the Resource ID for a Policy Definition +type PolicyDefinitionId struct { + SubscriptionId string + PolicyDefinitionName string +} + +// NewPolicyDefinitionID returns a new PolicyDefinitionId struct +func NewPolicyDefinitionID(subscriptionId string, policyDefinitionName string) PolicyDefinitionId { + return PolicyDefinitionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParsePolicyDefinitionID parses 'input' into a PolicyDefinitionId +func ParsePolicyDefinitionID(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionIDInsensitively(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionID checks that 'input' can be parsed as a Policy Definition ID +func ValidatePolicyDefinitionID(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 := ParsePolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition ID +func (id PolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition ID +func (id PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Definition ID +func (id PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_policydefinition_test.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policydefinition_test.go new file mode 100644 index 00000000000..c8c80548b19 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policydefinition_test.go @@ -0,0 +1,237 @@ +package policyevents + +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 = &PolicyDefinitionId{} + +func TestNewPolicyDefinitionID(t *testing.T) { + id := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + + 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.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatPolicyDefinitionID(t *testing.T) { + actual := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionID(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParsePolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionIDInsensitively(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionId(t *testing.T) { + segments := PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionId 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/policyinsights/2024-10-01/policyevents/id_policysetdefinition.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policysetdefinition.go new file mode 100644 index 00000000000..a946fe53891 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policysetdefinition.go @@ -0,0 +1,121 @@ +package policyevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +// PolicySetDefinitionId is a struct representing the Resource ID for a Policy Set Definition +type PolicySetDefinitionId struct { + SubscriptionId string + PolicySetDefinitionName string +} + +// NewPolicySetDefinitionID returns a new PolicySetDefinitionId struct +func NewPolicySetDefinitionID(subscriptionId string, policySetDefinitionName string) PolicySetDefinitionId { + return PolicySetDefinitionId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParsePolicySetDefinitionID parses 'input' into a PolicySetDefinitionId +func ParsePolicySetDefinitionID(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionIDInsensitively(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidatePolicySetDefinitionID checks that 'input' can be parsed as a Policy Set Definition ID +func ValidatePolicySetDefinitionID(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 := ParsePolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition ID +func (id PolicySetDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition ID +func (id PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Set Definition ID +func (id PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/id_policysetdefinition_test.go b/resource-manager/policyinsights/2024-10-01/policyevents/id_policysetdefinition_test.go new file mode 100644 index 00000000000..314c1e18d63 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/id_policysetdefinition_test.go @@ -0,0 +1,237 @@ +package policyevents + +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 = &PolicySetDefinitionId{} + +func TestNewPolicySetDefinitionID(t *testing.T) { + id := NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + + 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.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatPolicySetDefinitionID(t *testing.T) { + actual := NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionID(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParsePolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionIDInsensitively(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForPolicySetDefinitionId(t *testing.T) { + segments := PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionId 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/policyinsights/2024-10-01/policyevents/method_listqueryresultsformanagementgroup.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsformanagementgroup.go new file mode 100644 index 00000000000..429392b5f5f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsformanagementgroup.go @@ -0,0 +1,158 @@ +package policyevents + +import ( + "context" + "fmt" + "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 ListQueryResultsForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForManagementGroupOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForManagementGroupOperationOptions() ListQueryResultsForManagementGroupOperationOptions { + return ListQueryResultsForManagementGroupOperationOptions{} +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForManagementGroupCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForManagementGroup ... +func (c PolicyEventsClient) ListQueryResultsForManagementGroup(ctx context.Context, id ManagementGroupId, options ListQueryResultsForManagementGroupOperationOptions) (result ListQueryResultsForManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForManagementGroupComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForManagementGroupComplete(ctx context.Context, id ManagementGroupId, options ListQueryResultsForManagementGroupOperationOptions) (ListQueryResultsForManagementGroupCompleteResult, error) { + return c.ListQueryResultsForManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForManagementGroupCompleteMatchingPredicate(ctx context.Context, id ManagementGroupId, options ListQueryResultsForManagementGroupOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForManagementGroupCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForManagementGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicydefinition.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicydefinition.go new file mode 100644 index 00000000000..8064f6c7be6 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicydefinition.go @@ -0,0 +1,158 @@ +package policyevents + +import ( + "context" + "fmt" + "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 ListQueryResultsForPolicyDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForPolicyDefinitionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForPolicyDefinitionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForPolicyDefinitionOperationOptions() ListQueryResultsForPolicyDefinitionOperationOptions { + return ListQueryResultsForPolicyDefinitionOperationOptions{} +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForPolicyDefinitionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForPolicyDefinitionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForPolicyDefinition ... +func (c PolicyEventsClient) ListQueryResultsForPolicyDefinition(ctx context.Context, id PolicyDefinitionId, options ListQueryResultsForPolicyDefinitionOperationOptions) (result ListQueryResultsForPolicyDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForPolicyDefinitionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForPolicyDefinitionComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForPolicyDefinitionComplete(ctx context.Context, id PolicyDefinitionId, options ListQueryResultsForPolicyDefinitionOperationOptions) (ListQueryResultsForPolicyDefinitionCompleteResult, error) { + return c.ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate(ctx context.Context, id PolicyDefinitionId, options ListQueryResultsForPolicyDefinitionOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForPolicyDefinitionCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForPolicyDefinition(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForPolicyDefinitionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicysetdefinition.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicysetdefinition.go new file mode 100644 index 00000000000..f541fcd0500 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforpolicysetdefinition.go @@ -0,0 +1,158 @@ +package policyevents + +import ( + "context" + "fmt" + "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 ListQueryResultsForPolicySetDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForPolicySetDefinitionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForPolicySetDefinitionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForPolicySetDefinitionOperationOptions() ListQueryResultsForPolicySetDefinitionOperationOptions { + return ListQueryResultsForPolicySetDefinitionOperationOptions{} +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForPolicySetDefinitionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForPolicySetDefinitionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForPolicySetDefinition ... +func (c PolicyEventsClient) ListQueryResultsForPolicySetDefinition(ctx context.Context, id PolicySetDefinitionId, options ListQueryResultsForPolicySetDefinitionOperationOptions) (result ListQueryResultsForPolicySetDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForPolicySetDefinitionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForPolicySetDefinitionComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForPolicySetDefinitionComplete(ctx context.Context, id PolicySetDefinitionId, options ListQueryResultsForPolicySetDefinitionOperationOptions) (ListQueryResultsForPolicySetDefinitionCompleteResult, error) { + return c.ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate(ctx context.Context, id PolicySetDefinitionId, options ListQueryResultsForPolicySetDefinitionOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForPolicySetDefinitionCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForPolicySetDefinition(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForPolicySetDefinitionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresource.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresource.go new file mode 100644 index 00000000000..02953822328 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresource.go @@ -0,0 +1,163 @@ +package policyevents + +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 ListQueryResultsForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForResourceOperationOptions struct { + Apply *string + Expand *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceOperationOptions() ListQueryResultsForResourceOperationOptions { + return ListQueryResultsForResourceOperationOptions{} +} + +func (o ListQueryResultsForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResource ... +func (c PolicyEventsClient) ListQueryResultsForResource(ctx context.Context, id commonids.ScopeId, options ListQueryResultsForResourceOperationOptions) (result ListQueryResultsForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForResourceComplete(ctx context.Context, id commonids.ScopeId, options ListQueryResultsForResourceOperationOptions) (ListQueryResultsForResourceCompleteResult, error) { + return c.ListQueryResultsForResourceCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListQueryResultsForResourceOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForResourceCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForResource(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegroup.go new file mode 100644 index 00000000000..f72049a0b32 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegroup.go @@ -0,0 +1,159 @@ +package policyevents + +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 ListQueryResultsForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForResourceGroupOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupOperationOptions() ListQueryResultsForResourceGroupOperationOptions { + return ListQueryResultsForResourceGroupOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceGroupCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResourceGroup ... +func (c PolicyEventsClient) ListQueryResultsForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListQueryResultsForResourceGroupOperationOptions) (result ListQueryResultsForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceGroupComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListQueryResultsForResourceGroupOperationOptions) (ListQueryResultsForResourceGroupCompleteResult, error) { + return c.ListQueryResultsForResourceGroupCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListQueryResultsForResourceGroupOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForResourceGroupCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegrouplevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegrouplevelpolicyassignment.go new file mode 100644 index 00000000000..cf909391e37 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforresourcegrouplevelpolicyassignment.go @@ -0,0 +1,158 @@ +package policyevents + +import ( + "context" + "fmt" + "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 ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions() ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment ... +func (c PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, id AuthorizationNamespacePolicyAssignmentId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(ctx context.Context, id AuthorizationNamespacePolicyAssignmentId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) (ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult, error) { + return c.ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate(ctx context.Context, id AuthorizationNamespacePolicyAssignmentId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscription.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscription.go new file mode 100644 index 00000000000..6f45f620114 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscription.go @@ -0,0 +1,159 @@ +package policyevents + +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 ListQueryResultsForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForSubscriptionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionOperationOptions() ListQueryResultsForSubscriptionOperationOptions { + return ListQueryResultsForSubscriptionOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForSubscriptionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForSubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForSubscription ... +func (c PolicyEventsClient) ListQueryResultsForSubscription(ctx context.Context, id commonids.SubscriptionId, options ListQueryResultsForSubscriptionOperationOptions) (result ListQueryResultsForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForSubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForSubscriptionComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForSubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListQueryResultsForSubscriptionOperationOptions) (ListQueryResultsForSubscriptionCompleteResult, error) { + return c.ListQueryResultsForSubscriptionCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForSubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListQueryResultsForSubscriptionOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForSubscriptionCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForSubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscriptionlevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscriptionlevelpolicyassignment.go new file mode 100644 index 00000000000..15496304173 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/method_listqueryresultsforsubscriptionlevelpolicyassignment.go @@ -0,0 +1,158 @@ +package policyevents + +import ( + "context" + "fmt" + "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 ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyEvent +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyEvent +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions() ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment ... +func (c PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, id PolicyAssignmentId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyEvents/default/queryResults", 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 *[]PolicyEvent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete retrieves all the results into a single object +func (c PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx context.Context, id PolicyAssignmentId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) (ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult, error) { + return c.ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate(ctx, id, options, PolicyEventOperationPredicate{}) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate(ctx context.Context, id PolicyAssignmentId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions, predicate PolicyEventOperationPredicate) (result ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult, err error) { + items := make([]PolicyEvent, 0) + + resp, err := c.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/model_componenteventdetails.go b/resource-manager/policyinsights/2024-10-01/policyevents/model_componenteventdetails.go new file mode 100644 index 00000000000..8d6762671b1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/model_componenteventdetails.go @@ -0,0 +1,32 @@ +package policyevents + +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 ComponentEventDetails struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + PrincipalOid *string `json:"principalOid,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (o *ComponentEventDetails) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComponentEventDetails) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/model_policyevent.go b/resource-manager/policyinsights/2024-10-01/policyevents/model_policyevent.go new file mode 100644 index 00000000000..6baecfc30ef --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/model_policyevent.go @@ -0,0 +1,56 @@ +package policyevents + +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 PolicyEvent struct { + ComplianceState *string `json:"complianceState,omitempty"` + Components *[]ComponentEventDetails `json:"components,omitempty"` + EffectiveParameters *string `json:"effectiveParameters,omitempty"` + IsCompliant *bool `json:"isCompliant,omitempty"` + ManagementGroupIds *string `json:"managementGroupIds,omitempty"` + OdataContext *string `json:"@odata.context,omitempty"` + OdataId *string `json:"@odata.id,omitempty"` + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` + PrincipalOid *string `json:"principalOid,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceTags *string `json:"resourceTags,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` +} + +func (o *PolicyEvent) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *PolicyEvent) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/predicates.go b/resource-manager/policyinsights/2024-10-01/policyevents/predicates.go new file mode 100644 index 00000000000..a2cc5b255ab --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/predicates.go @@ -0,0 +1,162 @@ +package policyevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyEventOperationPredicate struct { + ComplianceState *string + EffectiveParameters *string + IsCompliant *bool + ManagementGroupIds *string + OdataContext *string + OdataId *string + PolicyAssignmentId *string + PolicyAssignmentName *string + PolicyAssignmentOwner *string + PolicyAssignmentParameters *string + PolicyAssignmentScope *string + PolicyDefinitionAction *string + PolicyDefinitionCategory *string + PolicyDefinitionId *string + PolicyDefinitionName *string + PolicyDefinitionReferenceId *string + PolicySetDefinitionCategory *string + PolicySetDefinitionId *string + PolicySetDefinitionName *string + PolicySetDefinitionOwner *string + PolicySetDefinitionParameters *string + PrincipalOid *string + ResourceGroup *string + ResourceId *string + ResourceLocation *string + ResourceTags *string + ResourceType *string + SubscriptionId *string + TenantId *string + Timestamp *string +} + +func (p PolicyEventOperationPredicate) Matches(input PolicyEvent) bool { + + if p.ComplianceState != nil && (input.ComplianceState == nil || *p.ComplianceState != *input.ComplianceState) { + return false + } + + if p.EffectiveParameters != nil && (input.EffectiveParameters == nil || *p.EffectiveParameters != *input.EffectiveParameters) { + return false + } + + if p.IsCompliant != nil && (input.IsCompliant == nil || *p.IsCompliant != *input.IsCompliant) { + return false + } + + if p.ManagementGroupIds != nil && (input.ManagementGroupIds == nil || *p.ManagementGroupIds != *input.ManagementGroupIds) { + return false + } + + if p.OdataContext != nil && (input.OdataContext == nil || *p.OdataContext != *input.OdataContext) { + return false + } + + if p.OdataId != nil && (input.OdataId == nil || *p.OdataId != *input.OdataId) { + return false + } + + if p.PolicyAssignmentId != nil && (input.PolicyAssignmentId == nil || *p.PolicyAssignmentId != *input.PolicyAssignmentId) { + return false + } + + if p.PolicyAssignmentName != nil && (input.PolicyAssignmentName == nil || *p.PolicyAssignmentName != *input.PolicyAssignmentName) { + return false + } + + if p.PolicyAssignmentOwner != nil && (input.PolicyAssignmentOwner == nil || *p.PolicyAssignmentOwner != *input.PolicyAssignmentOwner) { + return false + } + + if p.PolicyAssignmentParameters != nil && (input.PolicyAssignmentParameters == nil || *p.PolicyAssignmentParameters != *input.PolicyAssignmentParameters) { + return false + } + + if p.PolicyAssignmentScope != nil && (input.PolicyAssignmentScope == nil || *p.PolicyAssignmentScope != *input.PolicyAssignmentScope) { + return false + } + + if p.PolicyDefinitionAction != nil && (input.PolicyDefinitionAction == nil || *p.PolicyDefinitionAction != *input.PolicyDefinitionAction) { + return false + } + + if p.PolicyDefinitionCategory != nil && (input.PolicyDefinitionCategory == nil || *p.PolicyDefinitionCategory != *input.PolicyDefinitionCategory) { + return false + } + + if p.PolicyDefinitionId != nil && (input.PolicyDefinitionId == nil || *p.PolicyDefinitionId != *input.PolicyDefinitionId) { + return false + } + + if p.PolicyDefinitionName != nil && (input.PolicyDefinitionName == nil || *p.PolicyDefinitionName != *input.PolicyDefinitionName) { + return false + } + + if p.PolicyDefinitionReferenceId != nil && (input.PolicyDefinitionReferenceId == nil || *p.PolicyDefinitionReferenceId != *input.PolicyDefinitionReferenceId) { + return false + } + + if p.PolicySetDefinitionCategory != nil && (input.PolicySetDefinitionCategory == nil || *p.PolicySetDefinitionCategory != *input.PolicySetDefinitionCategory) { + return false + } + + if p.PolicySetDefinitionId != nil && (input.PolicySetDefinitionId == nil || *p.PolicySetDefinitionId != *input.PolicySetDefinitionId) { + return false + } + + if p.PolicySetDefinitionName != nil && (input.PolicySetDefinitionName == nil || *p.PolicySetDefinitionName != *input.PolicySetDefinitionName) { + return false + } + + if p.PolicySetDefinitionOwner != nil && (input.PolicySetDefinitionOwner == nil || *p.PolicySetDefinitionOwner != *input.PolicySetDefinitionOwner) { + return false + } + + if p.PolicySetDefinitionParameters != nil && (input.PolicySetDefinitionParameters == nil || *p.PolicySetDefinitionParameters != *input.PolicySetDefinitionParameters) { + return false + } + + if p.PrincipalOid != nil && (input.PrincipalOid == nil || *p.PrincipalOid != *input.PrincipalOid) { + return false + } + + if p.ResourceGroup != nil && (input.ResourceGroup == nil || *p.ResourceGroup != *input.ResourceGroup) { + return false + } + + if p.ResourceId != nil && (input.ResourceId == nil || *p.ResourceId != *input.ResourceId) { + return false + } + + if p.ResourceLocation != nil && (input.ResourceLocation == nil || *p.ResourceLocation != *input.ResourceLocation) { + return false + } + + if p.ResourceTags != nil && (input.ResourceTags == nil || *p.ResourceTags != *input.ResourceTags) { + return false + } + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + if p.SubscriptionId != nil && (input.SubscriptionId == nil || *p.SubscriptionId != *input.SubscriptionId) { + return false + } + + if p.TenantId != nil && (input.TenantId == nil || *p.TenantId != *input.TenantId) { + return false + } + + if p.Timestamp != nil && (input.Timestamp == nil || *p.Timestamp != *input.Timestamp) { + return false + } + + return true +} diff --git a/resource-manager/policyinsights/2024-10-01/policyevents/version.go b/resource-manager/policyinsights/2024-10-01/policyevents/version.go new file mode 100644 index 00000000000..66d1995b3c4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policyevents/version.go @@ -0,0 +1,10 @@ +package policyevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policyevents/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/README.md b/resource-manager/policyinsights/2024-10-01/policymetadata/README.md new file mode 100644 index 00000000000..09133566000 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policymetadata` Documentation + +The `policymetadata` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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/policyinsights/2024-10-01/policymetadata" +``` + + +### Client Initialization + +```go +client := policymetadata.NewPolicyMetadataClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyMetadataClient.GetResource` + +```go +ctx := context.TODO() +id := policymetadata.NewPolicyMetadataID("policyMetadataName") + +read, err := client.GetResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyMetadataClient.List` + +```go +ctx := context.TODO() + + +// alternatively `client.List(ctx, policymetadata.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, policymetadata.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/client.go b/resource-manager/policyinsights/2024-10-01/policymetadata/client.go new file mode 100644 index 00000000000..d123e227a3f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/client.go @@ -0,0 +1,26 @@ +package policymetadata + +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 PolicyMetadataClient struct { + Client *resourcemanager.Client +} + +func NewPolicyMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyMetadataClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policymetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyMetadataClient: %+v", err) + } + + return &PolicyMetadataClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata.go b/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata.go new file mode 100644 index 00000000000..6224edb8403 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata.go @@ -0,0 +1,112 @@ +package policymetadata + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyMetadataId{}) +} + +var _ resourceids.ResourceId = &PolicyMetadataId{} + +// PolicyMetadataId is a struct representing the Resource ID for a Policy Metadata +type PolicyMetadataId struct { + PolicyMetadataName string +} + +// NewPolicyMetadataID returns a new PolicyMetadataId struct +func NewPolicyMetadataID(policyMetadataName string) PolicyMetadataId { + return PolicyMetadataId{ + PolicyMetadataName: policyMetadataName, + } +} + +// ParsePolicyMetadataID parses 'input' into a PolicyMetadataId +func ParsePolicyMetadataID(input string) (*PolicyMetadataId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyMetadataId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyMetadataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyMetadataIDInsensitively parses 'input' case-insensitively into a PolicyMetadataId +// note: this method should only be used for API response data and not user input +func ParsePolicyMetadataIDInsensitively(input string) (*PolicyMetadataId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyMetadataId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyMetadataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyMetadataId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyMetadataName, ok = input.Parsed["policyMetadataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyMetadataName", input) + } + + return nil +} + +// ValidatePolicyMetadataID checks that 'input' can be parsed as a Policy Metadata ID +func ValidatePolicyMetadataID(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 := ParsePolicyMetadataID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Metadata ID +func (id PolicyMetadataId) ID() string { + fmtString := "/providers/Microsoft.PolicyInsights/policyMetadata/%s" + return fmt.Sprintf(fmtString, id.PolicyMetadataName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Metadata ID +func (id PolicyMetadataId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyMetadata", "policyMetadata", "policyMetadata"), + resourceids.UserSpecifiedSegment("policyMetadataName", "policyMetadataName"), + } +} + +// String returns a human-readable description of this Policy Metadata ID +func (id PolicyMetadataId) String() string { + components := []string{ + fmt.Sprintf("Policy Metadata Name: %q", id.PolicyMetadataName), + } + return fmt.Sprintf("Policy Metadata (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata_test.go b/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata_test.go new file mode 100644 index 00000000000..5402155d9b3 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/id_policymetadata_test.go @@ -0,0 +1,192 @@ +package policymetadata + +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 = &PolicyMetadataId{} + +func TestNewPolicyMetadataID(t *testing.T) { + id := NewPolicyMetadataID("policyMetadataName") + + if id.PolicyMetadataName != "policyMetadataName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyMetadataName'", id.PolicyMetadataName, "policyMetadataName") + } +} + +func TestFormatPolicyMetadataID(t *testing.T) { + actual := NewPolicyMetadataID("policyMetadataName").ID() + expected := "/providers/Microsoft.PolicyInsights/policyMetadata/policyMetadataName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyMetadataID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyMetadataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.PolicyInsights/policyMetadata", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.PolicyInsights/policyMetadata/policyMetadataName", + Expected: &PolicyMetadataId{ + PolicyMetadataName: "policyMetadataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.PolicyInsights/policyMetadata/policyMetadataName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyMetadataID(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.PolicyMetadataName != v.Expected.PolicyMetadataName { + t.Fatalf("Expected %q but got %q for PolicyMetadataName", v.Expected.PolicyMetadataName, actual.PolicyMetadataName) + } + + } +} + +func TestParsePolicyMetadataIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyMetadataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.PolicyInsights/policyMetadata", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYmEtAdAtA", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.PolicyInsights/policyMetadata/policyMetadataName", + Expected: &PolicyMetadataId{ + PolicyMetadataName: "policyMetadataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.PolicyInsights/policyMetadata/policyMetadataName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYmEtAdAtA/pOlIcYmEtAdAtAnAmE", + Expected: &PolicyMetadataId{ + PolicyMetadataName: "pOlIcYmEtAdAtAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYmEtAdAtA/pOlIcYmEtAdAtAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyMetadataIDInsensitively(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.PolicyMetadataName != v.Expected.PolicyMetadataName { + t.Fatalf("Expected %q but got %q for PolicyMetadataName", v.Expected.PolicyMetadataName, actual.PolicyMetadataName) + } + + } +} + +func TestSegmentsForPolicyMetadataId(t *testing.T) { + segments := PolicyMetadataId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyMetadataId 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/policyinsights/2024-10-01/policymetadata/method_getresource.go b/resource-manager/policyinsights/2024-10-01/policymetadata/method_getresource.go new file mode 100644 index 00000000000..11b0df85e39 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/method_getresource.go @@ -0,0 +1,53 @@ +package policymetadata + +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 GetResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyMetadata +} + +// GetResource ... +func (c PolicyMetadataClient) GetResource(ctx context.Context, id PolicyMetadataId) (result GetResourceOperationResponse, 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 + } + + var model PolicyMetadata + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/method_list.go b/resource-manager/policyinsights/2024-10-01/policymetadata/method_list.go new file mode 100644 index 00000000000..3030ae520c0 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/method_list.go @@ -0,0 +1,134 @@ +package policymetadata + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlimPolicyMetadata +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlimPolicyMetadata +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PolicyMetadataClient) List(ctx context.Context, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: "/providers/Microsoft.PolicyInsights/policyMetadata", + } + + 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 *[]SlimPolicyMetadata `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 PolicyMetadataClient) ListComplete(ctx context.Context, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, options, SlimPolicyMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, options ListOperationOptions, predicate SlimPolicyMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SlimPolicyMetadata, 0) + + resp, err := c.List(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/policyinsights/2024-10-01/policymetadata/model_policymetadata.go b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadata.go new file mode 100644 index 00000000000..3c3f576f0ea --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadata.go @@ -0,0 +1,11 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyMetadata struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyMetadataProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataproperties.go b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataproperties.go new file mode 100644 index 00000000000..6c981067b67 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataproperties.go @@ -0,0 +1,15 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyMetadataProperties struct { + AdditionalContentURL *string `json:"additionalContentUrl,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + MetadataId *string `json:"metadataId,omitempty"` + Owner *string `json:"owner,omitempty"` + Requirements *string `json:"requirements,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataslimproperties.go b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataslimproperties.go new file mode 100644 index 00000000000..1eb3097044f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/model_policymetadataslimproperties.go @@ -0,0 +1,13 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyMetadataSlimProperties struct { + AdditionalContentURL *string `json:"additionalContentUrl,omitempty"` + Category *string `json:"category,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + MetadataId *string `json:"metadataId,omitempty"` + Owner *string `json:"owner,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/model_slimpolicymetadata.go b/resource-manager/policyinsights/2024-10-01/policymetadata/model_slimpolicymetadata.go new file mode 100644 index 00000000000..f6755fec285 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/model_slimpolicymetadata.go @@ -0,0 +1,11 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlimPolicyMetadata struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyMetadataSlimProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policymetadata/predicates.go b/resource-manager/policyinsights/2024-10-01/policymetadata/predicates.go new file mode 100644 index 00000000000..38e110c80d9 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/predicates.go @@ -0,0 +1,27 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlimPolicyMetadataOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SlimPolicyMetadataOperationPredicate) Matches(input SlimPolicyMetadata) 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/policyinsights/2024-10-01/policymetadata/version.go b/resource-manager/policyinsights/2024-10-01/policymetadata/version.go new file mode 100644 index 00000000000..f2b20d26b12 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policymetadata/version.go @@ -0,0 +1,10 @@ +package policymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policymetadata/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/README.md b/resource-manager/policyinsights/2024-10-01/policystates/README.md new file mode 100644 index 00000000000..1bc559efa4f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/README.md @@ -0,0 +1,309 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policystates` Documentation + +The `policystates` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/policystates" +``` + + +### Client Initialization + +```go +client := policystates.NewPolicyStatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForManagementGroup` + +```go +ctx := context.TODO() +id := policystates.NewProviders2PolicyStatePolicyStatesResourceID("managementGroupName", "default") + +// alternatively `client.ListQueryResultsForManagementGroup(ctx, id, policystates.DefaultListQueryResultsForManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForManagementGroupComplete(ctx, id, policystates.DefaultListQueryResultsForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForPolicyDefinition` + +```go +ctx := context.TODO() +id := policystates.NewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "default") + +// alternatively `client.ListQueryResultsForPolicyDefinition(ctx, id, policystates.DefaultListQueryResultsForPolicyDefinitionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForPolicyDefinitionComplete(ctx, id, policystates.DefaultListQueryResultsForPolicyDefinitionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForPolicySetDefinition` + +```go +ctx := context.TODO() +id := policystates.NewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "default") + +// alternatively `client.ListQueryResultsForPolicySetDefinition(ctx, id, policystates.DefaultListQueryResultsForPolicySetDefinitionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForPolicySetDefinitionComplete(ctx, id, policystates.DefaultListQueryResultsForPolicySetDefinitionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForResource` + +```go +ctx := context.TODO() +id := policystates.NewScopedPolicyStatesResourceID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "default") + +// alternatively `client.ListQueryResultsForResource(ctx, id, policystates.DefaultListQueryResultsForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceComplete(ctx, id, policystates.DefaultListQueryResultsForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForResourceGroup` + +```go +ctx := context.TODO() +id := policystates.NewPolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "default") + +// alternatively `client.ListQueryResultsForResourceGroup(ctx, id, policystates.DefaultListQueryResultsForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceGroupComplete(ctx, id, policystates.DefaultListQueryResultsForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policystates.NewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName", "default") + +// alternatively `client.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, id, policystates.DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(ctx, id, policystates.DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForSubscription` + +```go +ctx := context.TODO() +id := policystates.NewPolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "default") + +// alternatively `client.ListQueryResultsForSubscription(ctx, id, policystates.DefaultListQueryResultsForSubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForSubscriptionComplete(ctx, id, policystates.DefaultListQueryResultsForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policystates.NewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyAssignmentName", "default") + +// alternatively `client.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, id, policystates.DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions())` can be used to do batched pagination +items, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx, id, policystates.DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForManagementGroup` + +```go +ctx := context.TODO() +id := policystates.NewManagementGroupID("managementGroupId") + +read, err := client.SummarizeForManagementGroup(ctx, id, policystates.DefaultSummarizeForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForPolicyDefinition` + +```go +ctx := context.TODO() +id := policystates.NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + +read, err := client.SummarizeForPolicyDefinition(ctx, id, policystates.DefaultSummarizeForPolicyDefinitionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForPolicySetDefinition` + +```go +ctx := context.TODO() +id := policystates.NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + +read, err := client.SummarizeForPolicySetDefinition(ctx, id, policystates.DefaultSummarizeForPolicySetDefinitionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.SummarizeForResource(ctx, id, policystates.DefaultSummarizeForResourceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.SummarizeForResourceGroup(ctx, id, policystates.DefaultSummarizeForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policystates.NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + +read, err := client.SummarizeForResourceGroupLevelPolicyAssignment(ctx, id, policystates.DefaultSummarizeForResourceGroupLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.SummarizeForSubscription(ctx, id, policystates.DefaultSummarizeForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment` + +```go +ctx := context.TODO() +id := policystates.NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + +read, err := client.SummarizeForSubscriptionLevelPolicyAssignment(ctx, id, policystates.DefaultSummarizeForSubscriptionLevelPolicyAssignmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyStatesClient.TriggerResourceGroupEvaluation` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +if err := client.TriggerResourceGroupEvaluationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PolicyStatesClient.TriggerSubscriptionEvaluation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +if err := client.TriggerSubscriptionEvaluationThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/policystates/client.go b/resource-manager/policyinsights/2024-10-01/policystates/client.go new file mode 100644 index 00000000000..41338a5ad7d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/client.go @@ -0,0 +1,26 @@ +package policystates + +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 PolicyStatesClient struct { + Client *resourcemanager.Client +} + +func NewPolicyStatesClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyStatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "policystates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyStatesClient: %+v", err) + } + + return &PolicyStatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/constants.go b/resource-manager/policyinsights/2024-10-01/policystates/constants.go new file mode 100644 index 00000000000..0a01d391a1b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/constants.go @@ -0,0 +1,51 @@ +package policystates + +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 PolicyStatesResource string + +const ( + PolicyStatesResourceDefault PolicyStatesResource = "default" + PolicyStatesResourceLatest PolicyStatesResource = "latest" +) + +func PossibleValuesForPolicyStatesResource() []string { + return []string{ + string(PolicyStatesResourceDefault), + string(PolicyStatesResourceLatest), + } +} + +func (s *PolicyStatesResource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyStatesResource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePolicyStatesResource(input string) (*PolicyStatesResource, error) { + vals := map[string]PolicyStatesResource{ + "default": PolicyStatesResourceDefault, + "latest": PolicyStatesResourceLatest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyStatesResource(input) + return &out, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment.go new file mode 100644 index 00000000000..33ea0eacf07 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment.go @@ -0,0 +1,130 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AuthorizationNamespacePolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &AuthorizationNamespacePolicyAssignmentId{} + +// AuthorizationNamespacePolicyAssignmentId is a struct representing the Resource ID for a Authorization Namespace Policy Assignment +type AuthorizationNamespacePolicyAssignmentId struct { + SubscriptionId string + ResourceGroupName string + PolicyAssignmentName string +} + +// NewAuthorizationNamespacePolicyAssignmentID returns a new AuthorizationNamespacePolicyAssignmentId struct +func NewAuthorizationNamespacePolicyAssignmentID(subscriptionId string, resourceGroupName string, policyAssignmentName string) AuthorizationNamespacePolicyAssignmentId { + return AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParseAuthorizationNamespacePolicyAssignmentID parses 'input' into a AuthorizationNamespacePolicyAssignmentId +func ParseAuthorizationNamespacePolicyAssignmentID(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthorizationNamespacePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a AuthorizationNamespacePolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(input string) (*AuthorizationNamespacePolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthorizationNamespacePolicyAssignmentId) 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.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidateAuthorizationNamespacePolicyAssignmentID checks that 'input' can be parsed as a Authorization Namespace Policy Assignment ID +func ValidateAuthorizationNamespacePolicyAssignmentID(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 := ParseAuthorizationNamespacePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) 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.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Authorization Namespace Policy Assignment ID +func (id AuthorizationNamespacePolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Authorization Namespace Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment_test.go new file mode 100644 index 00000000000..ff0b036feea --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignment_test.go @@ -0,0 +1,282 @@ +package policystates + +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 = &AuthorizationNamespacePolicyAssignmentId{} + +func TestNewAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + id := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + actual := NewAuthorizationNamespacePolicyAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &AuthorizationNamespacePolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // 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.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForAuthorizationNamespacePolicyAssignmentId(t *testing.T) { + segments := AuthorizationNamespacePolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthorizationNamespacePolicyAssignmentId 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/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource.go new file mode 100644 index 00000000000..1a4d82b6068 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource.go @@ -0,0 +1,149 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + +// AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource +type AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId struct { + SubscriptionId string + ResourceGroupName string + PolicyAssignmentName string + PolicyStatesResource PolicyStatesResource +} + +// NewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID returns a new AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId struct +func NewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(subscriptionId string, resourceGroupName string, policyAssignmentName string, policyStatesResource PolicyStatesResource) AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId { + return AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PolicyAssignmentName: policyAssignmentName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID parses 'input' into a AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId +func ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(input string) (*AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(input string) (*AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) 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.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidateAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource ID +func ValidateAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(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 := ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/policyAssignments/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PolicyAssignmentName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) 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.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Authorization Namespace Policy Assignment Providers 2 Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..61fe65bac92 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_authorizationnamespacepolicyassignmentproviders2policystatepolicystatesresource_test.go @@ -0,0 +1,357 @@ +package policystates + +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 = &AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + +func TestNewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName", "default") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "policyAssignmentName", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyAssignmentName: "policyAssignmentName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + PolicyStatesResource: "default", + }, + }, + { + // 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.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForAuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId(t *testing.T) { + segments := AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_managementgroup.go b/resource-manager/policyinsights/2024-10-01/policystates/id_managementgroup.go new file mode 100644 index 00000000000..5af518c86de --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_managementgroup.go @@ -0,0 +1,112 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementGroupId{}) +} + +var _ resourceids.ResourceId = &ManagementGroupId{} + +// ManagementGroupId is a struct representing the Resource ID for a Management Group +type ManagementGroupId struct { + ManagementGroupId string +} + +// NewManagementGroupID returns a new ManagementGroupId struct +func NewManagementGroupID(managementGroupId string) ManagementGroupId { + return ManagementGroupId{ + ManagementGroupId: managementGroupId, + } +} + +// ParseManagementGroupID parses 'input' into a ManagementGroupId +func ParseManagementGroupID(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementGroupIDInsensitively parses 'input' case-insensitively into a ManagementGroupId +// note: this method should only be used for API response data and not user input +func ParseManagementGroupIDInsensitively(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + return nil +} + +// ValidateManagementGroupID checks that 'input' can be parsed as a Management Group ID +func ValidateManagementGroupID(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 := ParseManagementGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Group ID +func (id ManagementGroupId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Group ID +func (id ManagementGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + } +} + +// String returns a human-readable description of this Management Group ID +func (id ManagementGroupId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + } + return fmt.Sprintf("Management Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_managementgroup_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_managementgroup_test.go new file mode 100644 index 00000000000..a31603b348c --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_managementgroup_test.go @@ -0,0 +1,192 @@ +package policystates + +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 = &ManagementGroupId{} + +func TestNewManagementGroupID(t *testing.T) { + id := NewManagementGroupID("managementGroupId") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } +} + +func TestFormatManagementGroupID(t *testing.T) { + actual := NewManagementGroupID("managementGroupId").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupID(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestParseManagementGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Expected: &ManagementGroupId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupIDInsensitively(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestSegmentsForManagementGroupId(t *testing.T) { + segments := ManagementGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementGroupId 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/policyinsights/2024-10-01/policystates/id_policyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignment.go new file mode 100644 index 00000000000..0cc140f619a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignment.go @@ -0,0 +1,121 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentId{} + +// PolicyAssignmentId is a struct representing the Resource ID for a Policy Assignment +type PolicyAssignmentId struct { + SubscriptionId string + PolicyAssignmentName string +} + +// NewPolicyAssignmentID returns a new PolicyAssignmentId struct +func NewPolicyAssignmentID(subscriptionId string, policyAssignmentName string) PolicyAssignmentId { + return PolicyAssignmentId{ + SubscriptionId: subscriptionId, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParsePolicyAssignmentID parses 'input' into a PolicyAssignmentId +func ParsePolicyAssignmentID(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentIDInsensitively(input string) (*PolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidatePolicyAssignmentID checks that 'input' can be parsed as a Policy Assignment ID +func ValidatePolicyAssignmentID(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 := ParsePolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment ID +func (id PolicyAssignmentId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment ID +func (id PolicyAssignmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + } +} + +// String returns a human-readable description of this Policy Assignment ID +func (id PolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignment_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignment_test.go new file mode 100644 index 00000000000..50826c41603 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignment_test.go @@ -0,0 +1,237 @@ +package policystates + +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 = &PolicyAssignmentId{} + +func TestNewPolicyAssignmentID(t *testing.T) { + id := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } +} + +func TestFormatPolicyAssignmentID(t *testing.T) { + actual := NewPolicyAssignmentID("12345678-1234-9876-4563-123456789012", "policyAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParsePolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Expected: &PolicyAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForPolicyAssignmentId(t *testing.T) { + segments := PolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentId 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/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource.go new file mode 100644 index 00000000000..71b7216e027 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource.go @@ -0,0 +1,140 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + +// PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Policy Assignment Providers 2 Policy State Policy States Resource +type PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId struct { + SubscriptionId string + PolicyAssignmentName string + PolicyStatesResource PolicyStatesResource +} + +// NewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID returns a new PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId struct +func NewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(subscriptionId string, policyAssignmentName string, policyStatesResource PolicyStatesResource) PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId { + return PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: subscriptionId, + PolicyAssignmentName: policyAssignmentName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID parses 'input' into a PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId +func ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(input string) (*PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(input string) (*PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidatePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Policy Assignment Providers 2 Policy State Policy States Resource ID +func ValidatePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(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 := ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyAssignments/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyAssignmentName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Policy Assignment Providers 2 Policy State Policy States Resource ID +func (id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Policy Assignment Providers 2 Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..ae4a00d992b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policyassignmentproviders2policystatepolicystatesresource_test.go @@ -0,0 +1,312 @@ +package policystates + +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 = &PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{} + +func TestNewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyAssignmentName", "default") + + 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.PolicyAssignmentName != "policyAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentName") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewPolicyAssignmentProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyAssignmentName", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceID(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "policyAssignmentName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTnAmE", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentProviders2PolicyStatePolicyStatesResourceIDInsensitively(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.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForPolicyAssignmentProviders2PolicyStatePolicyStatesResourceId(t *testing.T) { + segments := PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_policydefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinition.go new file mode 100644 index 00000000000..b14f7bea71f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinition.go @@ -0,0 +1,121 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionId{} + +// PolicyDefinitionId is a struct representing the Resource ID for a Policy Definition +type PolicyDefinitionId struct { + SubscriptionId string + PolicyDefinitionName string +} + +// NewPolicyDefinitionID returns a new PolicyDefinitionId struct +func NewPolicyDefinitionID(subscriptionId string, policyDefinitionName string) PolicyDefinitionId { + return PolicyDefinitionId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + } +} + +// ParsePolicyDefinitionID parses 'input' into a PolicyDefinitionId +func ParsePolicyDefinitionID(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionIDInsensitively(input string) (*PolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + return nil +} + +// ValidatePolicyDefinitionID checks that 'input' can be parsed as a Policy Definition ID +func ValidatePolicyDefinitionID(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 := ParsePolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition ID +func (id PolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition ID +func (id PolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Definition ID +func (id PolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + } + return fmt.Sprintf("Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinition_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinition_test.go new file mode 100644 index 00000000000..1febe51d033 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinition_test.go @@ -0,0 +1,237 @@ +package policystates + +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 = &PolicyDefinitionId{} + +func TestNewPolicyDefinitionID(t *testing.T) { + id := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName") + + 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.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } +} + +func TestFormatPolicyDefinitionID(t *testing.T) { + actual := NewPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "policyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionID(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestParsePolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Expected: &PolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionIDInsensitively(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + } +} + +func TestSegmentsForPolicyDefinitionId(t *testing.T) { + segments := PolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionId 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/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource.go new file mode 100644 index 00000000000..e6af44c75a1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource.go @@ -0,0 +1,140 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{} + +// PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Policy Definition Providers 2 Policy State Policy States Resource +type PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId struct { + SubscriptionId string + PolicyDefinitionName string + PolicyStatesResource PolicyStatesResource +} + +// NewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID returns a new PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId struct +func NewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(subscriptionId string, policyDefinitionName string, policyStatesResource PolicyStatesResource) PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId { + return PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: subscriptionId, + PolicyDefinitionName: policyDefinitionName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID parses 'input' into a PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId +func ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(input string) (*PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(input string) (*PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicyDefinitionName, ok = input.Parsed["policyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyDefinitionName", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidatePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Policy Definition Providers 2 Policy State Policy States Resource ID +func ValidatePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(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 := ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Definition Providers 2 Policy State Policy States Resource ID +func (id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policyDefinitions/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicyDefinitionName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Definition Providers 2 Policy State Policy States Resource ID +func (id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyDefinitions", "policyDefinitions", "policyDefinitions"), + resourceids.UserSpecifiedSegment("policyDefinitionName", "policyDefinitionName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Policy Definition Providers 2 Policy State Policy States Resource ID +func (id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Definition Name: %q", id.PolicyDefinitionName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Policy Definition Providers 2 Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..675b48e9da4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policydefinitionproviders2policystatepolicystatesresource_test.go @@ -0,0 +1,312 @@ +package policystates + +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 = &PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{} + +func TestNewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "default") + + 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.PolicyDefinitionName != "policyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyDefinitionName'", id.PolicyDefinitionName, "policyDefinitionName") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewPolicyDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policyDefinitionName", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceID(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "policyDefinitionName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyDefinitionName: "pOlIcYdEfInItIoNnAmE", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYdEfInItIoNs/pOlIcYdEfInItIoNnAmE/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(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.PolicyDefinitionName != v.Expected.PolicyDefinitionName { + t.Fatalf("Expected %q but got %q for PolicyDefinitionName", v.Expected.PolicyDefinitionName, actual.PolicyDefinitionName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForPolicyDefinitionProviders2PolicyStatePolicyStatesResourceId(t *testing.T) { + segments := PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_policysetdefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinition.go new file mode 100644 index 00000000000..5a279d35701 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinition.go @@ -0,0 +1,121 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionId{} + +// PolicySetDefinitionId is a struct representing the Resource ID for a Policy Set Definition +type PolicySetDefinitionId struct { + SubscriptionId string + PolicySetDefinitionName string +} + +// NewPolicySetDefinitionID returns a new PolicySetDefinitionId struct +func NewPolicySetDefinitionID(subscriptionId string, policySetDefinitionName string) PolicySetDefinitionId { + return PolicySetDefinitionId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + } +} + +// ParsePolicySetDefinitionID parses 'input' into a PolicySetDefinitionId +func ParsePolicySetDefinitionID(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionIDInsensitively(input string) (*PolicySetDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + return nil +} + +// ValidatePolicySetDefinitionID checks that 'input' can be parsed as a Policy Set Definition ID +func ValidatePolicySetDefinitionID(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 := ParsePolicySetDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition ID +func (id PolicySetDefinitionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition ID +func (id PolicySetDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + } +} + +// String returns a human-readable description of this Policy Set Definition ID +func (id PolicySetDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + } + return fmt.Sprintf("Policy Set Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinition_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinition_test.go new file mode 100644 index 00000000000..bd3b538459d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinition_test.go @@ -0,0 +1,237 @@ +package policystates + +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 = &PolicySetDefinitionId{} + +func TestNewPolicySetDefinitionID(t *testing.T) { + id := NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName") + + 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.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } +} + +func TestFormatPolicySetDefinitionID(t *testing.T) { + actual := NewPolicySetDefinitionID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionID(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestParsePolicySetDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Expected: &PolicySetDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionIDInsensitively(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + } +} + +func TestSegmentsForPolicySetDefinitionId(t *testing.T) { + segments := PolicySetDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionId 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/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource.go new file mode 100644 index 00000000000..7e461d0e015 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource.go @@ -0,0 +1,140 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{} + +// PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Policy Set Definition Providers 2 Policy State Policy States Resource +type PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId struct { + SubscriptionId string + PolicySetDefinitionName string + PolicyStatesResource PolicyStatesResource +} + +// NewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID returns a new PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId struct +func NewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(subscriptionId string, policySetDefinitionName string, policyStatesResource PolicyStatesResource) PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId { + return PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: subscriptionId, + PolicySetDefinitionName: policySetDefinitionName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID parses 'input' into a PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId +func ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(input string) (*PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(input string) (*PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PolicySetDefinitionName, ok = input.Parsed["policySetDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policySetDefinitionName", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidatePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Policy Set Definition Providers 2 Policy State Policy States Resource ID +func ValidatePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(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 := ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Set Definition Providers 2 Policy State Policy States Resource ID +func (id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Authorization/policySetDefinitions/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PolicySetDefinitionName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Set Definition Providers 2 Policy State Policy States Resource ID +func (id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("authorizationNamespace", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicySetDefinitions", "policySetDefinitions", "policySetDefinitions"), + resourceids.UserSpecifiedSegment("policySetDefinitionName", "policySetDefinitionName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Policy Set Definition Providers 2 Policy State Policy States Resource ID +func (id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy Set Definition Name: %q", id.PolicySetDefinitionName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Policy Set Definition Providers 2 Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..90cd0bde507 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policysetdefinitionproviders2policystatepolicystatesresource_test.go @@ -0,0 +1,312 @@ +package policystates + +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 = &PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{} + +func TestNewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "default") + + 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.PolicySetDefinitionName != "policySetDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'PolicySetDefinitionName'", id.PolicySetDefinitionName, "policySetDefinitionName") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "policySetDefinitionName", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceID(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "policySetDefinitionName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/policySetDefinitions/policySetDefinitionName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicySetDefinitionName: "pOlIcYsEtDeFiNiTiOnNaMe", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYsEtDeFiNiTiOnS/pOlIcYsEtDeFiNiTiOnNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicySetDefinitionProviders2PolicyStatePolicyStatesResourceIDInsensitively(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.PolicySetDefinitionName != v.Expected.PolicySetDefinitionName { + t.Fatalf("Expected %q but got %q for PolicySetDefinitionName", v.Expected.PolicySetDefinitionName, actual.PolicySetDefinitionName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForPolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId(t *testing.T) { + segments := PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource.go new file mode 100644 index 00000000000..3193ad40dd2 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource.go @@ -0,0 +1,138 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &PolicyStatePolicyStatesResourceId{} + +// PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Policy State Policy States Resource +type PolicyStatePolicyStatesResourceId struct { + SubscriptionId string + ResourceGroupName string + PolicyStatesResource PolicyStatesResource +} + +// NewPolicyStatePolicyStatesResourceID returns a new PolicyStatePolicyStatesResourceId struct +func NewPolicyStatePolicyStatesResourceID(subscriptionId string, resourceGroupName string, policyStatesResource PolicyStatesResource) PolicyStatePolicyStatesResourceId { + return PolicyStatePolicyStatesResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParsePolicyStatePolicyStatesResourceID parses 'input' into a PolicyStatePolicyStatesResourceId +func ParsePolicyStatePolicyStatesResourceID(input string) (*PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParsePolicyStatePolicyStatesResourceIDInsensitively(input string) (*PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyStatePolicyStatesResourceId) 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 v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidatePolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Policy State Policy States Resource ID +func ValidatePolicyStatePolicyStatesResourceID(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 := ParsePolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy State Policy States Resource ID +func (id PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy State Policy States Resource ID +func (id PolicyStatePolicyStatesResourceId) 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("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Policy State Policy States Resource ID +func (id PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..c3afab0db34 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatepolicystatesresource_test.go @@ -0,0 +1,282 @@ +package policystates + +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 = &PolicyStatePolicyStatesResourceId{} + +func TestNewPolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewPolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "default") + + 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.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatPolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewPolicyStatePolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyStatePolicyStatesResourceId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyStatePolicyStatesResourceID(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.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParsePolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyStatePolicyStatesResourceId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &PolicyStatePolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PolicyStatesResource: "default", + }, + }, + { + // 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.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyStatePolicyStatesResourceIDInsensitively(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.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForPolicyStatePolicyStatesResourceId(t *testing.T) { + segments := PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_policystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatesresource.go new file mode 100644 index 00000000000..4c4c4a1de2b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatesresource.go @@ -0,0 +1,129 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &PolicyStatesResourceId{} + +// PolicyStatesResourceId is a struct representing the Resource ID for a Policy States Resource +type PolicyStatesResourceId struct { + SubscriptionId string + PolicyStatesResource PolicyStatesResource +} + +// NewPolicyStatesResourceID returns a new PolicyStatesResourceId struct +func NewPolicyStatesResourceID(subscriptionId string, policyStatesResource PolicyStatesResource) PolicyStatesResourceId { + return PolicyStatesResourceId{ + SubscriptionId: subscriptionId, + PolicyStatesResource: policyStatesResource, + } +} + +// ParsePolicyStatesResourceID parses 'input' into a PolicyStatesResourceId +func ParsePolicyStatesResourceID(input string) (*PolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a PolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParsePolicyStatesResourceIDInsensitively(input string) (*PolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidatePolicyStatesResourceID checks that 'input' can be parsed as a Policy States Resource ID +func ValidatePolicyStatesResourceID(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 := ParsePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy States Resource ID +func (id PolicyStatesResourceId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy States Resource ID +func (id PolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Policy States Resource ID +func (id PolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_policystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatesresource_test.go new file mode 100644 index 00000000000..0dee8716abd --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_policystatesresource_test.go @@ -0,0 +1,237 @@ +package policystates + +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 = &PolicyStatesResourceId{} + +func TestNewPolicyStatesResourceID(t *testing.T) { + id := NewPolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "default") + + 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.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatPolicyStatesResourceID(t *testing.T) { + actual := NewPolicyStatesResourceID("12345678-1234-9876-4563-123456789012", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyStatesResourceID(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.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParsePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyStatesResourceId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &PolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &PolicyStatesResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyStatesResourceIDInsensitively(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.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForPolicyStatesResourceId(t *testing.T) { + segments := PolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource.go new file mode 100644 index 00000000000..bdf2f43803a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource.go @@ -0,0 +1,131 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&Providers2PolicyStatePolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &Providers2PolicyStatePolicyStatesResourceId{} + +// Providers2PolicyStatePolicyStatesResourceId is a struct representing the Resource ID for a Providers 2 Policy State Policy States Resource +type Providers2PolicyStatePolicyStatesResourceId struct { + ManagementGroupName string + PolicyStatesResource PolicyStatesResource +} + +// NewProviders2PolicyStatePolicyStatesResourceID returns a new Providers2PolicyStatePolicyStatesResourceId struct +func NewProviders2PolicyStatePolicyStatesResourceID(managementGroupName string, policyStatesResource PolicyStatesResource) Providers2PolicyStatePolicyStatesResourceId { + return Providers2PolicyStatePolicyStatesResourceId{ + ManagementGroupName: managementGroupName, + PolicyStatesResource: policyStatesResource, + } +} + +// ParseProviders2PolicyStatePolicyStatesResourceID parses 'input' into a Providers2PolicyStatePolicyStatesResourceId +func ParseProviders2PolicyStatePolicyStatesResourceID(input string) (*Providers2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2PolicyStatePolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a Providers2PolicyStatePolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParseProviders2PolicyStatePolicyStatesResourceIDInsensitively(input string) (*Providers2PolicyStatePolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2PolicyStatePolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2PolicyStatePolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2PolicyStatePolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupName, ok = input.Parsed["managementGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupName", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidateProviders2PolicyStatePolicyStatesResourceID checks that 'input' can be parsed as a Providers 2 Policy State Policy States Resource ID +func ValidateProviders2PolicyStatePolicyStatesResourceID(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 := ParseProviders2PolicyStatePolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Policy State Policy States Resource ID +func (id Providers2PolicyStatePolicyStatesResourceId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupName, string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Policy State Policy States Resource ID +func (id Providers2PolicyStatePolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupName", "managementGroupName"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Providers 2 Policy State Policy States Resource ID +func (id Providers2PolicyStatePolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Management Group Name: %q", id.ManagementGroupName), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Providers 2 Policy State Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource_test.go new file mode 100644 index 00000000000..39f4e4cda10 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_providers2policystatepolicystatesresource_test.go @@ -0,0 +1,267 @@ +package policystates + +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 = &Providers2PolicyStatePolicyStatesResourceId{} + +func TestNewProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + id := NewProviders2PolicyStatePolicyStatesResourceID("managementGroupName", "default") + + if id.ManagementGroupName != "managementGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupName'", id.ManagementGroupName, "managementGroupName") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + actual := NewProviders2PolicyStatePolicyStatesResourceID("managementGroupName", "default").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2PolicyStatePolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyStatePolicyStatesResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &Providers2PolicyStatePolicyStatesResourceId{ + ManagementGroupName: "managementGroupName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyStatePolicyStatesResourceID(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.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParseProviders2PolicyStatePolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2PolicyStatePolicyStatesResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &Providers2PolicyStatePolicyStatesResourceId{ + ManagementGroupName: "managementGroupName", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupName/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &Providers2PolicyStatePolicyStatesResourceId{ + ManagementGroupName: "mAnAgEmEnTgRoUpNaMe", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpNaMe/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2PolicyStatePolicyStatesResourceIDInsensitively(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.ManagementGroupName != v.Expected.ManagementGroupName { + t.Fatalf("Expected %q but got %q for ManagementGroupName", v.Expected.ManagementGroupName, actual.ManagementGroupName) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForProviders2PolicyStatePolicyStatesResourceId(t *testing.T) { + segments := Providers2PolicyStatePolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2PolicyStatePolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource.go b/resource-manager/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource.go new file mode 100644 index 00000000000..d1eecaff515 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource.go @@ -0,0 +1,128 @@ +package policystates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ScopedPolicyStatesResourceId{}) +} + +var _ resourceids.ResourceId = &ScopedPolicyStatesResourceId{} + +// ScopedPolicyStatesResourceId is a struct representing the Resource ID for a Scoped Policy States Resource +type ScopedPolicyStatesResourceId struct { + ResourceId string + PolicyStatesResource PolicyStatesResource +} + +// NewScopedPolicyStatesResourceID returns a new ScopedPolicyStatesResourceId struct +func NewScopedPolicyStatesResourceID(resourceId string, policyStatesResource PolicyStatesResource) ScopedPolicyStatesResourceId { + return ScopedPolicyStatesResourceId{ + ResourceId: resourceId, + PolicyStatesResource: policyStatesResource, + } +} + +// ParseScopedPolicyStatesResourceID parses 'input' into a ScopedPolicyStatesResourceId +func ParseScopedPolicyStatesResourceID(input string) (*ScopedPolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyStatesResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopedPolicyStatesResourceIDInsensitively parses 'input' case-insensitively into a ScopedPolicyStatesResourceId +// note: this method should only be used for API response data and not user input +func ParseScopedPolicyStatesResourceIDInsensitively(input string) (*ScopedPolicyStatesResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyStatesResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyStatesResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopedPolicyStatesResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ResourceId, ok = input.Parsed["resourceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceId", input) + } + + if v, ok := input.Parsed["policyStatesResource"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyStatesResource", input) + } + + policyStatesResource, err := parsePolicyStatesResource(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.PolicyStatesResource = *policyStatesResource + } + + return nil +} + +// ValidateScopedPolicyStatesResourceID checks that 'input' can be parsed as a Scoped Policy States Resource ID +func ValidateScopedPolicyStatesResourceID(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 := ParseScopedPolicyStatesResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Policy States Resource ID +func (id ScopedPolicyStatesResourceId) ID() string { + fmtString := "/%s/providers/Microsoft.PolicyInsights/policyStates/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.ResourceId, "/"), string(id.PolicyStatesResource)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Policy States Resource ID +func (id ScopedPolicyStatesResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("resourceId", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticPolicyStates", "policyStates", "policyStates"), + resourceids.ConstantSegment("policyStatesResource", PossibleValuesForPolicyStatesResource(), "default"), + } +} + +// String returns a human-readable description of this Scoped Policy States Resource ID +func (id ScopedPolicyStatesResourceId) String() string { + components := []string{ + fmt.Sprintf("Resource: %q", id.ResourceId), + fmt.Sprintf("Policy States Resource: %q", string(id.PolicyStatesResource)), + } + return fmt.Sprintf("Scoped Policy States Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource_test.go b/resource-manager/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource_test.go new file mode 100644 index 00000000000..8b22ef3a2b7 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/id_scopedpolicystatesresource_test.go @@ -0,0 +1,222 @@ +package policystates + +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 = &ScopedPolicyStatesResourceId{} + +func TestNewScopedPolicyStatesResourceID(t *testing.T) { + id := NewScopedPolicyStatesResourceID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "default") + + if id.ResourceId != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceId'", id.ResourceId, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } + + if id.PolicyStatesResource != "default" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyStatesResource'", id.PolicyStatesResource, "default") + } +} + +func TestFormatScopedPolicyStatesResourceID(t *testing.T) { + actual := NewScopedPolicyStatesResourceID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "default").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates/default" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopedPolicyStatesResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyStatesResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &ScopedPolicyStatesResourceId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyStatesResourceID(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestParseScopedPolicyStatesResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyStatesResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates/default", + Expected: &ScopedPolicyStatesResourceId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/policyStates/default/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt", + Expected: &ScopedPolicyStatesResourceId{ + ResourceId: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + PolicyStatesResource: "default", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/pOlIcYsTaTeS/dEfAuLt/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyStatesResourceIDInsensitively(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.PolicyStatesResource != v.Expected.PolicyStatesResource { + t.Fatalf("Expected %q but got %q for PolicyStatesResource", v.Expected.PolicyStatesResource, actual.PolicyStatesResource) + } + + } +} + +func TestSegmentsForScopedPolicyStatesResourceId(t *testing.T) { + segments := ScopedPolicyStatesResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopedPolicyStatesResourceId 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/policyinsights/2024-10-01/policystates/method_listqueryresultsformanagementgroup.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsformanagementgroup.go new file mode 100644 index 00000000000..4fb254c5b6e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsformanagementgroup.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForManagementGroupOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForManagementGroupOperationOptions() ListQueryResultsForManagementGroupOperationOptions { + return ListQueryResultsForManagementGroupOperationOptions{} +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForManagementGroupCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForManagementGroup ... +func (c PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context.Context, id Providers2PolicyStatePolicyStatesResourceId, options ListQueryResultsForManagementGroupOperationOptions) (result ListQueryResultsForManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForManagementGroupComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForManagementGroupComplete(ctx context.Context, id Providers2PolicyStatePolicyStatesResourceId, options ListQueryResultsForManagementGroupOperationOptions) (ListQueryResultsForManagementGroupCompleteResult, error) { + return c.ListQueryResultsForManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForManagementGroupCompleteMatchingPredicate(ctx context.Context, id Providers2PolicyStatePolicyStatesResourceId, options ListQueryResultsForManagementGroupOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForManagementGroupCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForManagementGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicydefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicydefinition.go new file mode 100644 index 00000000000..7b035e04b92 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicydefinition.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForPolicyDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForPolicyDefinitionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForPolicyDefinitionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForPolicyDefinitionOperationOptions() ListQueryResultsForPolicyDefinitionOperationOptions { + return ListQueryResultsForPolicyDefinitionOperationOptions{} +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForPolicyDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForPolicyDefinitionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForPolicyDefinitionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForPolicyDefinition ... +func (c PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context.Context, id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicyDefinitionOperationOptions) (result ListQueryResultsForPolicyDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForPolicyDefinitionCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForPolicyDefinitionComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForPolicyDefinitionComplete(ctx context.Context, id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicyDefinitionOperationOptions) (ListQueryResultsForPolicyDefinitionCompleteResult, error) { + return c.ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForPolicyDefinitionCompleteMatchingPredicate(ctx context.Context, id PolicyDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicyDefinitionOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForPolicyDefinitionCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForPolicyDefinition(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForPolicyDefinitionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicysetdefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicysetdefinition.go new file mode 100644 index 00000000000..54d4ec30278 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforpolicysetdefinition.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForPolicySetDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForPolicySetDefinitionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForPolicySetDefinitionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForPolicySetDefinitionOperationOptions() ListQueryResultsForPolicySetDefinitionOperationOptions { + return ListQueryResultsForPolicySetDefinitionOperationOptions{} +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForPolicySetDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForPolicySetDefinitionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForPolicySetDefinitionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForPolicySetDefinition ... +func (c PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx context.Context, id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicySetDefinitionOperationOptions) (result ListQueryResultsForPolicySetDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForPolicySetDefinitionCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForPolicySetDefinitionComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForPolicySetDefinitionComplete(ctx context.Context, id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicySetDefinitionOperationOptions) (ListQueryResultsForPolicySetDefinitionCompleteResult, error) { + return c.ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForPolicySetDefinitionCompleteMatchingPredicate(ctx context.Context, id PolicySetDefinitionProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForPolicySetDefinitionOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForPolicySetDefinitionCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForPolicySetDefinition(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForPolicySetDefinitionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresource.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresource.go new file mode 100644 index 00000000000..e2cdd181092 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresource.go @@ -0,0 +1,162 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForResourceOperationOptions struct { + Apply *string + Expand *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceOperationOptions() ListQueryResultsForResourceOperationOptions { + return ListQueryResultsForResourceOperationOptions{} +} + +func (o ListQueryResultsForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResource ... +func (c PolicyStatesClient) ListQueryResultsForResource(ctx context.Context, id ScopedPolicyStatesResourceId, options ListQueryResultsForResourceOperationOptions) (result ListQueryResultsForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForResourceComplete(ctx context.Context, id ScopedPolicyStatesResourceId, options ListQueryResultsForResourceOperationOptions) (ListQueryResultsForResourceCompleteResult, error) { + return c.ListQueryResultsForResourceCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForResourceCompleteMatchingPredicate(ctx context.Context, id ScopedPolicyStatesResourceId, options ListQueryResultsForResourceOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForResourceCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForResource(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegroup.go new file mode 100644 index 00000000000..a23babe3c23 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegroup.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForResourceGroupOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupOperationOptions() ListQueryResultsForResourceGroupOperationOptions { + return ListQueryResultsForResourceGroupOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceGroupCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResourceGroup ... +func (c PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Context, id PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupOperationOptions) (result ListQueryResultsForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceGroupComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForResourceGroupComplete(ctx context.Context, id PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupOperationOptions) (ListQueryResultsForResourceGroupCompleteResult, error) { + return c.ListQueryResultsForResourceGroupCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForResourceGroupCompleteMatchingPredicate(ctx context.Context, id PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForResourceGroupCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go new file mode 100644 index 00000000000..2912b8817d8 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforresourcegrouplevelpolicyassignment.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions() ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignment ... +func (c PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForResourceGroupLevelPolicyAssignmentCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentComplete(ctx context.Context, id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions) (ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult, error) { + return c.ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteMatchingPredicate(ctx context.Context, id AuthorizationNamespacePolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForResourceGroupLevelPolicyAssignmentOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForResourceGroupLevelPolicyAssignmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscription.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscription.go new file mode 100644 index 00000000000..0c40ec7c920 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscription.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForSubscriptionOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionOperationOptions() ListQueryResultsForSubscriptionOperationOptions { + return ListQueryResultsForSubscriptionOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForSubscriptionCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForSubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForSubscription ... +func (c PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Context, id PolicyStatesResourceId, options ListQueryResultsForSubscriptionOperationOptions) (result ListQueryResultsForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForSubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForSubscriptionComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForSubscriptionComplete(ctx context.Context, id PolicyStatesResourceId, options ListQueryResultsForSubscriptionOperationOptions) (ListQueryResultsForSubscriptionCompleteResult, error) { + return c.ListQueryResultsForSubscriptionCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForSubscriptionCompleteMatchingPredicate(ctx context.Context, id PolicyStatesResourceId, options ListQueryResultsForSubscriptionOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForSubscriptionCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForSubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go new file mode 100644 index 00000000000..11e7cad9778 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_listqueryresultsforsubscriptionlevelpolicyassignment.go @@ -0,0 +1,158 @@ +package policystates + +import ( + "context" + "fmt" + "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 ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyState +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyState +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions struct { + Apply *string + Filter *string + From *string + Orderby *string + Select *string + To *string + Top *int64 +} + +func DefaultListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions() ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions { + return ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions{} +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Apply != nil { + out.Append("$apply", fmt.Sprintf("%v", *o.Apply)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Select != nil { + out.Append("$select", fmt.Sprintf("%v", *o.Select)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignment ... +func (c PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) (result ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListQueryResultsForSubscriptionLevelPolicyAssignmentCustomPager{}, + Path: fmt.Sprintf("%s/queryResults", 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 *[]PolicyState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete retrieves all the results into a single object +func (c PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentComplete(ctx context.Context, id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions) (ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult, error) { + return c.ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate(ctx, id, options, PolicyStateOperationPredicate{}) +} + +// ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteMatchingPredicate(ctx context.Context, id PolicyAssignmentProviders2PolicyStatePolicyStatesResourceId, options ListQueryResultsForSubscriptionLevelPolicyAssignmentOperationOptions, predicate PolicyStateOperationPredicate) (result ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult, err error) { + items := make([]PolicyState, 0) + + resp, err := c.ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListQueryResultsForSubscriptionLevelPolicyAssignmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeformanagementgroup.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeformanagementgroup.go new file mode 100644 index 00000000000..8f2eca24973 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeformanagementgroup.go @@ -0,0 +1,95 @@ +package policystates + +import ( + "context" + "fmt" + "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 SummarizeForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForManagementGroupOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForManagementGroupOperationOptions() SummarizeForManagementGroupOperationOptions { + return SummarizeForManagementGroupOperationOptions{} +} + +func (o SummarizeForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForManagementGroup ... +func (c PolicyStatesClient) SummarizeForManagementGroup(ctx context.Context, id ManagementGroupId, options SummarizeForManagementGroupOperationOptions) (result SummarizeForManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicydefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicydefinition.go new file mode 100644 index 00000000000..4063611d5b6 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicydefinition.go @@ -0,0 +1,95 @@ +package policystates + +import ( + "context" + "fmt" + "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 SummarizeForPolicyDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForPolicyDefinitionOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForPolicyDefinitionOperationOptions() SummarizeForPolicyDefinitionOperationOptions { + return SummarizeForPolicyDefinitionOperationOptions{} +} + +func (o SummarizeForPolicyDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForPolicyDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForPolicyDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForPolicyDefinition ... +func (c PolicyStatesClient) SummarizeForPolicyDefinition(ctx context.Context, id PolicyDefinitionId, options SummarizeForPolicyDefinitionOperationOptions) (result SummarizeForPolicyDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicysetdefinition.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicysetdefinition.go new file mode 100644 index 00000000000..2b11c5f6231 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforpolicysetdefinition.go @@ -0,0 +1,95 @@ +package policystates + +import ( + "context" + "fmt" + "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 SummarizeForPolicySetDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForPolicySetDefinitionOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForPolicySetDefinitionOperationOptions() SummarizeForPolicySetDefinitionOperationOptions { + return SummarizeForPolicySetDefinitionOperationOptions{} +} + +func (o SummarizeForPolicySetDefinitionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForPolicySetDefinitionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForPolicySetDefinitionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForPolicySetDefinition ... +func (c PolicyStatesClient) SummarizeForPolicySetDefinition(ctx context.Context, id PolicySetDefinitionId, options SummarizeForPolicySetDefinitionOperationOptions) (result SummarizeForPolicySetDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresource.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresource.go new file mode 100644 index 00000000000..5121395cdd6 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresource.go @@ -0,0 +1,96 @@ +package policystates + +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 SummarizeForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForResourceOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForResourceOperationOptions() SummarizeForResourceOperationOptions { + return SummarizeForResourceOperationOptions{} +} + +func (o SummarizeForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForResource ... +func (c PolicyStatesClient) SummarizeForResource(ctx context.Context, id commonids.ScopeId, options SummarizeForResourceOperationOptions) (result SummarizeForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegroup.go new file mode 100644 index 00000000000..ac7948d0e91 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegroup.go @@ -0,0 +1,96 @@ +package policystates + +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 SummarizeForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForResourceGroupOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForResourceGroupOperationOptions() SummarizeForResourceGroupOperationOptions { + return SummarizeForResourceGroupOperationOptions{} +} + +func (o SummarizeForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForResourceGroup ... +func (c PolicyStatesClient) SummarizeForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options SummarizeForResourceGroupOperationOptions) (result SummarizeForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegrouplevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegrouplevelpolicyassignment.go new file mode 100644 index 00000000000..84aa7d51645 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforresourcegrouplevelpolicyassignment.go @@ -0,0 +1,95 @@ +package policystates + +import ( + "context" + "fmt" + "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 SummarizeForResourceGroupLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForResourceGroupLevelPolicyAssignmentOperationOptions() SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions { + return SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions{} +} + +func (o SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForResourceGroupLevelPolicyAssignment ... +func (c PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, id AuthorizationNamespacePolicyAssignmentId, options SummarizeForResourceGroupLevelPolicyAssignmentOperationOptions) (result SummarizeForResourceGroupLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscription.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscription.go new file mode 100644 index 00000000000..1e62276ffc9 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscription.go @@ -0,0 +1,96 @@ +package policystates + +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 SummarizeForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForSubscriptionOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForSubscriptionOperationOptions() SummarizeForSubscriptionOperationOptions { + return SummarizeForSubscriptionOperationOptions{} +} + +func (o SummarizeForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForSubscription ... +func (c PolicyStatesClient) SummarizeForSubscription(ctx context.Context, id commonids.SubscriptionId, options SummarizeForSubscriptionOperationOptions) (result SummarizeForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscriptionlevelpolicyassignment.go b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscriptionlevelpolicyassignment.go new file mode 100644 index 00000000000..dc34760429d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_summarizeforsubscriptionlevelpolicyassignment.go @@ -0,0 +1,95 @@ +package policystates + +import ( + "context" + "fmt" + "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 SummarizeForSubscriptionLevelPolicyAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SummarizeResults +} + +type SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions struct { + Filter *string + From *string + To *string + Top *int64 +} + +func DefaultSummarizeForSubscriptionLevelPolicyAssignmentOperationOptions() SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions { + return SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions{} +} + +func (o SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.From != nil { + out.Append("$from", fmt.Sprintf("%v", *o.From)) + } + if o.To != nil { + out.Append("$to", fmt.Sprintf("%v", *o.To)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// SummarizeForSubscriptionLevelPolicyAssignment ... +func (c PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, id PolicyAssignmentId, options SummarizeForSubscriptionLevelPolicyAssignmentOperationOptions) (result SummarizeForSubscriptionLevelPolicyAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/policyStates/latest/summarize", 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 + } + + var model SummarizeResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_triggerresourcegroupevaluation.go b/resource-manager/policyinsights/2024-10-01/policystates/method_triggerresourcegroupevaluation.go new file mode 100644 index 00000000000..4ef02afaec4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_triggerresourcegroupevaluation.go @@ -0,0 +1,71 @@ +package policystates + +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 TriggerResourceGroupEvaluationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// TriggerResourceGroupEvaluation ... +func (c PolicyStatesClient) TriggerResourceGroupEvaluation(ctx context.Context, id commonids.ResourceGroupId) (result TriggerResourceGroupEvaluationOperationResponse, 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.PolicyInsights/policyStates/latest/triggerEvaluation", 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 +} + +// TriggerResourceGroupEvaluationThenPoll performs TriggerResourceGroupEvaluation then polls until it's completed +func (c PolicyStatesClient) TriggerResourceGroupEvaluationThenPoll(ctx context.Context, id commonids.ResourceGroupId) error { + result, err := c.TriggerResourceGroupEvaluation(ctx, id) + if err != nil { + return fmt.Errorf("performing TriggerResourceGroupEvaluation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TriggerResourceGroupEvaluation: %+v", err) + } + + return nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/method_triggersubscriptionevaluation.go b/resource-manager/policyinsights/2024-10-01/policystates/method_triggersubscriptionevaluation.go new file mode 100644 index 00000000000..b764ea73868 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/method_triggersubscriptionevaluation.go @@ -0,0 +1,71 @@ +package policystates + +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 TriggerSubscriptionEvaluationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// TriggerSubscriptionEvaluation ... +func (c PolicyStatesClient) TriggerSubscriptionEvaluation(ctx context.Context, id commonids.SubscriptionId) (result TriggerSubscriptionEvaluationOperationResponse, 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.PolicyInsights/policyStates/latest/triggerEvaluation", 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 +} + +// TriggerSubscriptionEvaluationThenPoll performs TriggerSubscriptionEvaluation then polls until it's completed +func (c PolicyStatesClient) TriggerSubscriptionEvaluationThenPoll(ctx context.Context, id commonids.SubscriptionId) error { + result, err := c.TriggerSubscriptionEvaluation(ctx, id) + if err != nil { + return fmt.Errorf("performing TriggerSubscriptionEvaluation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TriggerSubscriptionEvaluation: %+v", err) + } + + return nil +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_compliancedetail.go b/resource-manager/policyinsights/2024-10-01/policystates/model_compliancedetail.go new file mode 100644 index 00000000000..dcc30dfb8e8 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_compliancedetail.go @@ -0,0 +1,9 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComplianceDetail struct { + ComplianceState *string `json:"complianceState,omitempty"` + Count *int64 `json:"count,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_componentstatedetails.go b/resource-manager/policyinsights/2024-10-01/policystates/model_componentstatedetails.go new file mode 100644 index 00000000000..5d02bb1fe24 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_componentstatedetails.go @@ -0,0 +1,30 @@ +package policystates + +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 ComponentStateDetails struct { + ComplianceState *string `json:"complianceState,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (o *ComponentStateDetails) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComponentStateDetails) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_expressionevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/policystates/model_expressionevaluationdetails.go new file mode 100644 index 00000000000..90875f954a5 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_expressionevaluationdetails.go @@ -0,0 +1,14 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressionEvaluationDetails struct { + Expression *string `json:"expression,omitempty"` + ExpressionKind *string `json:"expressionKind,omitempty"` + ExpressionValue *interface{} `json:"expressionValue,omitempty"` + Operator *string `json:"operator,omitempty"` + Path *string `json:"path,omitempty"` + Result *string `json:"result,omitempty"` + TargetValue *interface{} `json:"targetValue,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_ifnotexistsevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/policystates/model_ifnotexistsevaluationdetails.go new file mode 100644 index 00000000000..bccc0fd746f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_ifnotexistsevaluationdetails.go @@ -0,0 +1,9 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IfNotExistsEvaluationDetails struct { + ResourceId *string `json:"resourceId,omitempty"` + TotalResources *int64 `json:"totalResources,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_policyassignmentsummary.go b/resource-manager/policyinsights/2024-10-01/policystates/model_policyassignmentsummary.go new file mode 100644 index 00000000000..a0461306023 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_policyassignmentsummary.go @@ -0,0 +1,12 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentSummary struct { + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyDefinitions *[]PolicyDefinitionSummary `json:"policyDefinitions,omitempty"` + PolicyGroups *[]PolicyGroupSummary `json:"policyGroups,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` + Results *SummaryResults `json:"results,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_policydefinitionsummary.go b/resource-manager/policyinsights/2024-10-01/policystates/model_policydefinitionsummary.go new file mode 100644 index 00000000000..4774b619a1e --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_policydefinitionsummary.go @@ -0,0 +1,12 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyDefinitionSummary struct { + Effect *string `json:"effect,omitempty"` + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + Results *SummaryResults `json:"results,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_policyevaluationdetails.go b/resource-manager/policyinsights/2024-10-01/policystates/model_policyevaluationdetails.go new file mode 100644 index 00000000000..e0cd7cc7609 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_policyevaluationdetails.go @@ -0,0 +1,9 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyEvaluationDetails struct { + EvaluatedExpressions *[]ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` + IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_policygroupsummary.go b/resource-manager/policyinsights/2024-10-01/policystates/model_policygroupsummary.go new file mode 100644 index 00000000000..cbc0ad7a359 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_policygroupsummary.go @@ -0,0 +1,9 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyGroupSummary struct { + PolicyGroupName *string `json:"policyGroupName,omitempty"` + Results *SummaryResults `json:"results,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_policystate.go b/resource-manager/policyinsights/2024-10-01/policystates/model_policystate.go new file mode 100644 index 00000000000..3b6241f69e1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_policystate.go @@ -0,0 +1,59 @@ +package policystates + +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 PolicyState struct { + ComplianceState *string `json:"complianceState,omitempty"` + Components *[]ComponentStateDetails `json:"components,omitempty"` + EffectiveParameters *string `json:"effectiveParameters,omitempty"` + IsCompliant *bool `json:"isCompliant,omitempty"` + ManagementGroupIds *string `json:"managementGroupIds,omitempty"` + OdataContext *string `json:"@odata.context,omitempty"` + OdataId *string `json:"@odata.id,omitempty"` + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` + PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` + PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` + PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` + PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty"` + PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` + PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` + PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty"` + PolicyEvaluationDetails *PolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` + PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` + PolicySetDefinitionId *string `json:"policySetDefinitionId,omitempty"` + PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` + PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` + PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` + PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceTags *string `json:"resourceTags,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` +} + +func (o *PolicyState) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *PolicyState) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_summarizeresults.go b/resource-manager/policyinsights/2024-10-01/policystates/model_summarizeresults.go new file mode 100644 index 00000000000..22b4efe1e7c --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_summarizeresults.go @@ -0,0 +1,10 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SummarizeResults struct { + OdataContext *string `json:"@odata.context,omitempty"` + OdataCount *int64 `json:"@odata.count,omitempty"` + Value *[]Summary `json:"value,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_summary.go b/resource-manager/policyinsights/2024-10-01/policystates/model_summary.go new file mode 100644 index 00000000000..66ecb95cdc0 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_summary.go @@ -0,0 +1,11 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Summary struct { + OdataContext *string `json:"@odata.context,omitempty"` + OdataId *string `json:"@odata.id,omitempty"` + PolicyAssignments *[]PolicyAssignmentSummary `json:"policyAssignments,omitempty"` + Results *SummaryResults `json:"results,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/model_summaryresults.go b/resource-manager/policyinsights/2024-10-01/policystates/model_summaryresults.go new file mode 100644 index 00000000000..45ed07782f9 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/model_summaryresults.go @@ -0,0 +1,13 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SummaryResults struct { + NonCompliantPolicies *int64 `json:"nonCompliantPolicies,omitempty"` + NonCompliantResources *int64 `json:"nonCompliantResources,omitempty"` + PolicyDetails *[]ComplianceDetail `json:"policyDetails,omitempty"` + PolicyGroupDetails *[]ComplianceDetail `json:"policyGroupDetails,omitempty"` + QueryResultsUri *string `json:"queryResultsUri,omitempty"` + ResourceDetails *[]ComplianceDetail `json:"resourceDetails,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/predicates.go b/resource-manager/policyinsights/2024-10-01/policystates/predicates.go new file mode 100644 index 00000000000..c83be19a8cb --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/predicates.go @@ -0,0 +1,167 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyStateOperationPredicate struct { + ComplianceState *string + EffectiveParameters *string + IsCompliant *bool + ManagementGroupIds *string + OdataContext *string + OdataId *string + PolicyAssignmentId *string + PolicyAssignmentName *string + PolicyAssignmentOwner *string + PolicyAssignmentParameters *string + PolicyAssignmentScope *string + PolicyAssignmentVersion *string + PolicyDefinitionAction *string + PolicyDefinitionCategory *string + PolicyDefinitionId *string + PolicyDefinitionName *string + PolicyDefinitionReferenceId *string + PolicyDefinitionVersion *string + PolicySetDefinitionCategory *string + PolicySetDefinitionId *string + PolicySetDefinitionName *string + PolicySetDefinitionOwner *string + PolicySetDefinitionParameters *string + PolicySetDefinitionVersion *string + ResourceGroup *string + ResourceId *string + ResourceLocation *string + ResourceTags *string + ResourceType *string + SubscriptionId *string + Timestamp *string +} + +func (p PolicyStateOperationPredicate) Matches(input PolicyState) bool { + + if p.ComplianceState != nil && (input.ComplianceState == nil || *p.ComplianceState != *input.ComplianceState) { + return false + } + + if p.EffectiveParameters != nil && (input.EffectiveParameters == nil || *p.EffectiveParameters != *input.EffectiveParameters) { + return false + } + + if p.IsCompliant != nil && (input.IsCompliant == nil || *p.IsCompliant != *input.IsCompliant) { + return false + } + + if p.ManagementGroupIds != nil && (input.ManagementGroupIds == nil || *p.ManagementGroupIds != *input.ManagementGroupIds) { + return false + } + + if p.OdataContext != nil && (input.OdataContext == nil || *p.OdataContext != *input.OdataContext) { + return false + } + + if p.OdataId != nil && (input.OdataId == nil || *p.OdataId != *input.OdataId) { + return false + } + + if p.PolicyAssignmentId != nil && (input.PolicyAssignmentId == nil || *p.PolicyAssignmentId != *input.PolicyAssignmentId) { + return false + } + + if p.PolicyAssignmentName != nil && (input.PolicyAssignmentName == nil || *p.PolicyAssignmentName != *input.PolicyAssignmentName) { + return false + } + + if p.PolicyAssignmentOwner != nil && (input.PolicyAssignmentOwner == nil || *p.PolicyAssignmentOwner != *input.PolicyAssignmentOwner) { + return false + } + + if p.PolicyAssignmentParameters != nil && (input.PolicyAssignmentParameters == nil || *p.PolicyAssignmentParameters != *input.PolicyAssignmentParameters) { + return false + } + + if p.PolicyAssignmentScope != nil && (input.PolicyAssignmentScope == nil || *p.PolicyAssignmentScope != *input.PolicyAssignmentScope) { + return false + } + + if p.PolicyAssignmentVersion != nil && (input.PolicyAssignmentVersion == nil || *p.PolicyAssignmentVersion != *input.PolicyAssignmentVersion) { + return false + } + + if p.PolicyDefinitionAction != nil && (input.PolicyDefinitionAction == nil || *p.PolicyDefinitionAction != *input.PolicyDefinitionAction) { + return false + } + + if p.PolicyDefinitionCategory != nil && (input.PolicyDefinitionCategory == nil || *p.PolicyDefinitionCategory != *input.PolicyDefinitionCategory) { + return false + } + + if p.PolicyDefinitionId != nil && (input.PolicyDefinitionId == nil || *p.PolicyDefinitionId != *input.PolicyDefinitionId) { + return false + } + + if p.PolicyDefinitionName != nil && (input.PolicyDefinitionName == nil || *p.PolicyDefinitionName != *input.PolicyDefinitionName) { + return false + } + + if p.PolicyDefinitionReferenceId != nil && (input.PolicyDefinitionReferenceId == nil || *p.PolicyDefinitionReferenceId != *input.PolicyDefinitionReferenceId) { + return false + } + + if p.PolicyDefinitionVersion != nil && (input.PolicyDefinitionVersion == nil || *p.PolicyDefinitionVersion != *input.PolicyDefinitionVersion) { + return false + } + + if p.PolicySetDefinitionCategory != nil && (input.PolicySetDefinitionCategory == nil || *p.PolicySetDefinitionCategory != *input.PolicySetDefinitionCategory) { + return false + } + + if p.PolicySetDefinitionId != nil && (input.PolicySetDefinitionId == nil || *p.PolicySetDefinitionId != *input.PolicySetDefinitionId) { + return false + } + + if p.PolicySetDefinitionName != nil && (input.PolicySetDefinitionName == nil || *p.PolicySetDefinitionName != *input.PolicySetDefinitionName) { + return false + } + + if p.PolicySetDefinitionOwner != nil && (input.PolicySetDefinitionOwner == nil || *p.PolicySetDefinitionOwner != *input.PolicySetDefinitionOwner) { + return false + } + + if p.PolicySetDefinitionParameters != nil && (input.PolicySetDefinitionParameters == nil || *p.PolicySetDefinitionParameters != *input.PolicySetDefinitionParameters) { + return false + } + + if p.PolicySetDefinitionVersion != nil && (input.PolicySetDefinitionVersion == nil || *p.PolicySetDefinitionVersion != *input.PolicySetDefinitionVersion) { + return false + } + + if p.ResourceGroup != nil && (input.ResourceGroup == nil || *p.ResourceGroup != *input.ResourceGroup) { + return false + } + + if p.ResourceId != nil && (input.ResourceId == nil || *p.ResourceId != *input.ResourceId) { + return false + } + + if p.ResourceLocation != nil && (input.ResourceLocation == nil || *p.ResourceLocation != *input.ResourceLocation) { + return false + } + + if p.ResourceTags != nil && (input.ResourceTags == nil || *p.ResourceTags != *input.ResourceTags) { + return false + } + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + if p.SubscriptionId != nil && (input.SubscriptionId == nil || *p.SubscriptionId != *input.SubscriptionId) { + return false + } + + if p.Timestamp != nil && (input.Timestamp == nil || *p.Timestamp != *input.Timestamp) { + return false + } + + return true +} diff --git a/resource-manager/policyinsights/2024-10-01/policystates/version.go b/resource-manager/policyinsights/2024-10-01/policystates/version.go new file mode 100644 index 00000000000..b7fd8a702d0 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/policystates/version.go @@ -0,0 +1,10 @@ +package policystates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/policystates/2024-10-01" +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/README.md b/resource-manager/policyinsights/2024-10-01/remediations/README.md new file mode 100644 index 00000000000..f3be5c59c8b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/README.md @@ -0,0 +1,433 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/remediations` Documentation + +The `remediations` SDK allows for interaction with Azure Resource Manager `policyinsights` (API Version `2024-10-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2024-10-01/remediations" +``` + + +### Client Initialization + +```go +client := remediations.NewRemediationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RemediationsClient.CancelAtManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviders2RemediationID("managementGroupId", "remediationName") + +read, err := client.CancelAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CancelAtResource` + +```go +ctx := context.TODO() +id := remediations.NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + +read, err := client.CancelAtResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CancelAtResourceGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + +read, err := client.CancelAtResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CancelAtSubscription` + +```go +ctx := context.TODO() +id := remediations.NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + +read, err := client.CancelAtSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CreateOrUpdateAtManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviders2RemediationID("managementGroupId", "remediationName") + +payload := remediations.Remediation{ + // ... +} + + +read, err := client.CreateOrUpdateAtManagementGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CreateOrUpdateAtResource` + +```go +ctx := context.TODO() +id := remediations.NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + +payload := remediations.Remediation{ + // ... +} + + +read, err := client.CreateOrUpdateAtResource(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CreateOrUpdateAtResourceGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + +payload := remediations.Remediation{ + // ... +} + + +read, err := client.CreateOrUpdateAtResourceGroup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.CreateOrUpdateAtSubscription` + +```go +ctx := context.TODO() +id := remediations.NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + +payload := remediations.Remediation{ + // ... +} + + +read, err := client.CreateOrUpdateAtSubscription(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.DeleteAtManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviders2RemediationID("managementGroupId", "remediationName") + +read, err := client.DeleteAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.DeleteAtResource` + +```go +ctx := context.TODO() +id := remediations.NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + +read, err := client.DeleteAtResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.DeleteAtResourceGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + +read, err := client.DeleteAtResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.DeleteAtSubscription` + +```go +ctx := context.TODO() +id := remediations.NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + +read, err := client.DeleteAtSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.GetAtManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviders2RemediationID("managementGroupId", "remediationName") + +read, err := client.GetAtManagementGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.GetAtResource` + +```go +ctx := context.TODO() +id := remediations.NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + +read, err := client.GetAtResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.GetAtResourceGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + +read, err := client.GetAtResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.GetAtSubscription` + +```go +ctx := context.TODO() +id := remediations.NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + +read, err := client.GetAtSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RemediationsClient.ListDeploymentsAtManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviders2RemediationID("managementGroupId", "remediationName") + +// alternatively `client.ListDeploymentsAtManagementGroup(ctx, id, remediations.DefaultListDeploymentsAtManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListDeploymentsAtManagementGroupComplete(ctx, id, remediations.DefaultListDeploymentsAtManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListDeploymentsAtResource` + +```go +ctx := context.TODO() +id := remediations.NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + +// alternatively `client.ListDeploymentsAtResource(ctx, id, remediations.DefaultListDeploymentsAtResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListDeploymentsAtResourceComplete(ctx, id, remediations.DefaultListDeploymentsAtResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListDeploymentsAtResourceGroup` + +```go +ctx := context.TODO() +id := remediations.NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + +// alternatively `client.ListDeploymentsAtResourceGroup(ctx, id, remediations.DefaultListDeploymentsAtResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListDeploymentsAtResourceGroupComplete(ctx, id, remediations.DefaultListDeploymentsAtResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListDeploymentsAtSubscription` + +```go +ctx := context.TODO() +id := remediations.NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + +// alternatively `client.ListDeploymentsAtSubscription(ctx, id, remediations.DefaultListDeploymentsAtSubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListDeploymentsAtSubscriptionComplete(ctx, id, remediations.DefaultListDeploymentsAtSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListForManagementGroup` + +```go +ctx := context.TODO() +id := remediations.NewManagementGroupID("managementGroupId") + +// alternatively `client.ListForManagementGroup(ctx, id, remediations.DefaultListForManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForManagementGroupComplete(ctx, id, remediations.DefaultListForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListForResource(ctx, id, remediations.DefaultListForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceComplete(ctx, id, remediations.DefaultListForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListForResourceGroup(ctx, id, remediations.DefaultListForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceGroupComplete(ctx, id, remediations.DefaultListForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RemediationsClient.ListForSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListForSubscription(ctx, id, remediations.DefaultListForSubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListForSubscriptionComplete(ctx, id, remediations.DefaultListForSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/policyinsights/2024-10-01/remediations/client.go b/resource-manager/policyinsights/2024-10-01/remediations/client.go new file mode 100644 index 00000000000..105289dfacf --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/client.go @@ -0,0 +1,26 @@ +package remediations + +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 RemediationsClient struct { + Client *resourcemanager.Client +} + +func NewRemediationsClientWithBaseURI(sdkApi sdkEnv.Api) (*RemediationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "remediations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RemediationsClient: %+v", err) + } + + return &RemediationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/constants.go b/resource-manager/policyinsights/2024-10-01/remediations/constants.go new file mode 100644 index 00000000000..1ae4ef14412 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/constants.go @@ -0,0 +1,51 @@ +package remediations + +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 ResourceDiscoveryMode string + +const ( + ResourceDiscoveryModeExistingNonCompliant ResourceDiscoveryMode = "ExistingNonCompliant" + ResourceDiscoveryModeReEvaluateCompliance ResourceDiscoveryMode = "ReEvaluateCompliance" +) + +func PossibleValuesForResourceDiscoveryMode() []string { + return []string{ + string(ResourceDiscoveryModeExistingNonCompliant), + string(ResourceDiscoveryModeReEvaluateCompliance), + } +} + +func (s *ResourceDiscoveryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceDiscoveryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceDiscoveryMode(input string) (*ResourceDiscoveryMode, error) { + vals := map[string]ResourceDiscoveryMode{ + "existingnoncompliant": ResourceDiscoveryModeExistingNonCompliant, + "reevaluatecompliance": ResourceDiscoveryModeReEvaluateCompliance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceDiscoveryMode(input) + return &out, nil +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup.go new file mode 100644 index 00000000000..88b7c18d67b --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup.go @@ -0,0 +1,112 @@ +package remediations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementGroupId{}) +} + +var _ resourceids.ResourceId = &ManagementGroupId{} + +// ManagementGroupId is a struct representing the Resource ID for a Management Group +type ManagementGroupId struct { + ManagementGroupId string +} + +// NewManagementGroupID returns a new ManagementGroupId struct +func NewManagementGroupID(managementGroupId string) ManagementGroupId { + return ManagementGroupId{ + ManagementGroupId: managementGroupId, + } +} + +// ParseManagementGroupID parses 'input' into a ManagementGroupId +func ParseManagementGroupID(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementGroupIDInsensitively parses 'input' case-insensitively into a ManagementGroupId +// note: this method should only be used for API response data and not user input +func ParseManagementGroupIDInsensitively(input string) (*ManagementGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + return nil +} + +// ValidateManagementGroupID checks that 'input' can be parsed as a Management Group ID +func ValidateManagementGroupID(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 := ParseManagementGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Group ID +func (id ManagementGroupId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Group ID +func (id ManagementGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + } +} + +// String returns a human-readable description of this Management Group ID +func (id ManagementGroupId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + } + return fmt.Sprintf("Management Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup_test.go b/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup_test.go new file mode 100644 index 00000000000..0bc15a1a52c --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_managementgroup_test.go @@ -0,0 +1,192 @@ +package remediations + +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 = &ManagementGroupId{} + +func TestNewManagementGroupID(t *testing.T) { + id := NewManagementGroupID("managementGroupId") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } +} + +func TestFormatManagementGroupID(t *testing.T) { + actual := NewManagementGroupID("managementGroupId").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupID(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestParseManagementGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Expected: &ManagementGroupId{ + ManagementGroupId: "managementGroupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Expected: &ManagementGroupId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementGroupIDInsensitively(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + } +} + +func TestSegmentsForManagementGroupId(t *testing.T) { + segments := ManagementGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementGroupId 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/policyinsights/2024-10-01/remediations/id_providerremediation.go b/resource-manager/policyinsights/2024-10-01/remediations/id_providerremediation.go new file mode 100644 index 00000000000..50917d7f60d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_providerremediation.go @@ -0,0 +1,130 @@ +package remediations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderRemediationId{}) +} + +var _ resourceids.ResourceId = &ProviderRemediationId{} + +// ProviderRemediationId is a struct representing the Resource ID for a Provider Remediation +type ProviderRemediationId struct { + SubscriptionId string + ResourceGroupName string + RemediationName string +} + +// NewProviderRemediationID returns a new ProviderRemediationId struct +func NewProviderRemediationID(subscriptionId string, resourceGroupName string, remediationName string) ProviderRemediationId { + return ProviderRemediationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RemediationName: remediationName, + } +} + +// ParseProviderRemediationID parses 'input' into a ProviderRemediationId +func ParseProviderRemediationID(input string) (*ProviderRemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderRemediationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderRemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderRemediationIDInsensitively parses 'input' case-insensitively into a ProviderRemediationId +// note: this method should only be used for API response data and not user input +func ParseProviderRemediationIDInsensitively(input string) (*ProviderRemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderRemediationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderRemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderRemediationId) 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.RemediationName, ok = input.Parsed["remediationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remediationName", input) + } + + return nil +} + +// ValidateProviderRemediationID checks that 'input' can be parsed as a Provider Remediation ID +func ValidateProviderRemediationID(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 := ParseProviderRemediationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Remediation ID +func (id ProviderRemediationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.PolicyInsights/remediations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RemediationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Remediation ID +func (id ProviderRemediationId) 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("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticRemediations", "remediations", "remediations"), + resourceids.UserSpecifiedSegment("remediationName", "remediationName"), + } +} + +// String returns a human-readable description of this Provider Remediation ID +func (id ProviderRemediationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Remediation Name: %q", id.RemediationName), + } + return fmt.Sprintf("Provider Remediation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_providerremediation_test.go b/resource-manager/policyinsights/2024-10-01/remediations/id_providerremediation_test.go new file mode 100644 index 00000000000..fd05b11d54a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_providerremediation_test.go @@ -0,0 +1,282 @@ +package remediations + +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 = &ProviderRemediationId{} + +func TestNewProviderRemediationID(t *testing.T) { + id := NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName") + + 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.RemediationName != "remediationName" { + t.Fatalf("Expected %q but got %q for Segment 'RemediationName'", id.RemediationName, "remediationName") + } +} + +func TestFormatProviderRemediationID(t *testing.T) { + actual := NewProviderRemediationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "remediationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderRemediationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderRemediationId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &ProviderRemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderRemediationID(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.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestParseProviderRemediationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderRemediationId + }{ + { + // 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.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &ProviderRemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe", + Expected: &ProviderRemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RemediationName: "rEmEdIaTiOnNaMe", + }, + }, + { + // 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.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderRemediationIDInsensitively(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.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestSegmentsForProviderRemediationId(t *testing.T) { + segments := ProviderRemediationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderRemediationId 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/policyinsights/2024-10-01/remediations/id_providers2remediation.go b/resource-manager/policyinsights/2024-10-01/remediations/id_providers2remediation.go new file mode 100644 index 00000000000..8149bbd604f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_providers2remediation.go @@ -0,0 +1,123 @@ +package remediations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&Providers2RemediationId{}) +} + +var _ resourceids.ResourceId = &Providers2RemediationId{} + +// Providers2RemediationId is a struct representing the Resource ID for a Providers 2 Remediation +type Providers2RemediationId struct { + ManagementGroupId string + RemediationName string +} + +// NewProviders2RemediationID returns a new Providers2RemediationId struct +func NewProviders2RemediationID(managementGroupId string, remediationName string) Providers2RemediationId { + return Providers2RemediationId{ + ManagementGroupId: managementGroupId, + RemediationName: remediationName, + } +} + +// ParseProviders2RemediationID parses 'input' into a Providers2RemediationId +func ParseProviders2RemediationID(input string) (*Providers2RemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2RemediationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2RemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2RemediationIDInsensitively parses 'input' case-insensitively into a Providers2RemediationId +// note: this method should only be used for API response data and not user input +func ParseProviders2RemediationIDInsensitively(input string) (*Providers2RemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2RemediationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2RemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2RemediationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + if id.RemediationName, ok = input.Parsed["remediationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remediationName", input) + } + + return nil +} + +// ValidateProviders2RemediationID checks that 'input' can be parsed as a Providers 2 Remediation ID +func ValidateProviders2RemediationID(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 := ParseProviders2RemediationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Remediation ID +func (id Providers2RemediationId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.PolicyInsights/remediations/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId, id.RemediationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Remediation ID +func (id Providers2RemediationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.StaticSegment("managementGroupsNamespace", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticRemediations", "remediations", "remediations"), + resourceids.UserSpecifiedSegment("remediationName", "remediationName"), + } +} + +// String returns a human-readable description of this Providers 2 Remediation ID +func (id Providers2RemediationId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + fmt.Sprintf("Remediation Name: %q", id.RemediationName), + } + return fmt.Sprintf("Providers 2 Remediation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_providers2remediation_test.go b/resource-manager/policyinsights/2024-10-01/remediations/id_providers2remediation_test.go new file mode 100644 index 00000000000..d94648328f3 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_providers2remediation_test.go @@ -0,0 +1,267 @@ +package remediations + +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 = &Providers2RemediationId{} + +func TestNewProviders2RemediationID(t *testing.T) { + id := NewProviders2RemediationID("managementGroupId", "remediationName") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } + + if id.RemediationName != "remediationName" { + t.Fatalf("Expected %q but got %q for Segment 'RemediationName'", id.RemediationName, "remediationName") + } +} + +func TestFormatProviders2RemediationID(t *testing.T) { + actual := NewProviders2RemediationID("managementGroupId", "remediationName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations/remediationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2RemediationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2RemediationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &Providers2RemediationId{ + ManagementGroupId: "managementGroupId", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2RemediationID(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + if actual.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestParseProviders2RemediationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2RemediationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &Providers2RemediationId{ + ManagementGroupId: "managementGroupId", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe", + Expected: &Providers2RemediationId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + RemediationName: "rEmEdIaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2RemediationIDInsensitively(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.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + if actual.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestSegmentsForProviders2RemediationId(t *testing.T) { + segments := Providers2RemediationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2RemediationId 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/policyinsights/2024-10-01/remediations/id_remediation.go b/resource-manager/policyinsights/2024-10-01/remediations/id_remediation.go new file mode 100644 index 00000000000..f9137731f2a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_remediation.go @@ -0,0 +1,121 @@ +package remediations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RemediationId{}) +} + +var _ resourceids.ResourceId = &RemediationId{} + +// RemediationId is a struct representing the Resource ID for a Remediation +type RemediationId struct { + SubscriptionId string + RemediationName string +} + +// NewRemediationID returns a new RemediationId struct +func NewRemediationID(subscriptionId string, remediationName string) RemediationId { + return RemediationId{ + SubscriptionId: subscriptionId, + RemediationName: remediationName, + } +} + +// ParseRemediationID parses 'input' into a RemediationId +func ParseRemediationID(input string) (*RemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemediationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRemediationIDInsensitively parses 'input' case-insensitively into a RemediationId +// note: this method should only be used for API response data and not user input +func ParseRemediationIDInsensitively(input string) (*RemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RemediationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RemediationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.RemediationName, ok = input.Parsed["remediationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remediationName", input) + } + + return nil +} + +// ValidateRemediationID checks that 'input' can be parsed as a Remediation ID +func ValidateRemediationID(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 := ParseRemediationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Remediation ID +func (id RemediationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.PolicyInsights/remediations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.RemediationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Remediation ID +func (id RemediationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticRemediations", "remediations", "remediations"), + resourceids.UserSpecifiedSegment("remediationName", "remediationName"), + } +} + +// String returns a human-readable description of this Remediation ID +func (id RemediationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Remediation Name: %q", id.RemediationName), + } + return fmt.Sprintf("Remediation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_remediation_test.go b/resource-manager/policyinsights/2024-10-01/remediations/id_remediation_test.go new file mode 100644 index 00000000000..d1813352f63 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_remediation_test.go @@ -0,0 +1,237 @@ +package remediations + +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 = &RemediationId{} + +func TestNewRemediationID(t *testing.T) { + id := NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName") + + 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.RemediationName != "remediationName" { + t.Fatalf("Expected %q but got %q for Segment 'RemediationName'", id.RemediationName, "remediationName") + } +} + +func TestFormatRemediationID(t *testing.T) { + actual := NewRemediationID("12345678-1234-9876-4563-123456789012", "remediationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations/remediationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRemediationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RemediationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &RemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRemediationID(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.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestParseRemediationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RemediationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &RemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe", + Expected: &RemediationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RemediationName: "rEmEdIaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRemediationIDInsensitively(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.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestSegmentsForRemediationId(t *testing.T) { + segments := RemediationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RemediationId 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/policyinsights/2024-10-01/remediations/id_scopedremediation.go b/resource-manager/policyinsights/2024-10-01/remediations/id_scopedremediation.go new file mode 100644 index 00000000000..61f9c19f788 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_scopedremediation.go @@ -0,0 +1,120 @@ +package remediations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ScopedRemediationId{}) +} + +var _ resourceids.ResourceId = &ScopedRemediationId{} + +// ScopedRemediationId is a struct representing the Resource ID for a Scoped Remediation +type ScopedRemediationId struct { + ResourceId string + RemediationName string +} + +// NewScopedRemediationID returns a new ScopedRemediationId struct +func NewScopedRemediationID(resourceId string, remediationName string) ScopedRemediationId { + return ScopedRemediationId{ + ResourceId: resourceId, + RemediationName: remediationName, + } +} + +// ParseScopedRemediationID parses 'input' into a ScopedRemediationId +func ParseScopedRemediationID(input string) (*ScopedRemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedRemediationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedRemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopedRemediationIDInsensitively parses 'input' case-insensitively into a ScopedRemediationId +// note: this method should only be used for API response data and not user input +func ParseScopedRemediationIDInsensitively(input string) (*ScopedRemediationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedRemediationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedRemediationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopedRemediationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ResourceId, ok = input.Parsed["resourceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceId", input) + } + + if id.RemediationName, ok = input.Parsed["remediationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "remediationName", input) + } + + return nil +} + +// ValidateScopedRemediationID checks that 'input' can be parsed as a Scoped Remediation ID +func ValidateScopedRemediationID(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 := ParseScopedRemediationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Remediation ID +func (id ScopedRemediationId) ID() string { + fmtString := "/%s/providers/Microsoft.PolicyInsights/remediations/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.ResourceId, "/"), id.RemediationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Remediation ID +func (id ScopedRemediationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("resourceId", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftPolicyInsights", "Microsoft.PolicyInsights", "Microsoft.PolicyInsights"), + resourceids.StaticSegment("staticRemediations", "remediations", "remediations"), + resourceids.UserSpecifiedSegment("remediationName", "remediationName"), + } +} + +// String returns a human-readable description of this Scoped Remediation ID +func (id ScopedRemediationId) String() string { + components := []string{ + fmt.Sprintf("Resource: %q", id.ResourceId), + fmt.Sprintf("Remediation Name: %q", id.RemediationName), + } + return fmt.Sprintf("Scoped Remediation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/id_scopedremediation_test.go b/resource-manager/policyinsights/2024-10-01/remediations/id_scopedremediation_test.go new file mode 100644 index 00000000000..4c709c19223 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/id_scopedremediation_test.go @@ -0,0 +1,222 @@ +package remediations + +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 = &ScopedRemediationId{} + +func TestNewScopedRemediationID(t *testing.T) { + id := NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName") + + if id.ResourceId != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceId'", id.ResourceId, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } + + if id.RemediationName != "remediationName" { + t.Fatalf("Expected %q but got %q for Segment 'RemediationName'", id.RemediationName, "remediationName") + } +} + +func TestFormatScopedRemediationID(t *testing.T) { + actual := NewScopedRemediationID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "remediationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopedRemediationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedRemediationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &ScopedRemediationId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedRemediationID(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestParseScopedRemediationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedRemediationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName", + Expected: &ScopedRemediationId{ + ResourceId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + RemediationName: "remediationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.PolicyInsights/remediations/remediationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe", + Expected: &ScopedRemediationId{ + ResourceId: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + RemediationName: "rEmEdIaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.pOlIcYiNsIgHtS/rEmEdIaTiOnS/rEmEdIaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedRemediationIDInsensitively(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.ResourceId != v.Expected.ResourceId { + t.Fatalf("Expected %q but got %q for ResourceId", v.Expected.ResourceId, actual.ResourceId) + } + + if actual.RemediationName != v.Expected.RemediationName { + t.Fatalf("Expected %q but got %q for RemediationName", v.Expected.RemediationName, actual.RemediationName) + } + + } +} + +func TestSegmentsForScopedRemediationId(t *testing.T) { + segments := ScopedRemediationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopedRemediationId 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/policyinsights/2024-10-01/remediations/method_cancelatmanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatmanagementgroup.go new file mode 100644 index 00000000000..3a2e8e80114 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatmanagementgroup.go @@ -0,0 +1,54 @@ +package remediations + +import ( + "context" + "fmt" + "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 CancelAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CancelAtManagementGroup ... +func (c RemediationsClient) CancelAtManagementGroup(ctx context.Context, id Providers2RemediationId) (result CancelAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresource.go new file mode 100644 index 00000000000..86de50a538f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresource.go @@ -0,0 +1,54 @@ +package remediations + +import ( + "context" + "fmt" + "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 CancelAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CancelAtResource ... +func (c RemediationsClient) CancelAtResource(ctx context.Context, id ScopedRemediationId) (result CancelAtResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresourcegroup.go new file mode 100644 index 00000000000..6e93937ba87 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatresourcegroup.go @@ -0,0 +1,54 @@ +package remediations + +import ( + "context" + "fmt" + "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 CancelAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CancelAtResourceGroup ... +func (c RemediationsClient) CancelAtResourceGroup(ctx context.Context, id ProviderRemediationId) (result CancelAtResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatsubscription.go new file mode 100644 index 00000000000..f2de8e92ce4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_cancelatsubscription.go @@ -0,0 +1,54 @@ +package remediations + +import ( + "context" + "fmt" + "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 CancelAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CancelAtSubscription ... +func (c RemediationsClient) CancelAtSubscription(ctx context.Context, id RemediationId) (result CancelAtSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatmanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatmanagementgroup.go new file mode 100644 index 00000000000..31b72969e3a --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatmanagementgroup.go @@ -0,0 +1,58 @@ +package remediations + +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 CreateOrUpdateAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CreateOrUpdateAtManagementGroup ... +func (c RemediationsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, id Providers2RemediationId, input Remediation) (result CreateOrUpdateAtManagementGroupOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresource.go new file mode 100644 index 00000000000..a5e980acc51 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresource.go @@ -0,0 +1,58 @@ +package remediations + +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 CreateOrUpdateAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CreateOrUpdateAtResource ... +func (c RemediationsClient) CreateOrUpdateAtResource(ctx context.Context, id ScopedRemediationId, input Remediation) (result CreateOrUpdateAtResourceOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresourcegroup.go new file mode 100644 index 00000000000..74f8807ac26 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatresourcegroup.go @@ -0,0 +1,58 @@ +package remediations + +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 CreateOrUpdateAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CreateOrUpdateAtResourceGroup ... +func (c RemediationsClient) CreateOrUpdateAtResourceGroup(ctx context.Context, id ProviderRemediationId, input Remediation) (result CreateOrUpdateAtResourceGroupOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatsubscription.go new file mode 100644 index 00000000000..b5b54984856 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_createorupdateatsubscription.go @@ -0,0 +1,58 @@ +package remediations + +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 CreateOrUpdateAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// CreateOrUpdateAtSubscription ... +func (c RemediationsClient) CreateOrUpdateAtSubscription(ctx context.Context, id RemediationId, input Remediation) (result CreateOrUpdateAtSubscriptionOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatmanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatmanagementgroup.go new file mode 100644 index 00000000000..6c1f56b8ed9 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatmanagementgroup.go @@ -0,0 +1,54 @@ +package remediations + +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 DeleteAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// DeleteAtManagementGroup ... +func (c RemediationsClient) DeleteAtManagementGroup(ctx context.Context, id Providers2RemediationId) (result DeleteAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresource.go new file mode 100644 index 00000000000..c5ffc153041 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresource.go @@ -0,0 +1,54 @@ +package remediations + +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 DeleteAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// DeleteAtResource ... +func (c RemediationsClient) DeleteAtResource(ctx context.Context, id ScopedRemediationId) (result DeleteAtResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresourcegroup.go new file mode 100644 index 00000000000..f3fa20289db --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatresourcegroup.go @@ -0,0 +1,54 @@ +package remediations + +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 DeleteAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// DeleteAtResourceGroup ... +func (c RemediationsClient) DeleteAtResourceGroup(ctx context.Context, id ProviderRemediationId) (result DeleteAtResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatsubscription.go new file mode 100644 index 00000000000..d2e7ffb3dd4 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_deleteatsubscription.go @@ -0,0 +1,54 @@ +package remediations + +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 DeleteAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// DeleteAtSubscription ... +func (c RemediationsClient) DeleteAtSubscription(ctx context.Context, id RemediationId) (result DeleteAtSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_getatmanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_getatmanagementgroup.go new file mode 100644 index 00000000000..0fe05dbdcb7 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_getatmanagementgroup.go @@ -0,0 +1,53 @@ +package remediations + +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 GetAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// GetAtManagementGroup ... +func (c RemediationsClient) GetAtManagementGroup(ctx context.Context, id Providers2RemediationId) (result GetAtManagementGroupOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_getatresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_getatresource.go new file mode 100644 index 00000000000..2f85b9ddc19 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_getatresource.go @@ -0,0 +1,53 @@ +package remediations + +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 GetAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// GetAtResource ... +func (c RemediationsClient) GetAtResource(ctx context.Context, id ScopedRemediationId) (result GetAtResourceOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_getatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_getatresourcegroup.go new file mode 100644 index 00000000000..1e4c0c59310 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_getatresourcegroup.go @@ -0,0 +1,53 @@ +package remediations + +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 GetAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// GetAtResourceGroup ... +func (c RemediationsClient) GetAtResourceGroup(ctx context.Context, id ProviderRemediationId) (result GetAtResourceGroupOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_getatsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_getatsubscription.go new file mode 100644 index 00000000000..7040cf62d24 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_getatsubscription.go @@ -0,0 +1,53 @@ +package remediations + +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 GetAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Remediation +} + +// GetAtSubscription ... +func (c RemediationsClient) GetAtSubscription(ctx context.Context, id RemediationId) (result GetAtSubscriptionOperationResponse, 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 + } + + var model Remediation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatmanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatmanagementgroup.go new file mode 100644 index 00000000000..000a1dede92 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatmanagementgroup.go @@ -0,0 +1,134 @@ +package remediations + +import ( + "context" + "fmt" + "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 ListDeploymentsAtManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemediationDeployment +} + +type ListDeploymentsAtManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemediationDeployment +} + +type ListDeploymentsAtManagementGroupOperationOptions struct { + Top *int64 +} + +func DefaultListDeploymentsAtManagementGroupOperationOptions() ListDeploymentsAtManagementGroupOperationOptions { + return ListDeploymentsAtManagementGroupOperationOptions{} +} + +func (o ListDeploymentsAtManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListDeploymentsAtManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListDeploymentsAtManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListDeploymentsAtManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsAtManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsAtManagementGroup ... +func (c RemediationsClient) ListDeploymentsAtManagementGroup(ctx context.Context, id Providers2RemediationId, options ListDeploymentsAtManagementGroupOperationOptions) (result ListDeploymentsAtManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListDeploymentsAtManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/listDeployments", 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 *[]RemediationDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsAtManagementGroupComplete retrieves all the results into a single object +func (c RemediationsClient) ListDeploymentsAtManagementGroupComplete(ctx context.Context, id Providers2RemediationId, options ListDeploymentsAtManagementGroupOperationOptions) (ListDeploymentsAtManagementGroupCompleteResult, error) { + return c.ListDeploymentsAtManagementGroupCompleteMatchingPredicate(ctx, id, options, RemediationDeploymentOperationPredicate{}) +} + +// ListDeploymentsAtManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListDeploymentsAtManagementGroupCompleteMatchingPredicate(ctx context.Context, id Providers2RemediationId, options ListDeploymentsAtManagementGroupOperationOptions, predicate RemediationDeploymentOperationPredicate) (result ListDeploymentsAtManagementGroupCompleteResult, err error) { + items := make([]RemediationDeployment, 0) + + resp, err := c.ListDeploymentsAtManagementGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsAtManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresource.go new file mode 100644 index 00000000000..4eacc612b3f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresource.go @@ -0,0 +1,134 @@ +package remediations + +import ( + "context" + "fmt" + "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 ListDeploymentsAtResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemediationDeployment +} + +type ListDeploymentsAtResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemediationDeployment +} + +type ListDeploymentsAtResourceOperationOptions struct { + Top *int64 +} + +func DefaultListDeploymentsAtResourceOperationOptions() ListDeploymentsAtResourceOperationOptions { + return ListDeploymentsAtResourceOperationOptions{} +} + +func (o ListDeploymentsAtResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListDeploymentsAtResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListDeploymentsAtResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListDeploymentsAtResourceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsAtResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsAtResource ... +func (c RemediationsClient) ListDeploymentsAtResource(ctx context.Context, id ScopedRemediationId, options ListDeploymentsAtResourceOperationOptions) (result ListDeploymentsAtResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListDeploymentsAtResourceCustomPager{}, + Path: fmt.Sprintf("%s/listDeployments", 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 *[]RemediationDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsAtResourceComplete retrieves all the results into a single object +func (c RemediationsClient) ListDeploymentsAtResourceComplete(ctx context.Context, id ScopedRemediationId, options ListDeploymentsAtResourceOperationOptions) (ListDeploymentsAtResourceCompleteResult, error) { + return c.ListDeploymentsAtResourceCompleteMatchingPredicate(ctx, id, options, RemediationDeploymentOperationPredicate{}) +} + +// ListDeploymentsAtResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListDeploymentsAtResourceCompleteMatchingPredicate(ctx context.Context, id ScopedRemediationId, options ListDeploymentsAtResourceOperationOptions, predicate RemediationDeploymentOperationPredicate) (result ListDeploymentsAtResourceCompleteResult, err error) { + items := make([]RemediationDeployment, 0) + + resp, err := c.ListDeploymentsAtResource(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsAtResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresourcegroup.go new file mode 100644 index 00000000000..c440965a8ad --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatresourcegroup.go @@ -0,0 +1,134 @@ +package remediations + +import ( + "context" + "fmt" + "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 ListDeploymentsAtResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemediationDeployment +} + +type ListDeploymentsAtResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemediationDeployment +} + +type ListDeploymentsAtResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListDeploymentsAtResourceGroupOperationOptions() ListDeploymentsAtResourceGroupOperationOptions { + return ListDeploymentsAtResourceGroupOperationOptions{} +} + +func (o ListDeploymentsAtResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListDeploymentsAtResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListDeploymentsAtResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListDeploymentsAtResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsAtResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsAtResourceGroup ... +func (c RemediationsClient) ListDeploymentsAtResourceGroup(ctx context.Context, id ProviderRemediationId, options ListDeploymentsAtResourceGroupOperationOptions) (result ListDeploymentsAtResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListDeploymentsAtResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/listDeployments", 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 *[]RemediationDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsAtResourceGroupComplete retrieves all the results into a single object +func (c RemediationsClient) ListDeploymentsAtResourceGroupComplete(ctx context.Context, id ProviderRemediationId, options ListDeploymentsAtResourceGroupOperationOptions) (ListDeploymentsAtResourceGroupCompleteResult, error) { + return c.ListDeploymentsAtResourceGroupCompleteMatchingPredicate(ctx, id, options, RemediationDeploymentOperationPredicate{}) +} + +// ListDeploymentsAtResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListDeploymentsAtResourceGroupCompleteMatchingPredicate(ctx context.Context, id ProviderRemediationId, options ListDeploymentsAtResourceGroupOperationOptions, predicate RemediationDeploymentOperationPredicate) (result ListDeploymentsAtResourceGroupCompleteResult, err error) { + items := make([]RemediationDeployment, 0) + + resp, err := c.ListDeploymentsAtResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsAtResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatsubscription.go new file mode 100644 index 00000000000..fa1f5512c46 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listdeploymentsatsubscription.go @@ -0,0 +1,134 @@ +package remediations + +import ( + "context" + "fmt" + "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 ListDeploymentsAtSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemediationDeployment +} + +type ListDeploymentsAtSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemediationDeployment +} + +type ListDeploymentsAtSubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListDeploymentsAtSubscriptionOperationOptions() ListDeploymentsAtSubscriptionOperationOptions { + return ListDeploymentsAtSubscriptionOperationOptions{} +} + +func (o ListDeploymentsAtSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListDeploymentsAtSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListDeploymentsAtSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListDeploymentsAtSubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsAtSubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsAtSubscription ... +func (c RemediationsClient) ListDeploymentsAtSubscription(ctx context.Context, id RemediationId, options ListDeploymentsAtSubscriptionOperationOptions) (result ListDeploymentsAtSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListDeploymentsAtSubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/listDeployments", 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 *[]RemediationDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsAtSubscriptionComplete retrieves all the results into a single object +func (c RemediationsClient) ListDeploymentsAtSubscriptionComplete(ctx context.Context, id RemediationId, options ListDeploymentsAtSubscriptionOperationOptions) (ListDeploymentsAtSubscriptionCompleteResult, error) { + return c.ListDeploymentsAtSubscriptionCompleteMatchingPredicate(ctx, id, options, RemediationDeploymentOperationPredicate{}) +} + +// ListDeploymentsAtSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListDeploymentsAtSubscriptionCompleteMatchingPredicate(ctx context.Context, id RemediationId, options ListDeploymentsAtSubscriptionOperationOptions, predicate RemediationDeploymentOperationPredicate) (result ListDeploymentsAtSubscriptionCompleteResult, err error) { + items := make([]RemediationDeployment, 0) + + resp, err := c.ListDeploymentsAtSubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsAtSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listformanagementgroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listformanagementgroup.go new file mode 100644 index 00000000000..c4ccbdf488d --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listformanagementgroup.go @@ -0,0 +1,138 @@ +package remediations + +import ( + "context" + "fmt" + "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 ListForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Remediation +} + +type ListForManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Remediation +} + +type ListForManagementGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForManagementGroupOperationOptions() ListForManagementGroupOperationOptions { + return ListForManagementGroupOperationOptions{} +} + +func (o ListForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForManagementGroup ... +func (c RemediationsClient) ListForManagementGroup(ctx context.Context, id ManagementGroupId, options ListForManagementGroupOperationOptions) (result ListForManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/remediations", 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 *[]Remediation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForManagementGroupComplete retrieves all the results into a single object +func (c RemediationsClient) ListForManagementGroupComplete(ctx context.Context, id ManagementGroupId, options ListForManagementGroupOperationOptions) (ListForManagementGroupCompleteResult, error) { + return c.ListForManagementGroupCompleteMatchingPredicate(ctx, id, options, RemediationOperationPredicate{}) +} + +// ListForManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListForManagementGroupCompleteMatchingPredicate(ctx context.Context, id ManagementGroupId, options ListForManagementGroupOperationOptions, predicate RemediationOperationPredicate) (result ListForManagementGroupCompleteResult, err error) { + items := make([]Remediation, 0) + + resp, err := c.ListForManagementGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listforresource.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listforresource.go new file mode 100644 index 00000000000..220cd218684 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listforresource.go @@ -0,0 +1,139 @@ +package remediations + +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 ListForResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Remediation +} + +type ListForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []Remediation +} + +type ListForResourceOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceOperationOptions() ListForResourceOperationOptions { + return ListForResourceOperationOptions{} +} + +func (o ListForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResource ... +func (c RemediationsClient) ListForResource(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (result ListForResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/remediations", 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 *[]Remediation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceComplete retrieves all the results into a single object +func (c RemediationsClient) ListForResourceComplete(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (ListForResourceCompleteResult, error) { + return c.ListForResourceCompleteMatchingPredicate(ctx, id, options, RemediationOperationPredicate{}) +} + +// ListForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions, predicate RemediationOperationPredicate) (result ListForResourceCompleteResult, err error) { + items := make([]Remediation, 0) + + resp, err := c.ListForResource(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listforresourcegroup.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listforresourcegroup.go new file mode 100644 index 00000000000..9fe404cebab --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listforresourcegroup.go @@ -0,0 +1,139 @@ +package remediations + +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 ListForResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Remediation +} + +type ListForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Remediation +} + +type ListForResourceGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceGroupOperationOptions() ListForResourceGroupOperationOptions { + return ListForResourceGroupOperationOptions{} +} + +func (o ListForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForResourceGroup ... +func (c RemediationsClient) ListForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (result ListForResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/remediations", 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 *[]Remediation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForResourceGroupComplete retrieves all the results into a single object +func (c RemediationsClient) ListForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (ListForResourceGroupCompleteResult, error) { + return c.ListForResourceGroupCompleteMatchingPredicate(ctx, id, options, RemediationOperationPredicate{}) +} + +// ListForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions, predicate RemediationOperationPredicate) (result ListForResourceGroupCompleteResult, err error) { + items := make([]Remediation, 0) + + resp, err := c.ListForResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/method_listforsubscription.go b/resource-manager/policyinsights/2024-10-01/remediations/method_listforsubscription.go new file mode 100644 index 00000000000..01493cd18b1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/method_listforsubscription.go @@ -0,0 +1,139 @@ +package remediations + +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 ListForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Remediation +} + +type ListForSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Remediation +} + +type ListForSubscriptionOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForSubscriptionOperationOptions() ListForSubscriptionOperationOptions { + return ListForSubscriptionOperationOptions{} +} + +func (o ListForSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListForSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListForSubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListForSubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListForSubscription ... +func (c RemediationsClient) ListForSubscription(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions) (result ListForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListForSubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.PolicyInsights/remediations", 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 *[]Remediation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForSubscriptionComplete retrieves all the results into a single object +func (c RemediationsClient) ListForSubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions) (ListForSubscriptionCompleteResult, error) { + return c.ListForSubscriptionCompleteMatchingPredicate(ctx, id, options, RemediationOperationPredicate{}) +} + +// ListForSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RemediationsClient) ListForSubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListForSubscriptionOperationOptions, predicate RemediationOperationPredicate) (result ListForSubscriptionCompleteResult, err error) { + items := make([]Remediation, 0) + + resp, err := c.ListForSubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListForSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_errordefinition.go b/resource-manager/policyinsights/2024-10-01/remediations/model_errordefinition.go new file mode 100644 index 00000000000..7d2cb5ba700 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_errordefinition.go @@ -0,0 +1,12 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + AdditionalInfo *[]TypedErrorInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediation.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediation.go new file mode 100644 index 00000000000..f19bbad7544 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediation.go @@ -0,0 +1,16 @@ +package remediations + +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 Remediation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemediationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeployment.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeployment.go new file mode 100644 index 00000000000..456d1946724 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeployment.go @@ -0,0 +1,44 @@ +package remediations + +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 RemediationDeployment struct { + CreatedOn *string `json:"createdOn,omitempty"` + DeploymentId *string `json:"deploymentId,omitempty"` + Error *ErrorDefinition `json:"error,omitempty"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + RemediatedResourceId *string `json:"remediatedResourceId,omitempty"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *RemediationDeployment) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *RemediationDeployment) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *RemediationDeployment) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *RemediationDeployment) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeploymentsummary.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeploymentsummary.go new file mode 100644 index 00000000000..db2a3e65be5 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationdeploymentsummary.go @@ -0,0 +1,10 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemediationDeploymentSummary struct { + FailedDeployments *int64 `json:"failedDeployments,omitempty"` + SuccessfulDeployments *int64 `json:"successfulDeployments,omitempty"` + TotalDeployments *int64 `json:"totalDeployments,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediationfilters.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationfilters.go new file mode 100644 index 00000000000..95f71be7564 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationfilters.go @@ -0,0 +1,9 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemediationFilters struct { + Locations *[]string `json:"locations,omitempty"` + ResourceIds *[]string `json:"resourceIds,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediationproperties.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationproperties.go new file mode 100644 index 00000000000..501085bcf65 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationproperties.go @@ -0,0 +1,50 @@ +package remediations + +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 RemediationProperties struct { + CorrelationId *string `json:"correlationId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + DeploymentStatus *RemediationDeploymentSummary `json:"deploymentStatus,omitempty"` + FailureThreshold *RemediationPropertiesFailureThreshold `json:"failureThreshold,omitempty"` + Filters *RemediationFilters `json:"filters,omitempty"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + ParallelDeployments *int64 `json:"parallelDeployments,omitempty"` + PolicyAssignmentId *string `json:"policyAssignmentId,omitempty"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceCount *int64 `json:"resourceCount,omitempty"` + ResourceDiscoveryMode *ResourceDiscoveryMode `json:"resourceDiscoveryMode,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} + +func (o *RemediationProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *RemediationProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *RemediationProperties) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *RemediationProperties) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_remediationpropertiesfailurethreshold.go b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationpropertiesfailurethreshold.go new file mode 100644 index 00000000000..f3a8d59c959 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_remediationpropertiesfailurethreshold.go @@ -0,0 +1,8 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemediationPropertiesFailureThreshold struct { + Percentage *float64 `json:"percentage,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/model_typederrorinfo.go b/resource-manager/policyinsights/2024-10-01/remediations/model_typederrorinfo.go new file mode 100644 index 00000000000..3819fb61aff --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/model_typederrorinfo.go @@ -0,0 +1,9 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TypedErrorInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/predicates.go b/resource-manager/policyinsights/2024-10-01/remediations/predicates.go new file mode 100644 index 00000000000..db9f8d3867f --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/predicates.go @@ -0,0 +1,65 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemediationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RemediationOperationPredicate) Matches(input Remediation) 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 +} + +type RemediationDeploymentOperationPredicate struct { + CreatedOn *string + DeploymentId *string + LastUpdatedOn *string + RemediatedResourceId *string + ResourceLocation *string + Status *string +} + +func (p RemediationDeploymentOperationPredicate) Matches(input RemediationDeployment) bool { + + if p.CreatedOn != nil && (input.CreatedOn == nil || *p.CreatedOn != *input.CreatedOn) { + return false + } + + if p.DeploymentId != nil && (input.DeploymentId == nil || *p.DeploymentId != *input.DeploymentId) { + return false + } + + if p.LastUpdatedOn != nil && (input.LastUpdatedOn == nil || *p.LastUpdatedOn != *input.LastUpdatedOn) { + return false + } + + if p.RemediatedResourceId != nil && (input.RemediatedResourceId == nil || *p.RemediatedResourceId != *input.RemediatedResourceId) { + return false + } + + if p.ResourceLocation != nil && (input.ResourceLocation == nil || *p.ResourceLocation != *input.ResourceLocation) { + return false + } + + if p.Status != nil && (input.Status == nil || *p.Status != *input.Status) { + return false + } + + return true +} diff --git a/resource-manager/policyinsights/2024-10-01/remediations/version.go b/resource-manager/policyinsights/2024-10-01/remediations/version.go new file mode 100644 index 00000000000..7ed5ab3a3b1 --- /dev/null +++ b/resource-manager/policyinsights/2024-10-01/remediations/version.go @@ -0,0 +1,10 @@ +package remediations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/remediations/2024-10-01" +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/README.md b/resource-manager/postgresql/2024-08-01/administrators/README.md new file mode 100644 index 00000000000..83bfb00d806 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/administrators` Documentation + +The `administrators` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/administrators" +``` + + +### Client Initialization + +```go +client := administrators.NewAdministratorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdministratorsClient.Create` + +```go +ctx := context.TODO() +id := administrators.NewAdministratorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "objectId") + +payload := administrators.ActiveDirectoryAdministratorAdd{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AdministratorsClient.Delete` + +```go +ctx := context.TODO() +id := administrators.NewAdministratorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "objectId") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AdministratorsClient.Get` + +```go +ctx := context.TODO() +id := administrators.NewAdministratorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "objectId") + +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: `AdministratorsClient.ListByServer` + +```go +ctx := context.TODO() +id := administrators.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/administrators/client.go b/resource-manager/postgresql/2024-08-01/administrators/client.go new file mode 100644 index 00000000000..6fd32a5af24 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/client.go @@ -0,0 +1,26 @@ +package administrators + +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 AdministratorsClient struct { + Client *resourcemanager.Client +} + +func NewAdministratorsClientWithBaseURI(sdkApi sdkEnv.Api) (*AdministratorsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "administrators", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdministratorsClient: %+v", err) + } + + return &AdministratorsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/constants.go b/resource-manager/postgresql/2024-08-01/administrators/constants.go new file mode 100644 index 00000000000..b6dba558d6a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/constants.go @@ -0,0 +1,57 @@ +package administrators + +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 PrincipalType string + +const ( + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeServicePrincipal PrincipalType = "ServicePrincipal" + PrincipalTypeUnknown PrincipalType = "Unknown" + PrincipalTypeUser PrincipalType = "User" +) + +func PossibleValuesForPrincipalType() []string { + return []string{ + string(PrincipalTypeGroup), + string(PrincipalTypeServicePrincipal), + string(PrincipalTypeUnknown), + string(PrincipalTypeUser), + } +} + +func (s *PrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalType(input string) (*PrincipalType, error) { + vals := map[string]PrincipalType{ + "group": PrincipalTypeGroup, + "serviceprincipal": PrincipalTypeServicePrincipal, + "unknown": PrincipalTypeUnknown, + "user": PrincipalTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalType(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/id_administrator.go b/resource-manager/postgresql/2024-08-01/administrators/id_administrator.go new file mode 100644 index 00000000000..5ef76826665 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/id_administrator.go @@ -0,0 +1,139 @@ +package administrators + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AdministratorId{}) +} + +var _ resourceids.ResourceId = &AdministratorId{} + +// AdministratorId is a struct representing the Resource ID for a Administrator +type AdministratorId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + ObjectId string +} + +// NewAdministratorID returns a new AdministratorId struct +func NewAdministratorID(subscriptionId string, resourceGroupName string, flexibleServerName string, objectId string) AdministratorId { + return AdministratorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + ObjectId: objectId, + } +} + +// ParseAdministratorID parses 'input' into a AdministratorId +func ParseAdministratorID(input string) (*AdministratorId, error) { + parser := resourceids.NewParserFromResourceIdType(&AdministratorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AdministratorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAdministratorIDInsensitively parses 'input' case-insensitively into a AdministratorId +// note: this method should only be used for API response data and not user input +func ParseAdministratorIDInsensitively(input string) (*AdministratorId, error) { + parser := resourceids.NewParserFromResourceIdType(&AdministratorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AdministratorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AdministratorId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.ObjectId, ok = input.Parsed["objectId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "objectId", input) + } + + return nil +} + +// ValidateAdministratorID checks that 'input' can be parsed as a Administrator ID +func ValidateAdministratorID(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 := ParseAdministratorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Administrator ID +func (id AdministratorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/administrators/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.ObjectId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Administrator ID +func (id AdministratorId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticAdministrators", "administrators", "administrators"), + resourceids.UserSpecifiedSegment("objectId", "objectId"), + } +} + +// String returns a human-readable description of this Administrator ID +func (id AdministratorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Object: %q", id.ObjectId), + } + return fmt.Sprintf("Administrator (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/id_administrator_test.go b/resource-manager/postgresql/2024-08-01/administrators/id_administrator_test.go new file mode 100644 index 00000000000..8d4a88c7e33 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/id_administrator_test.go @@ -0,0 +1,327 @@ +package administrators + +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 = &AdministratorId{} + +func TestNewAdministratorID(t *testing.T) { + id := NewAdministratorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "objectId") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.ObjectId != "objectId" { + t.Fatalf("Expected %q but got %q for Segment 'ObjectId'", id.ObjectId, "objectId") + } +} + +func TestFormatAdministratorID(t *testing.T) { + actual := NewAdministratorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "objectId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators/objectId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAdministratorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AdministratorId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators/objectId", + Expected: &AdministratorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + ObjectId: "objectId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators/objectId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAdministratorID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.ObjectId != v.Expected.ObjectId { + t.Fatalf("Expected %q but got %q for ObjectId", v.Expected.ObjectId, actual.ObjectId) + } + + } +} + +func TestParseAdministratorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AdministratorId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/aDmInIsTrAtOrS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators/objectId", + Expected: &AdministratorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + ObjectId: "objectId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/administrators/objectId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/aDmInIsTrAtOrS/oBjEcTiD", + Expected: &AdministratorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + ObjectId: "oBjEcTiD", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/aDmInIsTrAtOrS/oBjEcTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAdministratorIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.ObjectId != v.Expected.ObjectId { + t.Fatalf("Expected %q but got %q for ObjectId", v.Expected.ObjectId, actual.ObjectId) + } + + } +} + +func TestSegmentsForAdministratorId(t *testing.T) { + segments := AdministratorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AdministratorId 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/postgresql/2024-08-01/administrators/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/administrators/id_flexibleserver.go new file mode 100644 index 00000000000..1a03f5e9f36 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/id_flexibleserver.go @@ -0,0 +1,130 @@ +package administrators + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/administrators/id_flexibleserver_test.go new file mode 100644 index 00000000000..b12837b2f7c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package administrators + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/administrators/method_create.go b/resource-manager/postgresql/2024-08-01/administrators/method_create.go new file mode 100644 index 00000000000..1cb87d11f66 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/method_create.go @@ -0,0 +1,76 @@ +package administrators + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ActiveDirectoryAdministrator +} + +// Create ... +func (c AdministratorsClient) Create(ctx context.Context, id AdministratorId, input ActiveDirectoryAdministratorAdd) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c AdministratorsClient) CreateThenPoll(ctx context.Context, id AdministratorId, input ActiveDirectoryAdministratorAdd) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/method_delete.go b/resource-manager/postgresql/2024-08-01/administrators/method_delete.go new file mode 100644 index 00000000000..5ac93683683 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/method_delete.go @@ -0,0 +1,71 @@ +package administrators + +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 AdministratorsClient) Delete(ctx context.Context, id AdministratorId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AdministratorsClient) DeleteThenPoll(ctx context.Context, id AdministratorId) 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/postgresql/2024-08-01/administrators/method_get.go b/resource-manager/postgresql/2024-08-01/administrators/method_get.go new file mode 100644 index 00000000000..a4f50294a89 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/method_get.go @@ -0,0 +1,53 @@ +package administrators + +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 *ActiveDirectoryAdministrator +} + +// Get ... +func (c AdministratorsClient) Get(ctx context.Context, id AdministratorId) (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 + } + + var model ActiveDirectoryAdministrator + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/administrators/method_listbyserver.go new file mode 100644 index 00000000000..0d5db978165 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/method_listbyserver.go @@ -0,0 +1,105 @@ +package administrators + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ActiveDirectoryAdministrator +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []ActiveDirectoryAdministrator +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c AdministratorsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/administrators", 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 *[]ActiveDirectoryAdministrator `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c AdministratorsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ActiveDirectoryAdministratorOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdministratorsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ActiveDirectoryAdministratorOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]ActiveDirectoryAdministrator, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministrator.go b/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministrator.go new file mode 100644 index 00000000000..755ec3d20cf --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministrator.go @@ -0,0 +1,16 @@ +package administrators + +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 ActiveDirectoryAdministrator struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AdministratorProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministratoradd.go b/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministratoradd.go new file mode 100644 index 00000000000..be4ae69c7e7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/model_activedirectoryadministratoradd.go @@ -0,0 +1,8 @@ +package administrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectoryAdministratorAdd struct { + Properties *AdministratorPropertiesForAdd `json:"properties,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/model_administratorproperties.go b/resource-manager/postgresql/2024-08-01/administrators/model_administratorproperties.go new file mode 100644 index 00000000000..08f085de6e1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/model_administratorproperties.go @@ -0,0 +1,11 @@ +package administrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministratorProperties struct { + ObjectId *string `json:"objectId,omitempty"` + PrincipalName *string `json:"principalName,omitempty"` + PrincipalType *PrincipalType `json:"principalType,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/model_administratorpropertiesforadd.go b/resource-manager/postgresql/2024-08-01/administrators/model_administratorpropertiesforadd.go new file mode 100644 index 00000000000..a5e157419de --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/model_administratorpropertiesforadd.go @@ -0,0 +1,10 @@ +package administrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministratorPropertiesForAdd struct { + PrincipalName *string `json:"principalName,omitempty"` + PrincipalType *PrincipalType `json:"principalType,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/administrators/predicates.go b/resource-manager/postgresql/2024-08-01/administrators/predicates.go new file mode 100644 index 00000000000..66918ad7784 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/predicates.go @@ -0,0 +1,27 @@ +package administrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveDirectoryAdministratorOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ActiveDirectoryAdministratorOperationPredicate) Matches(input ActiveDirectoryAdministrator) 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/postgresql/2024-08-01/administrators/version.go b/resource-manager/postgresql/2024-08-01/administrators/version.go new file mode 100644 index 00000000000..f866ba24634 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/administrators/version.go @@ -0,0 +1,10 @@ +package administrators + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/administrators/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/README.md b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/README.md new file mode 100644 index 00000000000..7505d9091eb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings` Documentation + +The `advancedthreatprotectionsettings` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/advancedthreatprotectionsettings" +``` + + +### Client Initialization + +```go +client := advancedthreatprotectionsettings.NewAdvancedThreatProtectionSettingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdvancedThreatProtectionSettingsClient.ServerThreatProtectionSettingsCreateOrUpdate` + +```go +ctx := context.TODO() +id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := advancedthreatprotectionsettings.ServerThreatProtectionSettingsModel{ + // ... +} + + +if err := client.ServerThreatProtectionSettingsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AdvancedThreatProtectionSettingsClient.ServerThreatProtectionSettingsGet` + +```go +ctx := context.TODO() +id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +read, err := client.ServerThreatProtectionSettingsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdvancedThreatProtectionSettingsClient.ServerThreatProtectionSettingsListByServer` + +```go +ctx := context.TODO() +id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ServerThreatProtectionSettingsListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ServerThreatProtectionSettingsListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/client.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/client.go new file mode 100644 index 00000000000..e7a35ff187e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/client.go @@ -0,0 +1,26 @@ +package advancedthreatprotectionsettings + +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 AdvancedThreatProtectionSettingsClient struct { + Client *resourcemanager.Client +} + +func NewAdvancedThreatProtectionSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*AdvancedThreatProtectionSettingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "advancedthreatprotectionsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdvancedThreatProtectionSettingsClient: %+v", err) + } + + return &AdvancedThreatProtectionSettingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/constants.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/constants.go new file mode 100644 index 00000000000..33c03e5a580 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/constants.go @@ -0,0 +1,51 @@ +package advancedthreatprotectionsettings + +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 ThreatProtectionState string + +const ( + ThreatProtectionStateDisabled ThreatProtectionState = "Disabled" + ThreatProtectionStateEnabled ThreatProtectionState = "Enabled" +) + +func PossibleValuesForThreatProtectionState() []string { + return []string{ + string(ThreatProtectionStateDisabled), + string(ThreatProtectionStateEnabled), + } +} + +func (s *ThreatProtectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseThreatProtectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseThreatProtectionState(input string) (*ThreatProtectionState, error) { + vals := map[string]ThreatProtectionState{ + "disabled": ThreatProtectionStateDisabled, + "enabled": ThreatProtectionStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ThreatProtectionState(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver.go new file mode 100644 index 00000000000..6c8af36ce31 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver.go @@ -0,0 +1,130 @@ +package advancedthreatprotectionsettings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver_test.go new file mode 100644 index 00000000000..f686975522e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package advancedthreatprotectionsettings + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingscreateorupdate.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingscreateorupdate.go new file mode 100644 index 00000000000..71bfefb5c89 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingscreateorupdate.go @@ -0,0 +1,76 @@ +package advancedthreatprotectionsettings + +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 ServerThreatProtectionSettingsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServerThreatProtectionSettingsModel +} + +// ServerThreatProtectionSettingsCreateOrUpdate ... +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsCreateOrUpdate(ctx context.Context, id FlexibleServerId, input ServerThreatProtectionSettingsModel) (result ServerThreatProtectionSettingsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/advancedThreatProtectionSettings/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 +} + +// ServerThreatProtectionSettingsCreateOrUpdateThenPoll performs ServerThreatProtectionSettingsCreateOrUpdate then polls until it's completed +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsCreateOrUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerThreatProtectionSettingsModel) error { + result, err := c.ServerThreatProtectionSettingsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServerThreatProtectionSettingsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServerThreatProtectionSettingsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingsget.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingsget.go new file mode 100644 index 00000000000..7bddb82a9c6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingsget.go @@ -0,0 +1,54 @@ +package advancedthreatprotectionsettings + +import ( + "context" + "fmt" + "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 ServerThreatProtectionSettingsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerThreatProtectionSettingsModel +} + +// ServerThreatProtectionSettingsGet ... +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsGet(ctx context.Context, id FlexibleServerId) (result ServerThreatProtectionSettingsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/advancedThreatProtectionSettings/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 + } + + var model ServerThreatProtectionSettingsModel + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingslistbyserver.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingslistbyserver.go new file mode 100644 index 00000000000..1547145f636 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/method_serverthreatprotectionsettingslistbyserver.go @@ -0,0 +1,105 @@ +package advancedthreatprotectionsettings + +import ( + "context" + "fmt" + "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 ServerThreatProtectionSettingsListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerThreatProtectionSettingsModel +} + +type ServerThreatProtectionSettingsListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServerThreatProtectionSettingsModel +} + +type ServerThreatProtectionSettingsListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ServerThreatProtectionSettingsListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ServerThreatProtectionSettingsListByServer ... +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsListByServer(ctx context.Context, id FlexibleServerId) (result ServerThreatProtectionSettingsListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ServerThreatProtectionSettingsListByServerCustomPager{}, + Path: fmt.Sprintf("%s/advancedThreatProtectionSettings", 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 *[]ServerThreatProtectionSettingsModel `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ServerThreatProtectionSettingsListByServerComplete retrieves all the results into a single object +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsListByServerComplete(ctx context.Context, id FlexibleServerId) (ServerThreatProtectionSettingsListByServerCompleteResult, error) { + return c.ServerThreatProtectionSettingsListByServerCompleteMatchingPredicate(ctx, id, ServerThreatProtectionSettingsModelOperationPredicate{}) +} + +// ServerThreatProtectionSettingsListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdvancedThreatProtectionSettingsClient) ServerThreatProtectionSettingsListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerThreatProtectionSettingsModelOperationPredicate) (result ServerThreatProtectionSettingsListByServerCompleteResult, err error) { + items := make([]ServerThreatProtectionSettingsModel, 0) + + resp, err := c.ServerThreatProtectionSettingsListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ServerThreatProtectionSettingsListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionproperties.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionproperties.go new file mode 100644 index 00000000000..58a99451513 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionproperties.go @@ -0,0 +1,27 @@ +package advancedthreatprotectionsettings + +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 ServerThreatProtectionProperties struct { + CreationTime *string `json:"creationTime,omitempty"` + State ThreatProtectionState `json:"state"` +} + +func (o *ServerThreatProtectionProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ServerThreatProtectionProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionsettingsmodel.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionsettingsmodel.go new file mode 100644 index 00000000000..504d426acd3 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/model_serverthreatprotectionsettingsmodel.go @@ -0,0 +1,16 @@ +package advancedthreatprotectionsettings + +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 ServerThreatProtectionSettingsModel struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServerThreatProtectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/predicates.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/predicates.go new file mode 100644 index 00000000000..317033ac932 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/predicates.go @@ -0,0 +1,27 @@ +package advancedthreatprotectionsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerThreatProtectionSettingsModelOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ServerThreatProtectionSettingsModelOperationPredicate) Matches(input ServerThreatProtectionSettingsModel) 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/postgresql/2024-08-01/advancedthreatprotectionsettings/version.go b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/version.go new file mode 100644 index 00000000000..76c147f68f1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings/version.go @@ -0,0 +1,10 @@ +package advancedthreatprotectionsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/advancedthreatprotectionsettings/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/backups/README.md b/resource-manager/postgresql/2024-08-01/backups/README.md new file mode 100644 index 00000000000..0de5291f66b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/README.md @@ -0,0 +1,77 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/backups` Documentation + +The `backups` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/backups" +``` + + +### Client Initialization + +```go +client := backups.NewBackupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupsClient.Create` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "backupName") + +if err := client.CreateThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.Delete` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "backupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupsClient.Get` + +```go +ctx := context.TODO() +id := backups.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "backupName") + +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: `BackupsClient.ListByServer` + +```go +ctx := context.TODO() +id := backups.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/backups/client.go b/resource-manager/postgresql/2024-08-01/backups/client.go new file mode 100644 index 00000000000..6e1cc70d434 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/client.go @@ -0,0 +1,26 @@ +package backups + +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 BackupsClient struct { + Client *resourcemanager.Client +} + +func NewBackupsClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "backups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupsClient: %+v", err) + } + + return &BackupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/backups/constants.go b/resource-manager/postgresql/2024-08-01/backups/constants.go new file mode 100644 index 00000000000..b5c4ed93781 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/constants.go @@ -0,0 +1,51 @@ +package backups + +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 Origin string + +const ( + OriginCustomerOnNegativeDemand Origin = "Customer On-Demand" + OriginFull Origin = "Full" +) + +func PossibleValuesForOrigin() []string { + return []string{ + string(OriginCustomerOnNegativeDemand), + string(OriginFull), + } +} + +func (s *Origin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOrigin(input string) (*Origin, error) { + vals := map[string]Origin{ + "customer on-demand": OriginCustomerOnNegativeDemand, + "full": OriginFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Origin(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/backups/id_backup.go b/resource-manager/postgresql/2024-08-01/backups/id_backup.go new file mode 100644 index 00000000000..6781b8d3476 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/id_backup.go @@ -0,0 +1,139 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupId{}) +} + +var _ resourceids.ResourceId = &BackupId{} + +// BackupId is a struct representing the Resource ID for a Backup +type BackupId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + BackupName string +} + +// NewBackupID returns a new BackupId struct +func NewBackupID(subscriptionId string, resourceGroupName string, flexibleServerName string, backupName string) BackupId { + return BackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + BackupName: backupName, + } +} + +// ParseBackupID parses 'input' into a BackupId +func ParseBackupID(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupIDInsensitively parses 'input' case-insensitively into a BackupId +// note: this method should only be used for API response data and not user input +func ParseBackupIDInsensitively(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.BackupName, ok = input.Parsed["backupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupName", input) + } + + return nil +} + +// ValidateBackupID checks that 'input' can be parsed as a Backup ID +func ValidateBackupID(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 := ParseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup ID +func (id BackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.BackupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup ID +func (id BackupId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupName", "backupName"), + } +} + +// String returns a human-readable description of this Backup ID +func (id BackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Backup Name: %q", id.BackupName), + } + return fmt.Sprintf("Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/backups/id_backup_test.go b/resource-manager/postgresql/2024-08-01/backups/id_backup_test.go new file mode 100644 index 00000000000..5863c240b4a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/id_backup_test.go @@ -0,0 +1,327 @@ +package backups + +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 = &BackupId{} + +func TestNewBackupID(t *testing.T) { + id := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "backupName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.BackupName != "backupName" { + t.Fatalf("Expected %q but got %q for Segment 'BackupName'", id.BackupName, "backupName") + } +} + +func TestFormatBackupID(t *testing.T) { + actual := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "backupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups/backupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups/backupName", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + BackupName: "backupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups/backupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.BackupName != v.Expected.BackupName { + t.Fatalf("Expected %q but got %q for BackupName", v.Expected.BackupName, actual.BackupName) + } + + } +} + +func TestParseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups/backupName", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + BackupName: "backupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/backups/backupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/bAcKuPs/bAcKuPnAmE", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + BackupName: "bAcKuPnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/bAcKuPs/bAcKuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.BackupName != v.Expected.BackupName { + t.Fatalf("Expected %q but got %q for BackupName", v.Expected.BackupName, actual.BackupName) + } + + } +} + +func TestSegmentsForBackupId(t *testing.T) { + segments := BackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupId 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/postgresql/2024-08-01/backups/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/backups/id_flexibleserver.go new file mode 100644 index 00000000000..a5241d9a143 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/id_flexibleserver.go @@ -0,0 +1,130 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/backups/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/backups/id_flexibleserver_test.go new file mode 100644 index 00000000000..77d4d37291a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package backups + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/backups/method_create.go b/resource-manager/postgresql/2024-08-01/backups/method_create.go new file mode 100644 index 00000000000..205f104181b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/method_create.go @@ -0,0 +1,72 @@ +package backups + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Create ... +func (c BackupsClient) Create(ctx context.Context, id BackupId) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c BackupsClient) CreateThenPoll(ctx context.Context, id BackupId) error { + result, err := c.Create(ctx, id) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/backups/method_delete.go b/resource-manager/postgresql/2024-08-01/backups/method_delete.go new file mode 100644 index 00000000000..15a40b88c3c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/method_delete.go @@ -0,0 +1,70 @@ +package backups + +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 BackupsClient) Delete(ctx context.Context, id BackupId) (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 BackupsClient) DeleteThenPoll(ctx context.Context, id BackupId) 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/postgresql/2024-08-01/backups/method_get.go b/resource-manager/postgresql/2024-08-01/backups/method_get.go new file mode 100644 index 00000000000..43a1081766a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/method_get.go @@ -0,0 +1,53 @@ +package backups + +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 *ServerBackup +} + +// Get ... +func (c BackupsClient) Get(ctx context.Context, id BackupId) (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 + } + + var model ServerBackup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/backups/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/backups/method_listbyserver.go new file mode 100644 index 00000000000..b9beeb1342e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/method_listbyserver.go @@ -0,0 +1,105 @@ +package backups + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerBackup +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServerBackup +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/backups", 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 *[]ServerBackup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]ServerBackup, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/backups/model_serverbackup.go b/resource-manager/postgresql/2024-08-01/backups/model_serverbackup.go new file mode 100644 index 00000000000..2e497c54625 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/model_serverbackup.go @@ -0,0 +1,16 @@ +package backups + +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 ServerBackup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServerBackupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/backups/model_serverbackupproperties.go b/resource-manager/postgresql/2024-08-01/backups/model_serverbackupproperties.go new file mode 100644 index 00000000000..46982ef04ba --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/model_serverbackupproperties.go @@ -0,0 +1,28 @@ +package backups + +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 ServerBackupProperties struct { + BackupType *Origin `json:"backupType,omitempty"` + CompletedTime *string `json:"completedTime,omitempty"` + Source *string `json:"source,omitempty"` +} + +func (o *ServerBackupProperties) GetCompletedTimeAsTime() (*time.Time, error) { + if o.CompletedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CompletedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ServerBackupProperties) SetCompletedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CompletedTime = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/backups/predicates.go b/resource-manager/postgresql/2024-08-01/backups/predicates.go new file mode 100644 index 00000000000..8dd0c0c5c20 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/predicates.go @@ -0,0 +1,27 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerBackupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ServerBackupOperationPredicate) Matches(input ServerBackup) 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/postgresql/2024-08-01/backups/version.go b/resource-manager/postgresql/2024-08-01/backups/version.go new file mode 100644 index 00000000000..c76f24acfad --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/backups/version.go @@ -0,0 +1,10 @@ +package backups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/backups/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/README.md b/resource-manager/postgresql/2024-08-01/checknameavailability/README.md new file mode 100644 index 00000000000..75186b8f2d6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/README.md @@ -0,0 +1,63 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/checknameavailability` Documentation + +The `checknameavailability` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/checknameavailability" +``` + + +### Client Initialization + +```go +client := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckNameAvailabilityClient.Execute` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := checknameavailability.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.Execute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CheckNameAvailabilityClient.WithLocationExecute` + +```go +ctx := context.TODO() +id := checknameavailability.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := checknameavailability.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.WithLocationExecute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/client.go b/resource-manager/postgresql/2024-08-01/checknameavailability/client.go new file mode 100644 index 00000000000..777c8ea9e9f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/client.go @@ -0,0 +1,26 @@ +package checknameavailability + +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 CheckNameAvailabilityClient struct { + Client *resourcemanager.Client +} + +func NewCheckNameAvailabilityClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckNameAvailabilityClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checknameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityClient: %+v", err) + } + + return &CheckNameAvailabilityClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/constants.go b/resource-manager/postgresql/2024-08-01/checknameavailability/constants.go new file mode 100644 index 00000000000..07700dec9cf --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/constants.go @@ -0,0 +1,51 @@ +package checknameavailability + +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 CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForCheckNameAvailabilityReason() []string { + return []string{ + string(CheckNameAvailabilityReasonAlreadyExists), + string(CheckNameAvailabilityReasonInvalid), + } +} + +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { + vals := map[string]CheckNameAvailabilityReason{ + "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, + "invalid": CheckNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameAvailabilityReason(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/id_location.go b/resource-manager/postgresql/2024-08-01/checknameavailability/id_location.go new file mode 100644 index 00000000000..b75d19d98ac --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/id_location.go @@ -0,0 +1,121 @@ +package checknameavailability + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DBforPostgreSQL/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/id_location_test.go b/resource-manager/postgresql/2024-08-01/checknameavailability/id_location_test.go new file mode 100644 index 00000000000..545419f9022 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/id_location_test.go @@ -0,0 +1,237 @@ +package checknameavailability + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/postgresql/2024-08-01/checknameavailability/method_execute.go b/resource-manager/postgresql/2024-08-01/checknameavailability/method_execute.go new file mode 100644 index 00000000000..fbb208858c9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/method_execute.go @@ -0,0 +1,59 @@ +package checknameavailability + +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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// Execute ... +func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforPostgreSQL/checkNameAvailability", 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 + } + + var model NameAvailability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/method_withlocationexecute.go b/resource-manager/postgresql/2024-08-01/checknameavailability/method_withlocationexecute.go new file mode 100644 index 00000000000..34090e99b85 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/method_withlocationexecute.go @@ -0,0 +1,58 @@ +package checknameavailability + +import ( + "context" + "fmt" + "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 WithLocationExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// WithLocationExecute ... +func (c CheckNameAvailabilityClient) WithLocationExecute(ctx context.Context, id LocationId, input CheckNameAvailabilityRequest) (result WithLocationExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 + } + + var model NameAvailability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/model_checknameavailabilityrequest.go b/resource-manager/postgresql/2024-08-01/checknameavailability/model_checknameavailabilityrequest.go new file mode 100644 index 00000000000..8c82090e86f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/model_nameavailability.go b/resource-manager/postgresql/2024-08-01/checknameavailability/model_nameavailability.go new file mode 100644 index 00000000000..736601533c7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/model_nameavailability.go @@ -0,0 +1,12 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameAvailability struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/checknameavailability/version.go b/resource-manager/postgresql/2024-08-01/checknameavailability/version.go new file mode 100644 index 00000000000..61e164ee00f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/checknameavailability/version.go @@ -0,0 +1,10 @@ +package checknameavailability + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checknameavailability/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/client.go b/resource-manager/postgresql/2024-08-01/client.go new file mode 100644 index 00000000000..79a36c2b190 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/client.go @@ -0,0 +1,226 @@ +package v2024_08_01 + +// 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/postgresql/2024-08-01/administrators" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/advancedthreatprotectionsettings" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/backups" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/checknameavailability" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/configurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/customoperation" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/databases" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/firewallrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/flexibleservercapabilities" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/locationbasedcapabilities" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/logfiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/longtermretentionbackup" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/migrations" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/post" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/replicas" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/serverrestart" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/servers" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/serverstart" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/serverstop" + "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/virtualendpoints" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Administrators *administrators.AdministratorsClient + AdvancedThreatProtectionSettings *advancedthreatprotectionsettings.AdvancedThreatProtectionSettingsClient + Backups *backups.BackupsClient + CheckNameAvailability *checknameavailability.CheckNameAvailabilityClient + Configurations *configurations.ConfigurationsClient + CustomOperation *customoperation.CustomOperationClient + Databases *databases.DatabasesClient + FirewallRules *firewallrules.FirewallRulesClient + FlexibleServerCapabilities *flexibleservercapabilities.FlexibleServerCapabilitiesClient + GetPrivateDnsZoneSuffix *getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient + LocationBasedCapabilities *locationbasedcapabilities.LocationBasedCapabilitiesClient + LogFiles *logfiles.LogFilesClient + LongTermRetentionBackup *longtermretentionbackup.LongTermRetentionBackupClient + Migrations *migrations.MigrationsClient + POST *post.POSTClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + Replicas *replicas.ReplicasClient + ServerRestart *serverrestart.ServerRestartClient + ServerStart *serverstart.ServerStartClient + ServerStop *serverstop.ServerStopClient + Servers *servers.ServersClient + VirtualEndpoints *virtualendpoints.VirtualEndpointsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + administratorsClient, err := administrators.NewAdministratorsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Administrators client: %+v", err) + } + configureFunc(administratorsClient.Client) + + advancedThreatProtectionSettingsClient, err := advancedthreatprotectionsettings.NewAdvancedThreatProtectionSettingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AdvancedThreatProtectionSettings client: %+v", err) + } + configureFunc(advancedThreatProtectionSettingsClient.Client) + + backupsClient, err := backups.NewBackupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Backups client: %+v", err) + } + configureFunc(backupsClient.Client) + + checkNameAvailabilityClient, err := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailability client: %+v", err) + } + configureFunc(checkNameAvailabilityClient.Client) + + configurationsClient, err := configurations.NewConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Configurations client: %+v", err) + } + configureFunc(configurationsClient.Client) + + customOperationClient, err := customoperation.NewCustomOperationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CustomOperation client: %+v", err) + } + configureFunc(customOperationClient.Client) + + databasesClient, err := databases.NewDatabasesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Databases client: %+v", err) + } + configureFunc(databasesClient.Client) + + firewallRulesClient, err := firewallrules.NewFirewallRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FirewallRules client: %+v", err) + } + configureFunc(firewallRulesClient.Client) + + flexibleServerCapabilitiesClient, err := flexibleservercapabilities.NewFlexibleServerCapabilitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FlexibleServerCapabilities client: %+v", err) + } + configureFunc(flexibleServerCapabilitiesClient.Client) + + getPrivateDnsZoneSuffixClient, err := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GetPrivateDnsZoneSuffix client: %+v", err) + } + configureFunc(getPrivateDnsZoneSuffixClient.Client) + + locationBasedCapabilitiesClient, err := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LocationBasedCapabilities client: %+v", err) + } + configureFunc(locationBasedCapabilitiesClient.Client) + + logFilesClient, err := logfiles.NewLogFilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LogFiles client: %+v", err) + } + configureFunc(logFilesClient.Client) + + longTermRetentionBackupClient, err := longtermretentionbackup.NewLongTermRetentionBackupClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LongTermRetentionBackup client: %+v", err) + } + configureFunc(longTermRetentionBackupClient.Client) + + migrationsClient, err := migrations.NewMigrationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Migrations client: %+v", err) + } + configureFunc(migrationsClient.Client) + + pOSTClient, err := post.NewPOSTClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building POST client: %+v", err) + } + configureFunc(pOSTClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + replicasClient, err := replicas.NewReplicasClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Replicas client: %+v", err) + } + configureFunc(replicasClient.Client) + + serverRestartClient, err := serverrestart.NewServerRestartClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServerRestart client: %+v", err) + } + configureFunc(serverRestartClient.Client) + + serverStartClient, err := serverstart.NewServerStartClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServerStart client: %+v", err) + } + configureFunc(serverStartClient.Client) + + serverStopClient, err := serverstop.NewServerStopClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServerStop client: %+v", err) + } + configureFunc(serverStopClient.Client) + + serversClient, err := servers.NewServersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Servers client: %+v", err) + } + configureFunc(serversClient.Client) + + virtualEndpointsClient, err := virtualendpoints.NewVirtualEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualEndpoints client: %+v", err) + } + configureFunc(virtualEndpointsClient.Client) + + return &Client{ + Administrators: administratorsClient, + AdvancedThreatProtectionSettings: advancedThreatProtectionSettingsClient, + Backups: backupsClient, + CheckNameAvailability: checkNameAvailabilityClient, + Configurations: configurationsClient, + CustomOperation: customOperationClient, + Databases: databasesClient, + FirewallRules: firewallRulesClient, + FlexibleServerCapabilities: flexibleServerCapabilitiesClient, + GetPrivateDnsZoneSuffix: getPrivateDnsZoneSuffixClient, + LocationBasedCapabilities: locationBasedCapabilitiesClient, + LogFiles: logFilesClient, + LongTermRetentionBackup: longTermRetentionBackupClient, + Migrations: migrationsClient, + POST: pOSTClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + Replicas: replicasClient, + ServerRestart: serverRestartClient, + ServerStart: serverStartClient, + ServerStop: serverStopClient, + Servers: serversClient, + VirtualEndpoints: virtualEndpointsClient, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/README.md b/resource-manager/postgresql/2024-08-01/configurations/README.md new file mode 100644 index 00000000000..1c388934244 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/README.md @@ -0,0 +1,87 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/configurations` Documentation + +The `configurations` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/configurations" +``` + + +### Client Initialization + +```go +client := configurations.NewConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := configurations.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "configurationName") + +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: `ConfigurationsClient.ListByServer` + +```go +ctx := context.TODO() +id := configurations.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConfigurationsClient.Put` + +```go +ctx := context.TODO() +id := configurations.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "configurationName") + +payload := configurations.Configuration{ + // ... +} + + +if err := client.PutThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConfigurationsClient.Update` + +```go +ctx := context.TODO() +id := configurations.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "configurationName") + +payload := configurations.ConfigurationForUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/postgresql/2024-08-01/configurations/client.go b/resource-manager/postgresql/2024-08-01/configurations/client.go new file mode 100644 index 00000000000..f927d73df19 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/client.go @@ -0,0 +1,26 @@ +package configurations + +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 ConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "configurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConfigurationsClient: %+v", err) + } + + return &ConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/constants.go b/resource-manager/postgresql/2024-08-01/configurations/constants.go new file mode 100644 index 00000000000..3710c8cfa7d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/constants.go @@ -0,0 +1,57 @@ +package configurations + +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 ConfigurationDataType string + +const ( + ConfigurationDataTypeBoolean ConfigurationDataType = "Boolean" + ConfigurationDataTypeEnumeration ConfigurationDataType = "Enumeration" + ConfigurationDataTypeInteger ConfigurationDataType = "Integer" + ConfigurationDataTypeNumeric ConfigurationDataType = "Numeric" +) + +func PossibleValuesForConfigurationDataType() []string { + return []string{ + string(ConfigurationDataTypeBoolean), + string(ConfigurationDataTypeEnumeration), + string(ConfigurationDataTypeInteger), + string(ConfigurationDataTypeNumeric), + } +} + +func (s *ConfigurationDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigurationDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConfigurationDataType(input string) (*ConfigurationDataType, error) { + vals := map[string]ConfigurationDataType{ + "boolean": ConfigurationDataTypeBoolean, + "enumeration": ConfigurationDataTypeEnumeration, + "integer": ConfigurationDataTypeInteger, + "numeric": ConfigurationDataTypeNumeric, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConfigurationDataType(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/id_configuration.go b/resource-manager/postgresql/2024-08-01/configurations/id_configuration.go new file mode 100644 index 00000000000..daa679a8b3f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/id_configuration.go @@ -0,0 +1,139 @@ +package configurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ConfigurationId{}) +} + +var _ resourceids.ResourceId = &ConfigurationId{} + +// ConfigurationId is a struct representing the Resource ID for a Configuration +type ConfigurationId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + ConfigurationName string +} + +// NewConfigurationID returns a new ConfigurationId struct +func NewConfigurationID(subscriptionId string, resourceGroupName string, flexibleServerName string, configurationName string) ConfigurationId { + return ConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + ConfigurationName: configurationName, + } +} + +// ParseConfigurationID parses 'input' into a ConfigurationId +func ParseConfigurationID(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigurationIDInsensitively parses 'input' case-insensitively into a ConfigurationId +// note: this method should only be used for API response data and not user input +func ParseConfigurationIDInsensitively(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigurationId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.ConfigurationName, ok = input.Parsed["configurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "configurationName", input) + } + + return nil +} + +// ValidateConfigurationID checks that 'input' can be parsed as a Configuration ID +func ValidateConfigurationID(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 := ParseConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Configuration ID +func (id ConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/configurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.ConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Configuration ID +func (id ConfigurationId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticConfigurations", "configurations", "configurations"), + resourceids.UserSpecifiedSegment("configurationName", "configurationName"), + } +} + +// String returns a human-readable description of this Configuration ID +func (id ConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Configuration Name: %q", id.ConfigurationName), + } + return fmt.Sprintf("Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/id_configuration_test.go b/resource-manager/postgresql/2024-08-01/configurations/id_configuration_test.go new file mode 100644 index 00000000000..e86f991b455 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/id_configuration_test.go @@ -0,0 +1,327 @@ +package configurations + +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 = &ConfigurationId{} + +func TestNewConfigurationID(t *testing.T) { + id := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "configurationName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.ConfigurationName != "configurationName" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationName'", id.ConfigurationName, "configurationName") + } +} + +func TestFormatConfigurationID(t *testing.T) { + actual := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "configurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations/configurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations/configurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestParseConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/cOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/configurations/configurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + ConfigurationName: "cOnFiGuRaTiOnNaMe", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestSegmentsForConfigurationId(t *testing.T) { + segments := ConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigurationId 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/postgresql/2024-08-01/configurations/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/configurations/id_flexibleserver.go new file mode 100644 index 00000000000..d2caf44125f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/id_flexibleserver.go @@ -0,0 +1,130 @@ +package configurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/configurations/id_flexibleserver_test.go new file mode 100644 index 00000000000..da4cbf38e83 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package configurations + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/configurations/method_get.go b/resource-manager/postgresql/2024-08-01/configurations/method_get.go new file mode 100644 index 00000000000..4526746d05f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/method_get.go @@ -0,0 +1,53 @@ +package configurations + +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 *Configuration +} + +// Get ... +func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (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 + } + + var model Configuration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/configurations/method_listbyserver.go new file mode 100644 index 00000000000..bef8498dc6b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/method_listbyserver.go @@ -0,0 +1,105 @@ +package configurations + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Configuration +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []Configuration +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/configurations", 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 *[]Configuration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ConfigurationOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ConfigurationOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Configuration, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/method_put.go b/resource-manager/postgresql/2024-08-01/configurations/method_put.go new file mode 100644 index 00000000000..3d62c73d69e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/method_put.go @@ -0,0 +1,76 @@ +package configurations + +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 PutOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Configuration +} + +// Put ... +func (c ConfigurationsClient) Put(ctx context.Context, id ConfigurationId, input Configuration) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// PutThenPoll performs Put then polls until it's completed +func (c ConfigurationsClient) PutThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { + result, err := c.Put(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Put: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Put: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/method_update.go b/resource-manager/postgresql/2024-08-01/configurations/method_update.go new file mode 100644 index 00000000000..28a86db0c76 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/method_update.go @@ -0,0 +1,76 @@ +package configurations + +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 + Model *Configuration +} + +// Update ... +func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input ConfigurationForUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input ConfigurationForUpdate) 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/postgresql/2024-08-01/configurations/model_configuration.go b/resource-manager/postgresql/2024-08-01/configurations/model_configuration.go new file mode 100644 index 00000000000..b541b4aa206 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/model_configuration.go @@ -0,0 +1,16 @@ +package configurations + +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 Configuration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/model_configurationforupdate.go b/resource-manager/postgresql/2024-08-01/configurations/model_configurationforupdate.go new file mode 100644 index 00000000000..836ca025810 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/model_configurationforupdate.go @@ -0,0 +1,8 @@ +package configurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationForUpdate struct { + Properties *ConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/model_configurationproperties.go b/resource-manager/postgresql/2024-08-01/configurations/model_configurationproperties.go new file mode 100644 index 00000000000..6e3b33946a4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/model_configurationproperties.go @@ -0,0 +1,18 @@ +package configurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationProperties struct { + AllowedValues *string `json:"allowedValues,omitempty"` + DataType *ConfigurationDataType `json:"dataType,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` + Description *string `json:"description,omitempty"` + DocumentationLink *string `json:"documentationLink,omitempty"` + IsConfigPendingRestart *bool `json:"isConfigPendingRestart,omitempty"` + IsDynamicConfig *bool `json:"isDynamicConfig,omitempty"` + IsReadOnly *bool `json:"isReadOnly,omitempty"` + Source *string `json:"source,omitempty"` + Unit *string `json:"unit,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/configurations/predicates.go b/resource-manager/postgresql/2024-08-01/configurations/predicates.go new file mode 100644 index 00000000000..4ff843ebaef --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/predicates.go @@ -0,0 +1,27 @@ +package configurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ConfigurationOperationPredicate) Matches(input Configuration) 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/postgresql/2024-08-01/configurations/version.go b/resource-manager/postgresql/2024-08-01/configurations/version.go new file mode 100644 index 00000000000..c5dc9fcf4a9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/configurations/version.go @@ -0,0 +1,10 @@ +package configurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/configurations/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/README.md b/resource-manager/postgresql/2024-08-01/customoperation/README.md new file mode 100644 index 00000000000..544ab56e74b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/customoperation` Documentation + +The `customoperation` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/customoperation" +``` + + +### Client Initialization + +```go +client := customoperation.NewCustomOperationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CustomOperationClient.CheckMigrationNameAvailability` + +```go +ctx := context.TODO() +id := customoperation.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := customoperation.MigrationNameAvailabilityResource{ + // ... +} + + +read, err := client.CheckMigrationNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/postgresql/2024-08-01/customoperation/client.go b/resource-manager/postgresql/2024-08-01/customoperation/client.go new file mode 100644 index 00000000000..dd76465d0b7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/client.go @@ -0,0 +1,26 @@ +package customoperation + +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 CustomOperationClient struct { + Client *resourcemanager.Client +} + +func NewCustomOperationClientWithBaseURI(sdkApi sdkEnv.Api) (*CustomOperationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "customoperation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CustomOperationClient: %+v", err) + } + + return &CustomOperationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/constants.go b/resource-manager/postgresql/2024-08-01/customoperation/constants.go new file mode 100644 index 00000000000..cc163c7370f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/constants.go @@ -0,0 +1,51 @@ +package customoperation + +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 MigrationNameAvailabilityReason string + +const ( + MigrationNameAvailabilityReasonAlreadyExists MigrationNameAvailabilityReason = "AlreadyExists" + MigrationNameAvailabilityReasonInvalid MigrationNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForMigrationNameAvailabilityReason() []string { + return []string{ + string(MigrationNameAvailabilityReasonAlreadyExists), + string(MigrationNameAvailabilityReasonInvalid), + } +} + +func (s *MigrationNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationNameAvailabilityReason(input string) (*MigrationNameAvailabilityReason, error) { + vals := map[string]MigrationNameAvailabilityReason{ + "alreadyexists": MigrationNameAvailabilityReasonAlreadyExists, + "invalid": MigrationNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationNameAvailabilityReason(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver.go new file mode 100644 index 00000000000..0f6154d881d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver.go @@ -0,0 +1,130 @@ +package customoperation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver_test.go new file mode 100644 index 00000000000..9417a483ab8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package customoperation + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/customoperation/method_checkmigrationnameavailability.go b/resource-manager/postgresql/2024-08-01/customoperation/method_checkmigrationnameavailability.go new file mode 100644 index 00000000000..3235480326b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/method_checkmigrationnameavailability.go @@ -0,0 +1,58 @@ +package customoperation + +import ( + "context" + "fmt" + "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 CheckMigrationNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationNameAvailabilityResource +} + +// CheckMigrationNameAvailability ... +func (c CustomOperationClient) CheckMigrationNameAvailability(ctx context.Context, id FlexibleServerId, input MigrationNameAvailabilityResource) (result CheckMigrationNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkMigrationNameAvailability", 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 + } + + var model MigrationNameAvailabilityResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/model_migrationnameavailabilityresource.go b/resource-manager/postgresql/2024-08-01/customoperation/model_migrationnameavailabilityresource.go new file mode 100644 index 00000000000..44c420db9b5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/model_migrationnameavailabilityresource.go @@ -0,0 +1,12 @@ +package customoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationNameAvailabilityResource struct { + Message *string `json:"message,omitempty"` + Name string `json:"name"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *MigrationNameAvailabilityReason `json:"reason,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/postgresql/2024-08-01/customoperation/version.go b/resource-manager/postgresql/2024-08-01/customoperation/version.go new file mode 100644 index 00000000000..5aa72ea9803 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/customoperation/version.go @@ -0,0 +1,10 @@ +package customoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/customoperation/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/databases/README.md b/resource-manager/postgresql/2024-08-01/databases/README.md new file mode 100644 index 00000000000..32e6db658d4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/databases` Documentation + +The `databases` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/databases" +``` + + +### Client Initialization + +```go +client := databases.NewDatabasesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DatabasesClient.Create` + +```go +ctx := context.TODO() +id := databases.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "databaseName") + +payload := databases.Database{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasesClient.Delete` + +```go +ctx := context.TODO() +id := databases.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "databaseName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasesClient.Get` + +```go +ctx := context.TODO() +id := databases.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "databaseName") + +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: `DatabasesClient.ListByServer` + +```go +ctx := context.TODO() +id := databases.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/databases/client.go b/resource-manager/postgresql/2024-08-01/databases/client.go new file mode 100644 index 00000000000..87de2d4fe59 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/client.go @@ -0,0 +1,26 @@ +package databases + +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 DatabasesClient struct { + Client *resourcemanager.Client +} + +func NewDatabasesClientWithBaseURI(sdkApi sdkEnv.Api) (*DatabasesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "databases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasesClient: %+v", err) + } + + return &DatabasesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/databases/id_database.go b/resource-manager/postgresql/2024-08-01/databases/id_database.go new file mode 100644 index 00000000000..f0da07ac18d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/id_database.go @@ -0,0 +1,139 @@ +package databases + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DatabaseId{}) +} + +var _ resourceids.ResourceId = &DatabaseId{} + +// DatabaseId is a struct representing the Resource ID for a Database +type DatabaseId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + DatabaseName string +} + +// NewDatabaseID returns a new DatabaseId struct +func NewDatabaseID(subscriptionId string, resourceGroupName string, flexibleServerName string, databaseName string) DatabaseId { + return DatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + DatabaseName: databaseName, + } +} + +// ParseDatabaseID parses 'input' into a DatabaseId +func ParseDatabaseID(input string) (*DatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId +// note: this method should only be used for API response data and not user input +func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + return nil +} + +// ValidateDatabaseID checks that 'input' can be parsed as a Database ID +func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database ID +func (id DatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/databases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.DatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database ID +func (id DatabaseId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + } +} + +// String returns a human-readable description of this Database ID +func (id DatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + } + return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/databases/id_database_test.go b/resource-manager/postgresql/2024-08-01/databases/id_database_test.go new file mode 100644 index 00000000000..f191274a59f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/id_database_test.go @@ -0,0 +1,327 @@ +package databases + +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 = &DatabaseId{} + +func TestNewDatabaseID(t *testing.T) { + id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "databaseName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } +} + +func TestFormatDatabaseID(t *testing.T) { + actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "databaseName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases/databaseName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases/databaseName", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + DatabaseName: "databaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases/databaseName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + } +} + +func TestParseDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/dAtAbAsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases/databaseName", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + DatabaseName: "databaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/databases/databaseName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/dAtAbAsEs/dAtAbAsEnAmE", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + DatabaseName: "dAtAbAsEnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/dAtAbAsEs/dAtAbAsEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + } +} + +func TestSegmentsForDatabaseId(t *testing.T) { + segments := DatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseId 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/postgresql/2024-08-01/databases/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/databases/id_flexibleserver.go new file mode 100644 index 00000000000..3692b6f0892 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/id_flexibleserver.go @@ -0,0 +1,130 @@ +package databases + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/databases/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/databases/id_flexibleserver_test.go new file mode 100644 index 00000000000..b6fcc967d2a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package databases + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/databases/method_create.go b/resource-manager/postgresql/2024-08-01/databases/method_create.go new file mode 100644 index 00000000000..003069ca5b1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/method_create.go @@ -0,0 +1,76 @@ +package databases + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Database +} + +// Create ... +func (c DatabasesClient) Create(ctx context.Context, id DatabaseId, input Database) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c DatabasesClient) CreateThenPoll(ctx context.Context, id DatabaseId, input Database) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/databases/method_delete.go b/resource-manager/postgresql/2024-08-01/databases/method_delete.go new file mode 100644 index 00000000000..dc03e526611 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/method_delete.go @@ -0,0 +1,71 @@ +package databases + +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 DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) 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/postgresql/2024-08-01/databases/method_get.go b/resource-manager/postgresql/2024-08-01/databases/method_get.go new file mode 100644 index 00000000000..df1a873b818 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/method_get.go @@ -0,0 +1,53 @@ +package databases + +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 *Database +} + +// Get ... +func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (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 + } + + var model Database + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/databases/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/databases/method_listbyserver.go new file mode 100644 index 00000000000..68487e28ffb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/method_listbyserver.go @@ -0,0 +1,105 @@ +package databases + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Database +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []Database +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/databases", 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 *[]Database `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Database, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/databases/model_database.go b/resource-manager/postgresql/2024-08-01/databases/model_database.go new file mode 100644 index 00000000000..f656e011163 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/model_database.go @@ -0,0 +1,16 @@ +package databases + +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 Database struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabaseProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/databases/model_databaseproperties.go b/resource-manager/postgresql/2024-08-01/databases/model_databaseproperties.go new file mode 100644 index 00000000000..85fcbd70d57 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/model_databaseproperties.go @@ -0,0 +1,9 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseProperties struct { + Charset *string `json:"charset,omitempty"` + Collation *string `json:"collation,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/databases/predicates.go b/resource-manager/postgresql/2024-08-01/databases/predicates.go new file mode 100644 index 00000000000..3d55136d0fb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/predicates.go @@ -0,0 +1,27 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DatabaseOperationPredicate) Matches(input Database) 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/postgresql/2024-08-01/databases/version.go b/resource-manager/postgresql/2024-08-01/databases/version.go new file mode 100644 index 00000000000..bcb1af1009b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/databases/version.go @@ -0,0 +1,10 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/databases/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/README.md b/resource-manager/postgresql/2024-08-01/firewallrules/README.md new file mode 100644 index 00000000000..43527d8e1b9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/firewallrules` Documentation + +The `firewallrules` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/firewallrules" +``` + + +### Client Initialization + +```go +client := firewallrules.NewFirewallRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FirewallRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := firewallrules.NewFirewallRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "firewallRuleName") + +payload := firewallrules.FirewallRule{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallRulesClient.Delete` + +```go +ctx := context.TODO() +id := firewallrules.NewFirewallRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "firewallRuleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallRulesClient.Get` + +```go +ctx := context.TODO() +id := firewallrules.NewFirewallRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "firewallRuleName") + +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: `FirewallRulesClient.ListByServer` + +```go +ctx := context.TODO() +id := firewallrules.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/client.go b/resource-manager/postgresql/2024-08-01/firewallrules/client.go new file mode 100644 index 00000000000..5ecd222a8c7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/client.go @@ -0,0 +1,26 @@ +package firewallrules + +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 FirewallRulesClient struct { + Client *resourcemanager.Client +} + +func NewFirewallRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*FirewallRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "firewallrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallRulesClient: %+v", err) + } + + return &FirewallRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule.go b/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule.go new file mode 100644 index 00000000000..8c7587a62e6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule.go @@ -0,0 +1,139 @@ +package firewallrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FirewallRuleId{}) +} + +var _ resourceids.ResourceId = &FirewallRuleId{} + +// FirewallRuleId is a struct representing the Resource ID for a Firewall Rule +type FirewallRuleId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + FirewallRuleName string +} + +// NewFirewallRuleID returns a new FirewallRuleId struct +func NewFirewallRuleID(subscriptionId string, resourceGroupName string, flexibleServerName string, firewallRuleName string) FirewallRuleId { + return FirewallRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + FirewallRuleName: firewallRuleName, + } +} + +// ParseFirewallRuleID parses 'input' into a FirewallRuleId +func ParseFirewallRuleID(input string) (*FirewallRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFirewallRuleIDInsensitively parses 'input' case-insensitively into a FirewallRuleId +// note: this method should only be used for API response data and not user input +func ParseFirewallRuleIDInsensitively(input string) (*FirewallRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FirewallRuleId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.FirewallRuleName, ok = input.Parsed["firewallRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "firewallRuleName", input) + } + + return nil +} + +// ValidateFirewallRuleID checks that 'input' can be parsed as a Firewall Rule ID +func ValidateFirewallRuleID(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 := ParseFirewallRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Firewall Rule ID +func (id FirewallRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/firewallRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.FirewallRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Firewall Rule ID +func (id FirewallRuleId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticFirewallRules", "firewallRules", "firewallRules"), + resourceids.UserSpecifiedSegment("firewallRuleName", "firewallRuleName"), + } +} + +// String returns a human-readable description of this Firewall Rule ID +func (id FirewallRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Firewall Rule Name: %q", id.FirewallRuleName), + } + return fmt.Sprintf("Firewall Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule_test.go b/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule_test.go new file mode 100644 index 00000000000..e94421ba9bc --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/id_firewallrule_test.go @@ -0,0 +1,327 @@ +package firewallrules + +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 = &FirewallRuleId{} + +func TestNewFirewallRuleID(t *testing.T) { + id := NewFirewallRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "firewallRuleName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.FirewallRuleName != "firewallRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'FirewallRuleName'", id.FirewallRuleName, "firewallRuleName") + } +} + +func TestFormatFirewallRuleID(t *testing.T) { + actual := NewFirewallRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "firewallRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules/firewallRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFirewallRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallRuleId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules/firewallRuleName", + Expected: &FirewallRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + FirewallRuleName: "firewallRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules/firewallRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallRuleID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.FirewallRuleName != v.Expected.FirewallRuleName { + t.Fatalf("Expected %q but got %q for FirewallRuleName", v.Expected.FirewallRuleName, actual.FirewallRuleName) + } + + } +} + +func TestParseFirewallRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallRuleId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/fIrEwAlLrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules/firewallRuleName", + Expected: &FirewallRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + FirewallRuleName: "firewallRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/firewallRules/firewallRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/fIrEwAlLrUlEs/fIrEwAlLrUlEnAmE", + Expected: &FirewallRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + FirewallRuleName: "fIrEwAlLrUlEnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/fIrEwAlLrUlEs/fIrEwAlLrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallRuleIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.FirewallRuleName != v.Expected.FirewallRuleName { + t.Fatalf("Expected %q but got %q for FirewallRuleName", v.Expected.FirewallRuleName, actual.FirewallRuleName) + } + + } +} + +func TestSegmentsForFirewallRuleId(t *testing.T) { + segments := FirewallRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FirewallRuleId 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/postgresql/2024-08-01/firewallrules/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/firewallrules/id_flexibleserver.go new file mode 100644 index 00000000000..2763dceed8b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/id_flexibleserver.go @@ -0,0 +1,130 @@ +package firewallrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/firewallrules/id_flexibleserver_test.go new file mode 100644 index 00000000000..93b573c9c99 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package firewallrules + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/firewallrules/method_createorupdate.go b/resource-manager/postgresql/2024-08-01/firewallrules/method_createorupdate.go new file mode 100644 index 00000000000..8a5fca1cd9f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/method_createorupdate.go @@ -0,0 +1,76 @@ +package firewallrules + +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 + Model *FirewallRule +} + +// CreateOrUpdate ... +func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) 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/postgresql/2024-08-01/firewallrules/method_delete.go b/resource-manager/postgresql/2024-08-01/firewallrules/method_delete.go new file mode 100644 index 00000000000..44b95e975c0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/method_delete.go @@ -0,0 +1,71 @@ +package firewallrules + +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 FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) 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/postgresql/2024-08-01/firewallrules/method_get.go b/resource-manager/postgresql/2024-08-01/firewallrules/method_get.go new file mode 100644 index 00000000000..6b53b2919c9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/method_get.go @@ -0,0 +1,53 @@ +package firewallrules + +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 *FirewallRule +} + +// Get ... +func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (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 + } + + var model FirewallRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/firewallrules/method_listbyserver.go new file mode 100644 index 00000000000..5f3772c0193 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/method_listbyserver.go @@ -0,0 +1,105 @@ +package firewallrules + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallRule +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []FirewallRule +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/firewallRules", 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 *[]FirewallRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]FirewallRule, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallrule.go b/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallrule.go new file mode 100644 index 00000000000..e6c4db6725d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallrule.go @@ -0,0 +1,16 @@ +package firewallrules + +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 FirewallRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties FirewallRuleProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallruleproperties.go b/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallruleproperties.go new file mode 100644 index 00000000000..fca4e1c3684 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/model_firewallruleproperties.go @@ -0,0 +1,9 @@ +package firewallrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallRuleProperties struct { + EndIPAddress string `json:"endIpAddress"` + StartIPAddress string `json:"startIpAddress"` +} diff --git a/resource-manager/postgresql/2024-08-01/firewallrules/predicates.go b/resource-manager/postgresql/2024-08-01/firewallrules/predicates.go new file mode 100644 index 00000000000..fb7011b1d3b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/predicates.go @@ -0,0 +1,27 @@ +package firewallrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FirewallRuleOperationPredicate) Matches(input FirewallRule) 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/postgresql/2024-08-01/firewallrules/version.go b/resource-manager/postgresql/2024-08-01/firewallrules/version.go new file mode 100644 index 00000000000..d1bb00cf1ea --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/firewallrules/version.go @@ -0,0 +1,10 @@ +package firewallrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/firewallrules/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/README.md b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/README.md new file mode 100644 index 00000000000..e20d4a08414 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/flexibleservercapabilities` Documentation + +The `flexibleservercapabilities` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/flexibleservercapabilities" +``` + + +### Client Initialization + +```go +client := flexibleservercapabilities.NewFlexibleServerCapabilitiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FlexibleServerCapabilitiesClient.ServerCapabilitiesList` + +```go +ctx := context.TODO() +id := flexibleservercapabilities.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ServerCapabilitiesList(ctx, id)` can be used to do batched pagination +items, err := client.ServerCapabilitiesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/client.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/client.go new file mode 100644 index 00000000000..d0fe6de3ae0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/client.go @@ -0,0 +1,26 @@ +package flexibleservercapabilities + +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 FlexibleServerCapabilitiesClient struct { + Client *resourcemanager.Client +} + +func NewFlexibleServerCapabilitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*FlexibleServerCapabilitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "flexibleservercapabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FlexibleServerCapabilitiesClient: %+v", err) + } + + return &FlexibleServerCapabilitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/constants.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/constants.go new file mode 100644 index 00000000000..09ddff04539 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/constants.go @@ -0,0 +1,385 @@ +package flexibleservercapabilities + +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 CapabilityStatus string + +const ( + CapabilityStatusAvailable CapabilityStatus = "Available" + CapabilityStatusDefault CapabilityStatus = "Default" + CapabilityStatusDisabled CapabilityStatus = "Disabled" + CapabilityStatusVisible CapabilityStatus = "Visible" +) + +func PossibleValuesForCapabilityStatus() []string { + return []string{ + string(CapabilityStatusAvailable), + string(CapabilityStatusDefault), + string(CapabilityStatusDisabled), + string(CapabilityStatusVisible), + } +} + +func (s *CapabilityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapabilityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCapabilityStatus(input string) (*CapabilityStatus, error) { + vals := map[string]CapabilityStatus{ + "available": CapabilityStatusAvailable, + "default": CapabilityStatusDefault, + "disabled": CapabilityStatusDisabled, + "visible": CapabilityStatusVisible, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CapabilityStatus(input) + return &out, nil +} + +type FastProvisioningSupportedEnum string + +const ( + FastProvisioningSupportedEnumDisabled FastProvisioningSupportedEnum = "Disabled" + FastProvisioningSupportedEnumEnabled FastProvisioningSupportedEnum = "Enabled" +) + +func PossibleValuesForFastProvisioningSupportedEnum() []string { + return []string{ + string(FastProvisioningSupportedEnumDisabled), + string(FastProvisioningSupportedEnumEnabled), + } +} + +func (s *FastProvisioningSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFastProvisioningSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFastProvisioningSupportedEnum(input string) (*FastProvisioningSupportedEnum, error) { + vals := map[string]FastProvisioningSupportedEnum{ + "disabled": FastProvisioningSupportedEnumDisabled, + "enabled": FastProvisioningSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FastProvisioningSupportedEnum(input) + return &out, nil +} + +type GeoBackupSupportedEnum string + +const ( + GeoBackupSupportedEnumDisabled GeoBackupSupportedEnum = "Disabled" + GeoBackupSupportedEnumEnabled GeoBackupSupportedEnum = "Enabled" +) + +func PossibleValuesForGeoBackupSupportedEnum() []string { + return []string{ + string(GeoBackupSupportedEnumDisabled), + string(GeoBackupSupportedEnumEnabled), + } +} + +func (s *GeoBackupSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoBackupSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeoBackupSupportedEnum(input string) (*GeoBackupSupportedEnum, error) { + vals := map[string]GeoBackupSupportedEnum{ + "disabled": GeoBackupSupportedEnumDisabled, + "enabled": GeoBackupSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GeoBackupSupportedEnum(input) + return &out, nil +} + +type HaMode string + +const ( + HaModeSameZone HaMode = "SameZone" + HaModeZoneRedundant HaMode = "ZoneRedundant" +) + +func PossibleValuesForHaMode() []string { + return []string{ + string(HaModeSameZone), + string(HaModeZoneRedundant), + } +} + +func (s *HaMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHaMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHaMode(input string) (*HaMode, error) { + vals := map[string]HaMode{ + "samezone": HaModeSameZone, + "zoneredundant": HaModeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HaMode(input) + return &out, nil +} + +type OnlineResizeSupportedEnum string + +const ( + OnlineResizeSupportedEnumDisabled OnlineResizeSupportedEnum = "Disabled" + OnlineResizeSupportedEnumEnabled OnlineResizeSupportedEnum = "Enabled" +) + +func PossibleValuesForOnlineResizeSupportedEnum() []string { + return []string{ + string(OnlineResizeSupportedEnumDisabled), + string(OnlineResizeSupportedEnumEnabled), + } +} + +func (s *OnlineResizeSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOnlineResizeSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOnlineResizeSupportedEnum(input string) (*OnlineResizeSupportedEnum, error) { + vals := map[string]OnlineResizeSupportedEnum{ + "disabled": OnlineResizeSupportedEnumDisabled, + "enabled": OnlineResizeSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OnlineResizeSupportedEnum(input) + return &out, nil +} + +type RestrictedEnum string + +const ( + RestrictedEnumDisabled RestrictedEnum = "Disabled" + RestrictedEnumEnabled RestrictedEnum = "Enabled" +) + +func PossibleValuesForRestrictedEnum() []string { + return []string{ + string(RestrictedEnumDisabled), + string(RestrictedEnumEnabled), + } +} + +func (s *RestrictedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestrictedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestrictedEnum(input string) (*RestrictedEnum, error) { + vals := map[string]RestrictedEnum{ + "disabled": RestrictedEnumDisabled, + "enabled": RestrictedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestrictedEnum(input) + return &out, nil +} + +type StorageAutoGrowthSupportedEnum string + +const ( + StorageAutoGrowthSupportedEnumDisabled StorageAutoGrowthSupportedEnum = "Disabled" + StorageAutoGrowthSupportedEnumEnabled StorageAutoGrowthSupportedEnum = "Enabled" +) + +func PossibleValuesForStorageAutoGrowthSupportedEnum() []string { + return []string{ + string(StorageAutoGrowthSupportedEnumDisabled), + string(StorageAutoGrowthSupportedEnumEnabled), + } +} + +func (s *StorageAutoGrowthSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAutoGrowthSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAutoGrowthSupportedEnum(input string) (*StorageAutoGrowthSupportedEnum, error) { + vals := map[string]StorageAutoGrowthSupportedEnum{ + "disabled": StorageAutoGrowthSupportedEnumDisabled, + "enabled": StorageAutoGrowthSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAutoGrowthSupportedEnum(input) + return &out, nil +} + +type ZoneRedundantHaAndGeoBackupSupportedEnum string + +const ( + ZoneRedundantHaAndGeoBackupSupportedEnumDisabled ZoneRedundantHaAndGeoBackupSupportedEnum = "Disabled" + ZoneRedundantHaAndGeoBackupSupportedEnumEnabled ZoneRedundantHaAndGeoBackupSupportedEnum = "Enabled" +) + +func PossibleValuesForZoneRedundantHaAndGeoBackupSupportedEnum() []string { + return []string{ + string(ZoneRedundantHaAndGeoBackupSupportedEnumDisabled), + string(ZoneRedundantHaAndGeoBackupSupportedEnumEnabled), + } +} + +func (s *ZoneRedundantHaAndGeoBackupSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneRedundantHaAndGeoBackupSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneRedundantHaAndGeoBackupSupportedEnum(input string) (*ZoneRedundantHaAndGeoBackupSupportedEnum, error) { + vals := map[string]ZoneRedundantHaAndGeoBackupSupportedEnum{ + "disabled": ZoneRedundantHaAndGeoBackupSupportedEnumDisabled, + "enabled": ZoneRedundantHaAndGeoBackupSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneRedundantHaAndGeoBackupSupportedEnum(input) + return &out, nil +} + +type ZoneRedundantHaSupportedEnum string + +const ( + ZoneRedundantHaSupportedEnumDisabled ZoneRedundantHaSupportedEnum = "Disabled" + ZoneRedundantHaSupportedEnumEnabled ZoneRedundantHaSupportedEnum = "Enabled" +) + +func PossibleValuesForZoneRedundantHaSupportedEnum() []string { + return []string{ + string(ZoneRedundantHaSupportedEnumDisabled), + string(ZoneRedundantHaSupportedEnumEnabled), + } +} + +func (s *ZoneRedundantHaSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneRedundantHaSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneRedundantHaSupportedEnum(input string) (*ZoneRedundantHaSupportedEnum, error) { + vals := map[string]ZoneRedundantHaSupportedEnum{ + "disabled": ZoneRedundantHaSupportedEnumDisabled, + "enabled": ZoneRedundantHaSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneRedundantHaSupportedEnum(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver.go new file mode 100644 index 00000000000..d431df079ec --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver.go @@ -0,0 +1,130 @@ +package flexibleservercapabilities + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver_test.go new file mode 100644 index 00000000000..dae573d7d82 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package flexibleservercapabilities + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/flexibleservercapabilities/method_servercapabilitieslist.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/method_servercapabilitieslist.go new file mode 100644 index 00000000000..155caa280c4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/method_servercapabilitieslist.go @@ -0,0 +1,105 @@ +package flexibleservercapabilities + +import ( + "context" + "fmt" + "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 ServerCapabilitiesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FlexibleServerCapability +} + +type ServerCapabilitiesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FlexibleServerCapability +} + +type ServerCapabilitiesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ServerCapabilitiesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ServerCapabilitiesList ... +func (c FlexibleServerCapabilitiesClient) ServerCapabilitiesList(ctx context.Context, id FlexibleServerId) (result ServerCapabilitiesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ServerCapabilitiesListCustomPager{}, + Path: fmt.Sprintf("%s/capabilities", 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 *[]FlexibleServerCapability `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ServerCapabilitiesListComplete retrieves all the results into a single object +func (c FlexibleServerCapabilitiesClient) ServerCapabilitiesListComplete(ctx context.Context, id FlexibleServerId) (ServerCapabilitiesListCompleteResult, error) { + return c.ServerCapabilitiesListCompleteMatchingPredicate(ctx, id, FlexibleServerCapabilityOperationPredicate{}) +} + +// ServerCapabilitiesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FlexibleServerCapabilitiesClient) ServerCapabilitiesListCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FlexibleServerCapabilityOperationPredicate) (result ServerCapabilitiesListCompleteResult, err error) { + items := make([]FlexibleServerCapability, 0) + + resp, err := c.ServerCapabilitiesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ServerCapabilitiesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_fastprovisioningeditioncapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_fastprovisioningeditioncapability.go new file mode 100644 index 00000000000..a22c82ad417 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_fastprovisioningeditioncapability.go @@ -0,0 +1,14 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FastProvisioningEditionCapability struct { + Reason *string `json:"reason,omitempty"` + ServerCount *int64 `json:"serverCount,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedServerVersions *string `json:"supportedServerVersions,omitempty"` + SupportedSku *string `json:"supportedSku,omitempty"` + SupportedStorageGb *int64 `json:"supportedStorageGb,omitempty"` + SupportedTier *string `json:"supportedTier,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservercapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservercapability.go new file mode 100644 index 00000000000..801bfafa412 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservercapability.go @@ -0,0 +1,20 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerCapability struct { + FastProvisioningSupported *FastProvisioningSupportedEnum `json:"fastProvisioningSupported,omitempty"` + GeoBackupSupported *GeoBackupSupportedEnum `json:"geoBackupSupported,omitempty"` + Name *string `json:"name,omitempty"` + OnlineResizeSupported *OnlineResizeSupportedEnum `json:"onlineResizeSupported,omitempty"` + Reason *string `json:"reason,omitempty"` + Restricted *RestrictedEnum `json:"restricted,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + StorageAutoGrowthSupported *StorageAutoGrowthSupportedEnum `json:"storageAutoGrowthSupported,omitempty"` + SupportedFastProvisioningEditions *[]FastProvisioningEditionCapability `json:"supportedFastProvisioningEditions,omitempty"` + SupportedServerEditions *[]FlexibleServerEditionCapability `json:"supportedServerEditions,omitempty"` + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + ZoneRedundantHaAndGeoBackupSupported *ZoneRedundantHaAndGeoBackupSupportedEnum `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"` + ZoneRedundantHaSupported *ZoneRedundantHaSupportedEnum `json:"zoneRedundantHaSupported,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservereditioncapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservereditioncapability.go new file mode 100644 index 00000000000..d836a67ed9e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_flexibleservereditioncapability.go @@ -0,0 +1,13 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerEditionCapability struct { + DefaultSkuName *string `json:"defaultSkuName,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedServerSkus *[]ServerSkuCapability `json:"supportedServerSkus,omitempty"` + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverskucapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverskucapability.go new file mode 100644 index 00000000000..a573a965058 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverskucapability.go @@ -0,0 +1,15 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerSkuCapability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedHaMode *[]HaMode `json:"supportedHaMode,omitempty"` + SupportedIops *int64 `json:"supportedIops,omitempty"` + SupportedMemoryPerVcoreMb *int64 `json:"supportedMemoryPerVcoreMb,omitempty"` + SupportedZones *[]string `json:"supportedZones,omitempty"` + VCores *int64 `json:"vCores,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverversioncapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverversioncapability.go new file mode 100644 index 00000000000..e2a101c54d6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_serverversioncapability.go @@ -0,0 +1,11 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerVersionCapability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedVersionsToUpgrade *[]string `json:"supportedVersionsToUpgrade,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storageeditioncapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storageeditioncapability.go new file mode 100644 index 00000000000..8e935e1bef9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storageeditioncapability.go @@ -0,0 +1,12 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageEditionCapability struct { + DefaultStorageSizeMb *int64 `json:"defaultStorageSizeMb,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedStorageMb *[]StorageMbCapability `json:"supportedStorageMb,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagembcapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagembcapability.go new file mode 100644 index 00000000000..f5406cd994e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagembcapability.go @@ -0,0 +1,17 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMbCapability struct { + DefaultIopsTier *string `json:"defaultIopsTier,omitempty"` + MaximumStorageSizeMb *int64 `json:"maximumStorageSizeMb,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + StorageSizeMb *int64 `json:"storageSizeMb,omitempty"` + SupportedIops *int64 `json:"supportedIops,omitempty"` + SupportedIopsTiers *[]StorageTierCapability `json:"supportedIopsTiers,omitempty"` + SupportedMaximumIops *int64 `json:"supportedMaximumIops,omitempty"` + SupportedMaximumThroughput *int64 `json:"supportedMaximumThroughput,omitempty"` + SupportedThroughput *int64 `json:"supportedThroughput,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagetiercapability.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagetiercapability.go new file mode 100644 index 00000000000..b2440547d4a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/model_storagetiercapability.go @@ -0,0 +1,11 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTierCapability struct { + Iops *int64 `json:"iops,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/predicates.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/predicates.go new file mode 100644 index 00000000000..4039d4e5aff --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/predicates.go @@ -0,0 +1,22 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerCapabilityOperationPredicate struct { + Name *string + Reason *string +} + +func (p FlexibleServerCapabilityOperationPredicate) Matches(input FlexibleServerCapability) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Reason != nil && (input.Reason == nil || *p.Reason != *input.Reason) { + return false + } + + return true +} diff --git a/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/version.go b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/version.go new file mode 100644 index 00000000000..e4c0abccac0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/flexibleservercapabilities/version.go @@ -0,0 +1,10 @@ +package flexibleservercapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/flexibleservercapabilities/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/client.go b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/client.go new file mode 100644 index 00000000000..cf157d284cc --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/client.go @@ -0,0 +1,26 @@ +package getprivatednszonesuffix + +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 GetPrivateDnsZoneSuffixClient struct { + Client *resourcemanager.Client +} + +func NewGetPrivateDnsZoneSuffixClientWithBaseURI(sdkApi sdkEnv.Api) (*GetPrivateDnsZoneSuffixClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "getprivatednszonesuffix", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateDnsZoneSuffixClient: %+v", err) + } + + return &GetPrivateDnsZoneSuffixClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/method_execute.go b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/method_execute.go new file mode 100644 index 00000000000..f9e99478551 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/method_execute.go @@ -0,0 +1,53 @@ +package getprivatednszonesuffix + +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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// Execute ... +func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix", + } + + 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 + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/version.go b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/version.go new file mode 100644 index 00000000000..97667fe4889 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/getprivatednszonesuffix/version.go @@ -0,0 +1,10 @@ +package getprivatednszonesuffix + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/getprivatednszonesuffix/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/README.md b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/README.md new file mode 100644 index 00000000000..d6d62a099f9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/locationbasedcapabilities` Documentation + +The `locationbasedcapabilities` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/locationbasedcapabilities" +``` + + +### Client Initialization + +```go +client := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LocationBasedCapabilitiesClient.Execute` + +```go +ctx := context.TODO() +id := locationbasedcapabilities.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.Execute(ctx, id)` can be used to do batched pagination +items, err := client.ExecuteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/client.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/client.go new file mode 100644 index 00000000000..e54b57a554b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/client.go @@ -0,0 +1,26 @@ +package locationbasedcapabilities + +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 LocationBasedCapabilitiesClient struct { + Client *resourcemanager.Client +} + +func NewLocationBasedCapabilitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*LocationBasedCapabilitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "locationbasedcapabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocationBasedCapabilitiesClient: %+v", err) + } + + return &LocationBasedCapabilitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/constants.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/constants.go new file mode 100644 index 00000000000..3449d670fe8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/constants.go @@ -0,0 +1,385 @@ +package locationbasedcapabilities + +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 CapabilityStatus string + +const ( + CapabilityStatusAvailable CapabilityStatus = "Available" + CapabilityStatusDefault CapabilityStatus = "Default" + CapabilityStatusDisabled CapabilityStatus = "Disabled" + CapabilityStatusVisible CapabilityStatus = "Visible" +) + +func PossibleValuesForCapabilityStatus() []string { + return []string{ + string(CapabilityStatusAvailable), + string(CapabilityStatusDefault), + string(CapabilityStatusDisabled), + string(CapabilityStatusVisible), + } +} + +func (s *CapabilityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapabilityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCapabilityStatus(input string) (*CapabilityStatus, error) { + vals := map[string]CapabilityStatus{ + "available": CapabilityStatusAvailable, + "default": CapabilityStatusDefault, + "disabled": CapabilityStatusDisabled, + "visible": CapabilityStatusVisible, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CapabilityStatus(input) + return &out, nil +} + +type FastProvisioningSupportedEnum string + +const ( + FastProvisioningSupportedEnumDisabled FastProvisioningSupportedEnum = "Disabled" + FastProvisioningSupportedEnumEnabled FastProvisioningSupportedEnum = "Enabled" +) + +func PossibleValuesForFastProvisioningSupportedEnum() []string { + return []string{ + string(FastProvisioningSupportedEnumDisabled), + string(FastProvisioningSupportedEnumEnabled), + } +} + +func (s *FastProvisioningSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFastProvisioningSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFastProvisioningSupportedEnum(input string) (*FastProvisioningSupportedEnum, error) { + vals := map[string]FastProvisioningSupportedEnum{ + "disabled": FastProvisioningSupportedEnumDisabled, + "enabled": FastProvisioningSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FastProvisioningSupportedEnum(input) + return &out, nil +} + +type GeoBackupSupportedEnum string + +const ( + GeoBackupSupportedEnumDisabled GeoBackupSupportedEnum = "Disabled" + GeoBackupSupportedEnumEnabled GeoBackupSupportedEnum = "Enabled" +) + +func PossibleValuesForGeoBackupSupportedEnum() []string { + return []string{ + string(GeoBackupSupportedEnumDisabled), + string(GeoBackupSupportedEnumEnabled), + } +} + +func (s *GeoBackupSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoBackupSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeoBackupSupportedEnum(input string) (*GeoBackupSupportedEnum, error) { + vals := map[string]GeoBackupSupportedEnum{ + "disabled": GeoBackupSupportedEnumDisabled, + "enabled": GeoBackupSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GeoBackupSupportedEnum(input) + return &out, nil +} + +type HaMode string + +const ( + HaModeSameZone HaMode = "SameZone" + HaModeZoneRedundant HaMode = "ZoneRedundant" +) + +func PossibleValuesForHaMode() []string { + return []string{ + string(HaModeSameZone), + string(HaModeZoneRedundant), + } +} + +func (s *HaMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHaMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHaMode(input string) (*HaMode, error) { + vals := map[string]HaMode{ + "samezone": HaModeSameZone, + "zoneredundant": HaModeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HaMode(input) + return &out, nil +} + +type OnlineResizeSupportedEnum string + +const ( + OnlineResizeSupportedEnumDisabled OnlineResizeSupportedEnum = "Disabled" + OnlineResizeSupportedEnumEnabled OnlineResizeSupportedEnum = "Enabled" +) + +func PossibleValuesForOnlineResizeSupportedEnum() []string { + return []string{ + string(OnlineResizeSupportedEnumDisabled), + string(OnlineResizeSupportedEnumEnabled), + } +} + +func (s *OnlineResizeSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOnlineResizeSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOnlineResizeSupportedEnum(input string) (*OnlineResizeSupportedEnum, error) { + vals := map[string]OnlineResizeSupportedEnum{ + "disabled": OnlineResizeSupportedEnumDisabled, + "enabled": OnlineResizeSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OnlineResizeSupportedEnum(input) + return &out, nil +} + +type RestrictedEnum string + +const ( + RestrictedEnumDisabled RestrictedEnum = "Disabled" + RestrictedEnumEnabled RestrictedEnum = "Enabled" +) + +func PossibleValuesForRestrictedEnum() []string { + return []string{ + string(RestrictedEnumDisabled), + string(RestrictedEnumEnabled), + } +} + +func (s *RestrictedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestrictedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestrictedEnum(input string) (*RestrictedEnum, error) { + vals := map[string]RestrictedEnum{ + "disabled": RestrictedEnumDisabled, + "enabled": RestrictedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestrictedEnum(input) + return &out, nil +} + +type StorageAutoGrowthSupportedEnum string + +const ( + StorageAutoGrowthSupportedEnumDisabled StorageAutoGrowthSupportedEnum = "Disabled" + StorageAutoGrowthSupportedEnumEnabled StorageAutoGrowthSupportedEnum = "Enabled" +) + +func PossibleValuesForStorageAutoGrowthSupportedEnum() []string { + return []string{ + string(StorageAutoGrowthSupportedEnumDisabled), + string(StorageAutoGrowthSupportedEnumEnabled), + } +} + +func (s *StorageAutoGrowthSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAutoGrowthSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAutoGrowthSupportedEnum(input string) (*StorageAutoGrowthSupportedEnum, error) { + vals := map[string]StorageAutoGrowthSupportedEnum{ + "disabled": StorageAutoGrowthSupportedEnumDisabled, + "enabled": StorageAutoGrowthSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAutoGrowthSupportedEnum(input) + return &out, nil +} + +type ZoneRedundantHaAndGeoBackupSupportedEnum string + +const ( + ZoneRedundantHaAndGeoBackupSupportedEnumDisabled ZoneRedundantHaAndGeoBackupSupportedEnum = "Disabled" + ZoneRedundantHaAndGeoBackupSupportedEnumEnabled ZoneRedundantHaAndGeoBackupSupportedEnum = "Enabled" +) + +func PossibleValuesForZoneRedundantHaAndGeoBackupSupportedEnum() []string { + return []string{ + string(ZoneRedundantHaAndGeoBackupSupportedEnumDisabled), + string(ZoneRedundantHaAndGeoBackupSupportedEnumEnabled), + } +} + +func (s *ZoneRedundantHaAndGeoBackupSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneRedundantHaAndGeoBackupSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneRedundantHaAndGeoBackupSupportedEnum(input string) (*ZoneRedundantHaAndGeoBackupSupportedEnum, error) { + vals := map[string]ZoneRedundantHaAndGeoBackupSupportedEnum{ + "disabled": ZoneRedundantHaAndGeoBackupSupportedEnumDisabled, + "enabled": ZoneRedundantHaAndGeoBackupSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneRedundantHaAndGeoBackupSupportedEnum(input) + return &out, nil +} + +type ZoneRedundantHaSupportedEnum string + +const ( + ZoneRedundantHaSupportedEnumDisabled ZoneRedundantHaSupportedEnum = "Disabled" + ZoneRedundantHaSupportedEnumEnabled ZoneRedundantHaSupportedEnum = "Enabled" +) + +func PossibleValuesForZoneRedundantHaSupportedEnum() []string { + return []string{ + string(ZoneRedundantHaSupportedEnumDisabled), + string(ZoneRedundantHaSupportedEnumEnabled), + } +} + +func (s *ZoneRedundantHaSupportedEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneRedundantHaSupportedEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneRedundantHaSupportedEnum(input string) (*ZoneRedundantHaSupportedEnum, error) { + vals := map[string]ZoneRedundantHaSupportedEnum{ + "disabled": ZoneRedundantHaSupportedEnumDisabled, + "enabled": ZoneRedundantHaSupportedEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneRedundantHaSupportedEnum(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location.go new file mode 100644 index 00000000000..ed48613c9f1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location.go @@ -0,0 +1,121 @@ +package locationbasedcapabilities + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DBforPostgreSQL/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location_test.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location_test.go new file mode 100644 index 00000000000..edbec85b2cc --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/id_location_test.go @@ -0,0 +1,237 @@ +package locationbasedcapabilities + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DBforPostgreSQL/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/postgresql/2024-08-01/locationbasedcapabilities/method_execute.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/method_execute.go new file mode 100644 index 00000000000..1656228d279 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/method_execute.go @@ -0,0 +1,105 @@ +package locationbasedcapabilities + +import ( + "context" + "fmt" + "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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FlexibleServerCapability +} + +type ExecuteCompleteResult struct { + LatestHttpResponse *http.Response + Items []FlexibleServerCapability +} + +type ExecuteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExecuteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Execute ... +func (c LocationBasedCapabilitiesClient) Execute(ctx context.Context, id LocationId) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ExecuteCustomPager{}, + Path: fmt.Sprintf("%s/capabilities", 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 *[]FlexibleServerCapability `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ExecuteComplete retrieves all the results into a single object +func (c LocationBasedCapabilitiesClient) ExecuteComplete(ctx context.Context, id LocationId) (ExecuteCompleteResult, error) { + return c.ExecuteCompleteMatchingPredicate(ctx, id, FlexibleServerCapabilityOperationPredicate{}) +} + +// ExecuteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationBasedCapabilitiesClient) ExecuteCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate FlexibleServerCapabilityOperationPredicate) (result ExecuteCompleteResult, err error) { + items := make([]FlexibleServerCapability, 0) + + resp, err := c.Execute(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ExecuteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_fastprovisioningeditioncapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_fastprovisioningeditioncapability.go new file mode 100644 index 00000000000..adb129b53d5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_fastprovisioningeditioncapability.go @@ -0,0 +1,14 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FastProvisioningEditionCapability struct { + Reason *string `json:"reason,omitempty"` + ServerCount *int64 `json:"serverCount,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedServerVersions *string `json:"supportedServerVersions,omitempty"` + SupportedSku *string `json:"supportedSku,omitempty"` + SupportedStorageGb *int64 `json:"supportedStorageGb,omitempty"` + SupportedTier *string `json:"supportedTier,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservercapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservercapability.go new file mode 100644 index 00000000000..3df2abbd49e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservercapability.go @@ -0,0 +1,20 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerCapability struct { + FastProvisioningSupported *FastProvisioningSupportedEnum `json:"fastProvisioningSupported,omitempty"` + GeoBackupSupported *GeoBackupSupportedEnum `json:"geoBackupSupported,omitempty"` + Name *string `json:"name,omitempty"` + OnlineResizeSupported *OnlineResizeSupportedEnum `json:"onlineResizeSupported,omitempty"` + Reason *string `json:"reason,omitempty"` + Restricted *RestrictedEnum `json:"restricted,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + StorageAutoGrowthSupported *StorageAutoGrowthSupportedEnum `json:"storageAutoGrowthSupported,omitempty"` + SupportedFastProvisioningEditions *[]FastProvisioningEditionCapability `json:"supportedFastProvisioningEditions,omitempty"` + SupportedServerEditions *[]FlexibleServerEditionCapability `json:"supportedServerEditions,omitempty"` + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + ZoneRedundantHaAndGeoBackupSupported *ZoneRedundantHaAndGeoBackupSupportedEnum `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"` + ZoneRedundantHaSupported *ZoneRedundantHaSupportedEnum `json:"zoneRedundantHaSupported,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservereditioncapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservereditioncapability.go new file mode 100644 index 00000000000..d27604fa0df --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_flexibleservereditioncapability.go @@ -0,0 +1,13 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerEditionCapability struct { + DefaultSkuName *string `json:"defaultSkuName,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedServerSkus *[]ServerSkuCapability `json:"supportedServerSkus,omitempty"` + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverskucapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverskucapability.go new file mode 100644 index 00000000000..da155513f4a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverskucapability.go @@ -0,0 +1,15 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerSkuCapability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedHaMode *[]HaMode `json:"supportedHaMode,omitempty"` + SupportedIops *int64 `json:"supportedIops,omitempty"` + SupportedMemoryPerVcoreMb *int64 `json:"supportedMemoryPerVcoreMb,omitempty"` + SupportedZones *[]string `json:"supportedZones,omitempty"` + VCores *int64 `json:"vCores,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverversioncapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverversioncapability.go new file mode 100644 index 00000000000..7bdc157ffab --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_serverversioncapability.go @@ -0,0 +1,11 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerVersionCapability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedVersionsToUpgrade *[]string `json:"supportedVersionsToUpgrade,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storageeditioncapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storageeditioncapability.go new file mode 100644 index 00000000000..9234a031f24 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storageeditioncapability.go @@ -0,0 +1,12 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageEditionCapability struct { + DefaultStorageSizeMb *int64 `json:"defaultStorageSizeMb,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + SupportedStorageMb *[]StorageMbCapability `json:"supportedStorageMb,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagembcapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagembcapability.go new file mode 100644 index 00000000000..0c266a2f5eb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagembcapability.go @@ -0,0 +1,17 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMbCapability struct { + DefaultIopsTier *string `json:"defaultIopsTier,omitempty"` + MaximumStorageSizeMb *int64 `json:"maximumStorageSizeMb,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` + StorageSizeMb *int64 `json:"storageSizeMb,omitempty"` + SupportedIops *int64 `json:"supportedIops,omitempty"` + SupportedIopsTiers *[]StorageTierCapability `json:"supportedIopsTiers,omitempty"` + SupportedMaximumIops *int64 `json:"supportedMaximumIops,omitempty"` + SupportedMaximumThroughput *int64 `json:"supportedMaximumThroughput,omitempty"` + SupportedThroughput *int64 `json:"supportedThroughput,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagetiercapability.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagetiercapability.go new file mode 100644 index 00000000000..59865aae613 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/model_storagetiercapability.go @@ -0,0 +1,11 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTierCapability struct { + Iops *int64 `json:"iops,omitempty"` + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *CapabilityStatus `json:"status,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/predicates.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/predicates.go new file mode 100644 index 00000000000..d1ea2a3ec43 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/predicates.go @@ -0,0 +1,22 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlexibleServerCapabilityOperationPredicate struct { + Name *string + Reason *string +} + +func (p FlexibleServerCapabilityOperationPredicate) Matches(input FlexibleServerCapability) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Reason != nil && (input.Reason == nil || *p.Reason != *input.Reason) { + return false + } + + return true +} diff --git a/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/version.go b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/version.go new file mode 100644 index 00000000000..83c6bdbe468 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/locationbasedcapabilities/version.go @@ -0,0 +1,10 @@ +package locationbasedcapabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/locationbasedcapabilities/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/README.md b/resource-manager/postgresql/2024-08-01/logfiles/README.md new file mode 100644 index 00000000000..ea6adcc90fe --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/logfiles` Documentation + +The `logfiles` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/logfiles" +``` + + +### Client Initialization + +```go +client := logfiles.NewLogFilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LogFilesClient.ListByServer` + +```go +ctx := context.TODO() +id := logfiles.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/logfiles/client.go b/resource-manager/postgresql/2024-08-01/logfiles/client.go new file mode 100644 index 00000000000..7c634ed9989 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/client.go @@ -0,0 +1,26 @@ +package logfiles + +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 LogFilesClient struct { + Client *resourcemanager.Client +} + +func NewLogFilesClientWithBaseURI(sdkApi sdkEnv.Api) (*LogFilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "logfiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LogFilesClient: %+v", err) + } + + return &LogFilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver.go new file mode 100644 index 00000000000..57ff27d0228 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver.go @@ -0,0 +1,130 @@ +package logfiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver_test.go new file mode 100644 index 00000000000..7fa4cffbb5b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package logfiles + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/logfiles/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/logfiles/method_listbyserver.go new file mode 100644 index 00000000000..8b163e0f91f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/method_listbyserver.go @@ -0,0 +1,105 @@ +package logfiles + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogFile +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogFile +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c LogFilesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/logFiles", 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 *[]LogFile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c LogFilesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, LogFileOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LogFilesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LogFileOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]LogFile, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/model_logfile.go b/resource-manager/postgresql/2024-08-01/logfiles/model_logfile.go new file mode 100644 index 00000000000..238e512289b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/model_logfile.go @@ -0,0 +1,16 @@ +package logfiles + +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 LogFile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogFileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/model_logfileproperties.go b/resource-manager/postgresql/2024-08-01/logfiles/model_logfileproperties.go new file mode 100644 index 00000000000..a292541e505 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/model_logfileproperties.go @@ -0,0 +1,42 @@ +package logfiles + +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 LogFileProperties struct { + CreatedTime *string `json:"createdTime,omitempty"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + SizeInKb *int64 `json:"sizeInKb,omitempty"` + Type *string `json:"type,omitempty"` + Url *string `json:"url,omitempty"` +} + +func (o *LogFileProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogFileProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *LogFileProperties) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *LogFileProperties) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/logfiles/predicates.go b/resource-manager/postgresql/2024-08-01/logfiles/predicates.go new file mode 100644 index 00000000000..3b4f9690c5d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/predicates.go @@ -0,0 +1,27 @@ +package logfiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogFileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LogFileOperationPredicate) Matches(input LogFile) 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/postgresql/2024-08-01/logfiles/version.go b/resource-manager/postgresql/2024-08-01/logfiles/version.go new file mode 100644 index 00000000000..f0a699a0452 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/logfiles/version.go @@ -0,0 +1,10 @@ +package logfiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/logfiles/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/README.md b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/README.md new file mode 100644 index 00000000000..49ce421d80b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/README.md @@ -0,0 +1,91 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/longtermretentionbackup` Documentation + +The `longtermretentionbackup` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/longtermretentionbackup" +``` + + +### Client Initialization + +```go +client := longtermretentionbackup.NewLongTermRetentionBackupClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LongTermRetentionBackupClient.FlexibleServerStartLtrBackup` + +```go +ctx := context.TODO() +id := longtermretentionbackup.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := longtermretentionbackup.LtrBackupRequest{ + // ... +} + + +if err := client.FlexibleServerStartLtrBackupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LongTermRetentionBackupClient.FlexibleServerTriggerLtrPreBackup` + +```go +ctx := context.TODO() +id := longtermretentionbackup.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := longtermretentionbackup.BackupRequestBase{ + // ... +} + + +read, err := client.FlexibleServerTriggerLtrPreBackup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LongTermRetentionBackupClient.LtrBackupOperationsGet` + +```go +ctx := context.TODO() +id := longtermretentionbackup.NewLtrBackupOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "ltrBackupOperationName") + +read, err := client.LtrBackupOperationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LongTermRetentionBackupClient.LtrBackupOperationsListByServer` + +```go +ctx := context.TODO() +id := longtermretentionbackup.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.LtrBackupOperationsListByServer(ctx, id)` can be used to do batched pagination +items, err := client.LtrBackupOperationsListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/client.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/client.go new file mode 100644 index 00000000000..bf19f5b7308 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/client.go @@ -0,0 +1,26 @@ +package longtermretentionbackup + +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 LongTermRetentionBackupClient struct { + Client *resourcemanager.Client +} + +func NewLongTermRetentionBackupClientWithBaseURI(sdkApi sdkEnv.Api) (*LongTermRetentionBackupClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "longtermretentionbackup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LongTermRetentionBackupClient: %+v", err) + } + + return &LongTermRetentionBackupClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/constants.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/constants.go new file mode 100644 index 00000000000..02cbe837360 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/constants.go @@ -0,0 +1,57 @@ +package longtermretentionbackup + +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 ExecutionStatus string + +const ( + ExecutionStatusCancelled ExecutionStatus = "Cancelled" + ExecutionStatusFailed ExecutionStatus = "Failed" + ExecutionStatusRunning ExecutionStatus = "Running" + ExecutionStatusSucceeded ExecutionStatus = "Succeeded" +) + +func PossibleValuesForExecutionStatus() []string { + return []string{ + string(ExecutionStatusCancelled), + string(ExecutionStatusFailed), + string(ExecutionStatusRunning), + string(ExecutionStatusSucceeded), + } +} + +func (s *ExecutionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExecutionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExecutionStatus(input string) (*ExecutionStatus, error) { + vals := map[string]ExecutionStatus{ + "cancelled": ExecutionStatusCancelled, + "failed": ExecutionStatusFailed, + "running": ExecutionStatusRunning, + "succeeded": ExecutionStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExecutionStatus(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver.go new file mode 100644 index 00000000000..d61c171dbdc --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver.go @@ -0,0 +1,130 @@ +package longtermretentionbackup + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver_test.go new file mode 100644 index 00000000000..dbdce1992fd --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package longtermretentionbackup + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation.go new file mode 100644 index 00000000000..6baac089c9f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation.go @@ -0,0 +1,139 @@ +package longtermretentionbackup + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LtrBackupOperationId{}) +} + +var _ resourceids.ResourceId = &LtrBackupOperationId{} + +// LtrBackupOperationId is a struct representing the Resource ID for a Ltr Backup Operation +type LtrBackupOperationId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + LtrBackupOperationName string +} + +// NewLtrBackupOperationID returns a new LtrBackupOperationId struct +func NewLtrBackupOperationID(subscriptionId string, resourceGroupName string, flexibleServerName string, ltrBackupOperationName string) LtrBackupOperationId { + return LtrBackupOperationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + LtrBackupOperationName: ltrBackupOperationName, + } +} + +// ParseLtrBackupOperationID parses 'input' into a LtrBackupOperationId +func ParseLtrBackupOperationID(input string) (*LtrBackupOperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LtrBackupOperationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LtrBackupOperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLtrBackupOperationIDInsensitively parses 'input' case-insensitively into a LtrBackupOperationId +// note: this method should only be used for API response data and not user input +func ParseLtrBackupOperationIDInsensitively(input string) (*LtrBackupOperationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LtrBackupOperationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LtrBackupOperationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LtrBackupOperationId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.LtrBackupOperationName, ok = input.Parsed["ltrBackupOperationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ltrBackupOperationName", input) + } + + return nil +} + +// ValidateLtrBackupOperationID checks that 'input' can be parsed as a Ltr Backup Operation ID +func ValidateLtrBackupOperationID(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 := ParseLtrBackupOperationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Ltr Backup Operation ID +func (id LtrBackupOperationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/ltrBackupOperations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.LtrBackupOperationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Ltr Backup Operation ID +func (id LtrBackupOperationId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticLtrBackupOperations", "ltrBackupOperations", "ltrBackupOperations"), + resourceids.UserSpecifiedSegment("ltrBackupOperationName", "ltrBackupOperationName"), + } +} + +// String returns a human-readable description of this Ltr Backup Operation ID +func (id LtrBackupOperationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Ltr Backup Operation Name: %q", id.LtrBackupOperationName), + } + return fmt.Sprintf("Ltr Backup Operation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation_test.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation_test.go new file mode 100644 index 00000000000..0a1a72cb23f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/id_ltrbackupoperation_test.go @@ -0,0 +1,327 @@ +package longtermretentionbackup + +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 = &LtrBackupOperationId{} + +func TestNewLtrBackupOperationID(t *testing.T) { + id := NewLtrBackupOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "ltrBackupOperationName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.LtrBackupOperationName != "ltrBackupOperationName" { + t.Fatalf("Expected %q but got %q for Segment 'LtrBackupOperationName'", id.LtrBackupOperationName, "ltrBackupOperationName") + } +} + +func TestFormatLtrBackupOperationID(t *testing.T) { + actual := NewLtrBackupOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "ltrBackupOperationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations/ltrBackupOperationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLtrBackupOperationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LtrBackupOperationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations/ltrBackupOperationName", + Expected: &LtrBackupOperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + LtrBackupOperationName: "ltrBackupOperationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations/ltrBackupOperationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLtrBackupOperationID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.LtrBackupOperationName != v.Expected.LtrBackupOperationName { + t.Fatalf("Expected %q but got %q for LtrBackupOperationName", v.Expected.LtrBackupOperationName, actual.LtrBackupOperationName) + } + + } +} + +func TestParseLtrBackupOperationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LtrBackupOperationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/lTrBaCkUpOpErAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations/ltrBackupOperationName", + Expected: &LtrBackupOperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + LtrBackupOperationName: "ltrBackupOperationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/ltrBackupOperations/ltrBackupOperationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/lTrBaCkUpOpErAtIoNs/lTrBaCkUpOpErAtIoNnAmE", + Expected: &LtrBackupOperationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + LtrBackupOperationName: "lTrBaCkUpOpErAtIoNnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/lTrBaCkUpOpErAtIoNs/lTrBaCkUpOpErAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLtrBackupOperationIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.LtrBackupOperationName != v.Expected.LtrBackupOperationName { + t.Fatalf("Expected %q but got %q for LtrBackupOperationName", v.Expected.LtrBackupOperationName, actual.LtrBackupOperationName) + } + + } +} + +func TestSegmentsForLtrBackupOperationId(t *testing.T) { + segments := LtrBackupOperationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LtrBackupOperationId 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/postgresql/2024-08-01/longtermretentionbackup/method_flexibleserverstartltrbackup.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_flexibleserverstartltrbackup.go new file mode 100644 index 00000000000..3864982e2ca --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_flexibleserverstartltrbackup.go @@ -0,0 +1,75 @@ +package longtermretentionbackup + +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 FlexibleServerStartLtrBackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *LtrBackupResponse +} + +// FlexibleServerStartLtrBackup ... +func (c LongTermRetentionBackupClient) FlexibleServerStartLtrBackup(ctx context.Context, id FlexibleServerId, input LtrBackupRequest) (result FlexibleServerStartLtrBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startLtrBackup", 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 +} + +// FlexibleServerStartLtrBackupThenPoll performs FlexibleServerStartLtrBackup then polls until it's completed +func (c LongTermRetentionBackupClient) FlexibleServerStartLtrBackupThenPoll(ctx context.Context, id FlexibleServerId, input LtrBackupRequest) error { + result, err := c.FlexibleServerStartLtrBackup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing FlexibleServerStartLtrBackup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FlexibleServerStartLtrBackup: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_flexibleservertriggerltrprebackup.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_flexibleservertriggerltrprebackup.go new file mode 100644 index 00000000000..ebd4b9bc639 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_flexibleservertriggerltrprebackup.go @@ -0,0 +1,58 @@ +package longtermretentionbackup + +import ( + "context" + "fmt" + "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 FlexibleServerTriggerLtrPreBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LtrPreBackupResponse +} + +// FlexibleServerTriggerLtrPreBackup ... +func (c LongTermRetentionBackupClient) FlexibleServerTriggerLtrPreBackup(ctx context.Context, id FlexibleServerId, input BackupRequestBase) (result FlexibleServerTriggerLtrPreBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/ltrPreBackup", 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 + } + + var model LtrPreBackupResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationsget.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationsget.go new file mode 100644 index 00000000000..e517bb0a254 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationsget.go @@ -0,0 +1,53 @@ +package longtermretentionbackup + +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 LtrBackupOperationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LtrServerBackupOperation +} + +// LtrBackupOperationsGet ... +func (c LongTermRetentionBackupClient) LtrBackupOperationsGet(ctx context.Context, id LtrBackupOperationId) (result LtrBackupOperationsGetOperationResponse, 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 + } + + var model LtrServerBackupOperation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationslistbyserver.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationslistbyserver.go new file mode 100644 index 00000000000..f39994ccfc4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/method_ltrbackupoperationslistbyserver.go @@ -0,0 +1,105 @@ +package longtermretentionbackup + +import ( + "context" + "fmt" + "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 LtrBackupOperationsListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LtrServerBackupOperation +} + +type LtrBackupOperationsListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []LtrServerBackupOperation +} + +type LtrBackupOperationsListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LtrBackupOperationsListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LtrBackupOperationsListByServer ... +func (c LongTermRetentionBackupClient) LtrBackupOperationsListByServer(ctx context.Context, id FlexibleServerId) (result LtrBackupOperationsListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LtrBackupOperationsListByServerCustomPager{}, + Path: fmt.Sprintf("%s/ltrBackupOperations", 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 *[]LtrServerBackupOperation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LtrBackupOperationsListByServerComplete retrieves all the results into a single object +func (c LongTermRetentionBackupClient) LtrBackupOperationsListByServerComplete(ctx context.Context, id FlexibleServerId) (LtrBackupOperationsListByServerCompleteResult, error) { + return c.LtrBackupOperationsListByServerCompleteMatchingPredicate(ctx, id, LtrServerBackupOperationOperationPredicate{}) +} + +// LtrBackupOperationsListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LongTermRetentionBackupClient) LtrBackupOperationsListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LtrServerBackupOperationOperationPredicate) (result LtrBackupOperationsListByServerCompleteResult, err error) { + items := make([]LtrServerBackupOperation, 0) + + resp, err := c.LtrBackupOperationsListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = LtrBackupOperationsListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backuprequestbase.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backuprequestbase.go new file mode 100644 index 00000000000..314d3b74b35 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backuprequestbase.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequestBase struct { + BackupSettings BackupSettings `json:"backupSettings"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupsettings.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupsettings.go new file mode 100644 index 00000000000..fd8f00894b2 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupsettings.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupSettings struct { + BackupName string `json:"backupName"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupstoredetails.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupstoredetails.go new file mode 100644 index 00000000000..61b08e3f213 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_backupstoredetails.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStoreDetails struct { + SasUriList []string `json:"sasUriList"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupoperationresponseproperties.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupoperationresponseproperties.go new file mode 100644 index 00000000000..be096b6b8ea --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupoperationresponseproperties.go @@ -0,0 +1,44 @@ +package longtermretentionbackup + +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 LtrBackupOperationResponseProperties struct { + BackupMetadata *string `json:"backupMetadata,omitempty"` + BackupName *string `json:"backupName,omitempty"` + DataTransferredInBytes *int64 `json:"dataTransferredInBytes,omitempty"` + DatasourceSizeInBytes *int64 `json:"datasourceSizeInBytes,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + StartTime string `json:"startTime"` + Status ExecutionStatus `json:"status"` +} + +func (o *LtrBackupOperationResponseProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *LtrBackupOperationResponseProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *LtrBackupOperationResponseProperties) GetStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *LtrBackupOperationResponseProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = formatted +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackuprequest.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackuprequest.go new file mode 100644 index 00000000000..ee5346beb96 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackuprequest.go @@ -0,0 +1,9 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LtrBackupRequest struct { + BackupSettings BackupSettings `json:"backupSettings"` + TargetDetails BackupStoreDetails `json:"targetDetails"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupresponse.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupresponse.go new file mode 100644 index 00000000000..78330b476b5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrbackupresponse.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LtrBackupResponse struct { + Properties *LtrBackupOperationResponseProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponse.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponse.go new file mode 100644 index 00000000000..d3b93baf5a0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponse.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LtrPreBackupResponse struct { + Properties LtrPreBackupResponseProperties `json:"properties"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponseproperties.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponseproperties.go new file mode 100644 index 00000000000..8b6a29d9272 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrprebackupresponseproperties.go @@ -0,0 +1,8 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LtrPreBackupResponseProperties struct { + NumberOfContainers int64 `json:"numberOfContainers"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrserverbackupoperation.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrserverbackupoperation.go new file mode 100644 index 00000000000..4cb3939b2dc --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/model_ltrserverbackupoperation.go @@ -0,0 +1,16 @@ +package longtermretentionbackup + +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 LtrServerBackupOperation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LtrBackupOperationResponseProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/longtermretentionbackup/predicates.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/predicates.go new file mode 100644 index 00000000000..0ec6ab8e328 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/predicates.go @@ -0,0 +1,27 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LtrServerBackupOperationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LtrServerBackupOperationOperationPredicate) Matches(input LtrServerBackupOperation) 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/postgresql/2024-08-01/longtermretentionbackup/version.go b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/version.go new file mode 100644 index 00000000000..a7a172413e9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/longtermretentionbackup/version.go @@ -0,0 +1,10 @@ +package longtermretentionbackup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/longtermretentionbackup/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/README.md b/resource-manager/postgresql/2024-08-01/migrations/README.md new file mode 100644 index 00000000000..feb59a0da8f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/migrations` Documentation + +The `migrations` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/migrations" +``` + + +### Client Initialization + +```go +client := migrations.NewMigrationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MigrationsClient.Create` + +```go +ctx := context.TODO() +id := migrations.NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName") + +payload := migrations.MigrationResource{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MigrationsClient.Delete` + +```go +ctx := context.TODO() +id := migrations.NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MigrationsClient.Get` + +```go +ctx := context.TODO() +id := migrations.NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName") + +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: `MigrationsClient.ListByTargetServer` + +```go +ctx := context.TODO() +id := migrations.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByTargetServer(ctx, id, migrations.DefaultListByTargetServerOperationOptions())` can be used to do batched pagination +items, err := client.ListByTargetServerComplete(ctx, id, migrations.DefaultListByTargetServerOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MigrationsClient.Update` + +```go +ctx := context.TODO() +id := migrations.NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName") + +payload := migrations.MigrationResourceForPatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/postgresql/2024-08-01/migrations/client.go b/resource-manager/postgresql/2024-08-01/migrations/client.go new file mode 100644 index 00000000000..14d12bc07af --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/client.go @@ -0,0 +1,26 @@ +package migrations + +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 MigrationsClient struct { + Client *resourcemanager.Client +} + +func NewMigrationsClientWithBaseURI(sdkApi sdkEnv.Api) (*MigrationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "migrations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MigrationsClient: %+v", err) + } + + return &MigrationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/constants.go b/resource-manager/postgresql/2024-08-01/migrations/constants.go new file mode 100644 index 00000000000..414376345b1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/constants.go @@ -0,0 +1,768 @@ +package migrations + +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 CancelEnum string + +const ( + CancelEnumFalse CancelEnum = "False" + CancelEnumTrue CancelEnum = "True" +) + +func PossibleValuesForCancelEnum() []string { + return []string{ + string(CancelEnumFalse), + string(CancelEnumTrue), + } +} + +func (s *CancelEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCancelEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCancelEnum(input string) (*CancelEnum, error) { + vals := map[string]CancelEnum{ + "false": CancelEnumFalse, + "true": CancelEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CancelEnum(input) + return &out, nil +} + +type LogicalReplicationOnSourceDbEnum string + +const ( + LogicalReplicationOnSourceDbEnumFalse LogicalReplicationOnSourceDbEnum = "False" + LogicalReplicationOnSourceDbEnumTrue LogicalReplicationOnSourceDbEnum = "True" +) + +func PossibleValuesForLogicalReplicationOnSourceDbEnum() []string { + return []string{ + string(LogicalReplicationOnSourceDbEnumFalse), + string(LogicalReplicationOnSourceDbEnumTrue), + } +} + +func (s *LogicalReplicationOnSourceDbEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogicalReplicationOnSourceDbEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogicalReplicationOnSourceDbEnum(input string) (*LogicalReplicationOnSourceDbEnum, error) { + vals := map[string]LogicalReplicationOnSourceDbEnum{ + "false": LogicalReplicationOnSourceDbEnumFalse, + "true": LogicalReplicationOnSourceDbEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogicalReplicationOnSourceDbEnum(input) + return &out, nil +} + +type MigrateRolesEnum string + +const ( + MigrateRolesEnumFalse MigrateRolesEnum = "False" + MigrateRolesEnumTrue MigrateRolesEnum = "True" +) + +func PossibleValuesForMigrateRolesEnum() []string { + return []string{ + string(MigrateRolesEnumFalse), + string(MigrateRolesEnumTrue), + } +} + +func (s *MigrateRolesEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrateRolesEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrateRolesEnum(input string) (*MigrateRolesEnum, error) { + vals := map[string]MigrateRolesEnum{ + "false": MigrateRolesEnumFalse, + "true": MigrateRolesEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrateRolesEnum(input) + return &out, nil +} + +type MigrationDbState string + +const ( + MigrationDbStateCanceled MigrationDbState = "Canceled" + MigrationDbStateCanceling MigrationDbState = "Canceling" + MigrationDbStateFailed MigrationDbState = "Failed" + MigrationDbStateInProgress MigrationDbState = "InProgress" + MigrationDbStateSucceeded MigrationDbState = "Succeeded" + MigrationDbStateWaitingForCutoverTrigger MigrationDbState = "WaitingForCutoverTrigger" +) + +func PossibleValuesForMigrationDbState() []string { + return []string{ + string(MigrationDbStateCanceled), + string(MigrationDbStateCanceling), + string(MigrationDbStateFailed), + string(MigrationDbStateInProgress), + string(MigrationDbStateSucceeded), + string(MigrationDbStateWaitingForCutoverTrigger), + } +} + +func (s *MigrationDbState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationDbState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationDbState(input string) (*MigrationDbState, error) { + vals := map[string]MigrationDbState{ + "canceled": MigrationDbStateCanceled, + "canceling": MigrationDbStateCanceling, + "failed": MigrationDbStateFailed, + "inprogress": MigrationDbStateInProgress, + "succeeded": MigrationDbStateSucceeded, + "waitingforcutovertrigger": MigrationDbStateWaitingForCutoverTrigger, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationDbState(input) + return &out, nil +} + +type MigrationListFilter string + +const ( + MigrationListFilterActive MigrationListFilter = "Active" + MigrationListFilterAll MigrationListFilter = "All" +) + +func PossibleValuesForMigrationListFilter() []string { + return []string{ + string(MigrationListFilterActive), + string(MigrationListFilterAll), + } +} + +func (s *MigrationListFilter) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationListFilter(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationListFilter(input string) (*MigrationListFilter, error) { + vals := map[string]MigrationListFilter{ + "active": MigrationListFilterActive, + "all": MigrationListFilterAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationListFilter(input) + return &out, nil +} + +type MigrationMode string + +const ( + MigrationModeOffline MigrationMode = "Offline" + MigrationModeOnline MigrationMode = "Online" +) + +func PossibleValuesForMigrationMode() []string { + return []string{ + string(MigrationModeOffline), + string(MigrationModeOnline), + } +} + +func (s *MigrationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationMode(input string) (*MigrationMode, error) { + vals := map[string]MigrationMode{ + "offline": MigrationModeOffline, + "online": MigrationModeOnline, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationMode(input) + return &out, nil +} + +type MigrationOption string + +const ( + MigrationOptionMigrate MigrationOption = "Migrate" + MigrationOptionValidate MigrationOption = "Validate" + MigrationOptionValidateAndMigrate MigrationOption = "ValidateAndMigrate" +) + +func PossibleValuesForMigrationOption() []string { + return []string{ + string(MigrationOptionMigrate), + string(MigrationOptionValidate), + string(MigrationOptionValidateAndMigrate), + } +} + +func (s *MigrationOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationOption(input string) (*MigrationOption, error) { + vals := map[string]MigrationOption{ + "migrate": MigrationOptionMigrate, + "validate": MigrationOptionValidate, + "validateandmigrate": MigrationOptionValidateAndMigrate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationOption(input) + return &out, nil +} + +type MigrationState string + +const ( + MigrationStateCanceled MigrationState = "Canceled" + MigrationStateCleaningUp MigrationState = "CleaningUp" + MigrationStateFailed MigrationState = "Failed" + MigrationStateInProgress MigrationState = "InProgress" + MigrationStateSucceeded MigrationState = "Succeeded" + MigrationStateValidationFailed MigrationState = "ValidationFailed" + MigrationStateWaitingForUserAction MigrationState = "WaitingForUserAction" +) + +func PossibleValuesForMigrationState() []string { + return []string{ + string(MigrationStateCanceled), + string(MigrationStateCleaningUp), + string(MigrationStateFailed), + string(MigrationStateInProgress), + string(MigrationStateSucceeded), + string(MigrationStateValidationFailed), + string(MigrationStateWaitingForUserAction), + } +} + +func (s *MigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationState(input string) (*MigrationState, error) { + vals := map[string]MigrationState{ + "canceled": MigrationStateCanceled, + "cleaningup": MigrationStateCleaningUp, + "failed": MigrationStateFailed, + "inprogress": MigrationStateInProgress, + "succeeded": MigrationStateSucceeded, + "validationfailed": MigrationStateValidationFailed, + "waitingforuseraction": MigrationStateWaitingForUserAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationState(input) + return &out, nil +} + +type MigrationSubState string + +const ( + MigrationSubStateCancelingRequestedDBMigrations MigrationSubState = "CancelingRequestedDBMigrations" + MigrationSubStateCompleted MigrationSubState = "Completed" + MigrationSubStateCompletingMigration MigrationSubState = "CompletingMigration" + MigrationSubStateMigratingData MigrationSubState = "MigratingData" + MigrationSubStatePerformingPreRequisiteSteps MigrationSubState = "PerformingPreRequisiteSteps" + MigrationSubStateValidationInProgress MigrationSubState = "ValidationInProgress" + MigrationSubStateWaitingForCutoverTrigger MigrationSubState = "WaitingForCutoverTrigger" + MigrationSubStateWaitingForDBsToMigrateSpecification MigrationSubState = "WaitingForDBsToMigrateSpecification" + MigrationSubStateWaitingForDataMigrationScheduling MigrationSubState = "WaitingForDataMigrationScheduling" + MigrationSubStateWaitingForDataMigrationWindow MigrationSubState = "WaitingForDataMigrationWindow" + MigrationSubStateWaitingForLogicalReplicationSetupRequestOnSourceDB MigrationSubState = "WaitingForLogicalReplicationSetupRequestOnSourceDB" + MigrationSubStateWaitingForTargetDBOverwriteConfirmation MigrationSubState = "WaitingForTargetDBOverwriteConfirmation" +) + +func PossibleValuesForMigrationSubState() []string { + return []string{ + string(MigrationSubStateCancelingRequestedDBMigrations), + string(MigrationSubStateCompleted), + string(MigrationSubStateCompletingMigration), + string(MigrationSubStateMigratingData), + string(MigrationSubStatePerformingPreRequisiteSteps), + string(MigrationSubStateValidationInProgress), + string(MigrationSubStateWaitingForCutoverTrigger), + string(MigrationSubStateWaitingForDBsToMigrateSpecification), + string(MigrationSubStateWaitingForDataMigrationScheduling), + string(MigrationSubStateWaitingForDataMigrationWindow), + string(MigrationSubStateWaitingForLogicalReplicationSetupRequestOnSourceDB), + string(MigrationSubStateWaitingForTargetDBOverwriteConfirmation), + } +} + +func (s *MigrationSubState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationSubState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationSubState(input string) (*MigrationSubState, error) { + vals := map[string]MigrationSubState{ + "cancelingrequesteddbmigrations": MigrationSubStateCancelingRequestedDBMigrations, + "completed": MigrationSubStateCompleted, + "completingmigration": MigrationSubStateCompletingMigration, + "migratingdata": MigrationSubStateMigratingData, + "performingprerequisitesteps": MigrationSubStatePerformingPreRequisiteSteps, + "validationinprogress": MigrationSubStateValidationInProgress, + "waitingforcutovertrigger": MigrationSubStateWaitingForCutoverTrigger, + "waitingfordbstomigratespecification": MigrationSubStateWaitingForDBsToMigrateSpecification, + "waitingfordatamigrationscheduling": MigrationSubStateWaitingForDataMigrationScheduling, + "waitingfordatamigrationwindow": MigrationSubStateWaitingForDataMigrationWindow, + "waitingforlogicalreplicationsetuprequestonsourcedb": MigrationSubStateWaitingForLogicalReplicationSetupRequestOnSourceDB, + "waitingfortargetdboverwriteconfirmation": MigrationSubStateWaitingForTargetDBOverwriteConfirmation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationSubState(input) + return &out, nil +} + +type OverwriteDbsInTargetEnum string + +const ( + OverwriteDbsInTargetEnumFalse OverwriteDbsInTargetEnum = "False" + OverwriteDbsInTargetEnumTrue OverwriteDbsInTargetEnum = "True" +) + +func PossibleValuesForOverwriteDbsInTargetEnum() []string { + return []string{ + string(OverwriteDbsInTargetEnumFalse), + string(OverwriteDbsInTargetEnumTrue), + } +} + +func (s *OverwriteDbsInTargetEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOverwriteDbsInTargetEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOverwriteDbsInTargetEnum(input string) (*OverwriteDbsInTargetEnum, error) { + vals := map[string]OverwriteDbsInTargetEnum{ + "false": OverwriteDbsInTargetEnumFalse, + "true": OverwriteDbsInTargetEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteDbsInTargetEnum(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBurstable SkuTier = "Burstable" + SkuTierGeneralPurpose SkuTier = "GeneralPurpose" + SkuTierMemoryOptimized SkuTier = "MemoryOptimized" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBurstable), + string(SkuTierGeneralPurpose), + string(SkuTierMemoryOptimized), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "burstable": SkuTierBurstable, + "generalpurpose": SkuTierGeneralPurpose, + "memoryoptimized": SkuTierMemoryOptimized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type SourceType string + +const ( + SourceTypeAWS SourceType = "AWS" + SourceTypeAWSAURORA SourceType = "AWS_AURORA" + SourceTypeAWSECTwo SourceType = "AWS_EC2" + SourceTypeAWSRDS SourceType = "AWS_RDS" + SourceTypeAzureVM SourceType = "AzureVM" + SourceTypeEDB SourceType = "EDB" + SourceTypeGCP SourceType = "GCP" + SourceTypeGCPAlloyDB SourceType = "GCP_AlloyDB" + SourceTypeGCPCloudSQL SourceType = "GCP_CloudSQL" + SourceTypeGCPCompute SourceType = "GCP_Compute" + SourceTypeOnPremises SourceType = "OnPremises" + SourceTypePostgreSQLSingleServer SourceType = "PostgreSQLSingleServer" +) + +func PossibleValuesForSourceType() []string { + return []string{ + string(SourceTypeAWS), + string(SourceTypeAWSAURORA), + string(SourceTypeAWSECTwo), + string(SourceTypeAWSRDS), + string(SourceTypeAzureVM), + string(SourceTypeEDB), + string(SourceTypeGCP), + string(SourceTypeGCPAlloyDB), + string(SourceTypeGCPCloudSQL), + string(SourceTypeGCPCompute), + string(SourceTypeOnPremises), + string(SourceTypePostgreSQLSingleServer), + } +} + +func (s *SourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceType(input string) (*SourceType, error) { + vals := map[string]SourceType{ + "aws": SourceTypeAWS, + "aws_aurora": SourceTypeAWSAURORA, + "aws_ec2": SourceTypeAWSECTwo, + "aws_rds": SourceTypeAWSRDS, + "azurevm": SourceTypeAzureVM, + "edb": SourceTypeEDB, + "gcp": SourceTypeGCP, + "gcp_alloydb": SourceTypeGCPAlloyDB, + "gcp_cloudsql": SourceTypeGCPCloudSQL, + "gcp_compute": SourceTypeGCPCompute, + "onpremises": SourceTypeOnPremises, + "postgresqlsingleserver": SourceTypePostgreSQLSingleServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceType(input) + return &out, nil +} + +type SslMode string + +const ( + SslModePrefer SslMode = "Prefer" + SslModeRequire SslMode = "Require" + SslModeVerifyCA SslMode = "VerifyCA" + SslModeVerifyFull SslMode = "VerifyFull" +) + +func PossibleValuesForSslMode() []string { + return []string{ + string(SslModePrefer), + string(SslModeRequire), + string(SslModeVerifyCA), + string(SslModeVerifyFull), + } +} + +func (s *SslMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslMode(input string) (*SslMode, error) { + vals := map[string]SslMode{ + "prefer": SslModePrefer, + "require": SslModeRequire, + "verifyca": SslModeVerifyCA, + "verifyfull": SslModeVerifyFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslMode(input) + return &out, nil +} + +type StartDataMigrationEnum string + +const ( + StartDataMigrationEnumFalse StartDataMigrationEnum = "False" + StartDataMigrationEnumTrue StartDataMigrationEnum = "True" +) + +func PossibleValuesForStartDataMigrationEnum() []string { + return []string{ + string(StartDataMigrationEnumFalse), + string(StartDataMigrationEnumTrue), + } +} + +func (s *StartDataMigrationEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStartDataMigrationEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStartDataMigrationEnum(input string) (*StartDataMigrationEnum, error) { + vals := map[string]StartDataMigrationEnum{ + "false": StartDataMigrationEnumFalse, + "true": StartDataMigrationEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StartDataMigrationEnum(input) + return &out, nil +} + +type TriggerCutoverEnum string + +const ( + TriggerCutoverEnumFalse TriggerCutoverEnum = "False" + TriggerCutoverEnumTrue TriggerCutoverEnum = "True" +) + +func PossibleValuesForTriggerCutoverEnum() []string { + return []string{ + string(TriggerCutoverEnumFalse), + string(TriggerCutoverEnumTrue), + } +} + +func (s *TriggerCutoverEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerCutoverEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerCutoverEnum(input string) (*TriggerCutoverEnum, error) { + vals := map[string]TriggerCutoverEnum{ + "false": TriggerCutoverEnumFalse, + "true": TriggerCutoverEnumTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerCutoverEnum(input) + return &out, nil +} + +type ValidationState string + +const ( + ValidationStateFailed ValidationState = "Failed" + ValidationStateSucceeded ValidationState = "Succeeded" + ValidationStateWarning ValidationState = "Warning" +) + +func PossibleValuesForValidationState() []string { + return []string{ + string(ValidationStateFailed), + string(ValidationStateSucceeded), + string(ValidationStateWarning), + } +} + +func (s *ValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationState(input string) (*ValidationState, error) { + vals := map[string]ValidationState{ + "failed": ValidationStateFailed, + "succeeded": ValidationStateSucceeded, + "warning": ValidationStateWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationState(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver.go new file mode 100644 index 00000000000..097e3e77da6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver.go @@ -0,0 +1,130 @@ +package migrations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver_test.go new file mode 100644 index 00000000000..7d7bb3f84e0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package migrations + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/migrations/id_migration.go b/resource-manager/postgresql/2024-08-01/migrations/id_migration.go new file mode 100644 index 00000000000..af292b91145 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/id_migration.go @@ -0,0 +1,139 @@ +package migrations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&MigrationId{}) +} + +var _ resourceids.ResourceId = &MigrationId{} + +// MigrationId is a struct representing the Resource ID for a Migration +type MigrationId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + MigrationName string +} + +// NewMigrationID returns a new MigrationId struct +func NewMigrationID(subscriptionId string, resourceGroupName string, flexibleServerName string, migrationName string) MigrationId { + return MigrationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + MigrationName: migrationName, + } +} + +// ParseMigrationID parses 'input' into a MigrationId +func ParseMigrationID(input string) (*MigrationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMigrationIDInsensitively parses 'input' case-insensitively into a MigrationId +// note: this method should only be used for API response data and not user input +func ParseMigrationIDInsensitively(input string) (*MigrationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MigrationId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.MigrationName, ok = input.Parsed["migrationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "migrationName", input) + } + + return nil +} + +// ValidateMigrationID checks that 'input' can be parsed as a Migration ID +func ValidateMigrationID(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 := ParseMigrationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Migration ID +func (id MigrationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/migrations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.MigrationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Migration ID +func (id MigrationId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticMigrations", "migrations", "migrations"), + resourceids.UserSpecifiedSegment("migrationName", "migrationName"), + } +} + +// String returns a human-readable description of this Migration ID +func (id MigrationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Migration Name: %q", id.MigrationName), + } + return fmt.Sprintf("Migration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/id_migration_test.go b/resource-manager/postgresql/2024-08-01/migrations/id_migration_test.go new file mode 100644 index 00000000000..5d5db5b06e2 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/id_migration_test.go @@ -0,0 +1,327 @@ +package migrations + +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 = &MigrationId{} + +func TestNewMigrationID(t *testing.T) { + id := NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.MigrationName != "migrationName" { + t.Fatalf("Expected %q but got %q for Segment 'MigrationName'", id.MigrationName, "migrationName") + } +} + +func TestFormatMigrationID(t *testing.T) { + actual := NewMigrationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "migrationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations/migrationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMigrationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations/migrationName", + Expected: &MigrationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + MigrationName: "migrationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations/migrationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.MigrationName != v.Expected.MigrationName { + t.Fatalf("Expected %q but got %q for MigrationName", v.Expected.MigrationName, actual.MigrationName) + } + + } +} + +func TestParseMigrationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/mIgRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations/migrationName", + Expected: &MigrationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + MigrationName: "migrationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/migrations/migrationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/mIgRaTiOnS/mIgRaTiOnNaMe", + Expected: &MigrationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + MigrationName: "mIgRaTiOnNaMe", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/mIgRaTiOnS/mIgRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.MigrationName != v.Expected.MigrationName { + t.Fatalf("Expected %q but got %q for MigrationName", v.Expected.MigrationName, actual.MigrationName) + } + + } +} + +func TestSegmentsForMigrationId(t *testing.T) { + segments := MigrationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MigrationId 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/postgresql/2024-08-01/migrations/method_create.go b/resource-manager/postgresql/2024-08-01/migrations/method_create.go new file mode 100644 index 00000000000..6c3c6089dc5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/method_create.go @@ -0,0 +1,58 @@ +package migrations + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationResource +} + +// Create ... +func (c MigrationsClient) Create(ctx context.Context, id MigrationId, input MigrationResource) (result CreateOperationResponse, 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 + } + + var model MigrationResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/method_delete.go b/resource-manager/postgresql/2024-08-01/migrations/method_delete.go new file mode 100644 index 00000000000..31af80c7027 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/method_delete.go @@ -0,0 +1,47 @@ +package migrations + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MigrationsClient) Delete(ctx context.Context, id MigrationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/method_get.go b/resource-manager/postgresql/2024-08-01/migrations/method_get.go new file mode 100644 index 00000000000..30b1e434d7c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/method_get.go @@ -0,0 +1,53 @@ +package migrations + +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 *MigrationResource +} + +// Get ... +func (c MigrationsClient) Get(ctx context.Context, id MigrationId) (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 + } + + var model MigrationResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/method_listbytargetserver.go b/resource-manager/postgresql/2024-08-01/migrations/method_listbytargetserver.go new file mode 100644 index 00000000000..3f5c59ee040 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/method_listbytargetserver.go @@ -0,0 +1,134 @@ +package migrations + +import ( + "context" + "fmt" + "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 ListByTargetServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationResource +} + +type ListByTargetServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationResource +} + +type ListByTargetServerOperationOptions struct { + MigrationListFilter *MigrationListFilter +} + +func DefaultListByTargetServerOperationOptions() ListByTargetServerOperationOptions { + return ListByTargetServerOperationOptions{} +} + +func (o ListByTargetServerOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByTargetServerOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByTargetServerOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.MigrationListFilter != nil { + out.Append("migrationListFilter", fmt.Sprintf("%v", *o.MigrationListFilter)) + } + return &out +} + +type ListByTargetServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByTargetServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByTargetServer ... +func (c MigrationsClient) ListByTargetServer(ctx context.Context, id FlexibleServerId, options ListByTargetServerOperationOptions) (result ListByTargetServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByTargetServerCustomPager{}, + Path: fmt.Sprintf("%s/migrations", 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 *[]MigrationResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByTargetServerComplete retrieves all the results into a single object +func (c MigrationsClient) ListByTargetServerComplete(ctx context.Context, id FlexibleServerId, options ListByTargetServerOperationOptions) (ListByTargetServerCompleteResult, error) { + return c.ListByTargetServerCompleteMatchingPredicate(ctx, id, options, MigrationResourceOperationPredicate{}) +} + +// ListByTargetServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MigrationsClient) ListByTargetServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, options ListByTargetServerOperationOptions, predicate MigrationResourceOperationPredicate) (result ListByTargetServerCompleteResult, err error) { + items := make([]MigrationResource, 0) + + resp, err := c.ListByTargetServer(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByTargetServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/method_update.go b/resource-manager/postgresql/2024-08-01/migrations/method_update.go new file mode 100644 index 00000000000..4c05390ae10 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/method_update.go @@ -0,0 +1,57 @@ +package migrations + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationResource +} + +// Update ... +func (c MigrationsClient) Update(ctx context.Context, id MigrationId, input MigrationResourceForPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model MigrationResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_admincredentials.go b/resource-manager/postgresql/2024-08-01/migrations/model_admincredentials.go new file mode 100644 index 00000000000..5503ac453e3 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_admincredentials.go @@ -0,0 +1,9 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminCredentials struct { + SourceServerPassword string `json:"sourceServerPassword"` + TargetServerPassword string `json:"targetServerPassword"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_dblevelvalidationstatus.go b/resource-manager/postgresql/2024-08-01/migrations/model_dblevelvalidationstatus.go new file mode 100644 index 00000000000..775d8a6b20b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_dblevelvalidationstatus.go @@ -0,0 +1,41 @@ +package migrations + +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 DbLevelValidationStatus struct { + DatabaseName *string `json:"databaseName,omitempty"` + EndedOn *string `json:"endedOn,omitempty"` + StartedOn *string `json:"startedOn,omitempty"` + Summary *[]ValidationSummaryItem `json:"summary,omitempty"` +} + +func (o *DbLevelValidationStatus) GetEndedOnAsTime() (*time.Time, error) { + if o.EndedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbLevelValidationStatus) SetEndedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndedOn = &formatted +} + +func (o *DbLevelValidationStatus) GetStartedOnAsTime() (*time.Time, error) { + if o.StartedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbLevelValidationStatus) SetStartedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartedOn = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_dbmigrationstatus.go b/resource-manager/postgresql/2024-08-01/migrations/model_dbmigrationstatus.go new file mode 100644 index 00000000000..1e2551fc083 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_dbmigrationstatus.go @@ -0,0 +1,53 @@ +package migrations + +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 DbMigrationStatus struct { + AppliedChanges *int64 `json:"appliedChanges,omitempty"` + CdcDeleteCounter *int64 `json:"cdcDeleteCounter,omitempty"` + CdcInsertCounter *int64 `json:"cdcInsertCounter,omitempty"` + CdcUpdateCounter *int64 `json:"cdcUpdateCounter,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + EndedOn *string `json:"endedOn,omitempty"` + FullLoadCompletedTables *int64 `json:"fullLoadCompletedTables,omitempty"` + FullLoadErroredTables *int64 `json:"fullLoadErroredTables,omitempty"` + FullLoadLoadingTables *int64 `json:"fullLoadLoadingTables,omitempty"` + FullLoadQueuedTables *int64 `json:"fullLoadQueuedTables,omitempty"` + IncomingChanges *int64 `json:"incomingChanges,omitempty"` + Latency *int64 `json:"latency,omitempty"` + Message *string `json:"message,omitempty"` + MigrationOperation *string `json:"migrationOperation,omitempty"` + MigrationState *MigrationDbState `json:"migrationState,omitempty"` + StartedOn *string `json:"startedOn,omitempty"` +} + +func (o *DbMigrationStatus) GetEndedOnAsTime() (*time.Time, error) { + if o.EndedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbMigrationStatus) SetEndedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndedOn = &formatted +} + +func (o *DbMigrationStatus) GetStartedOnAsTime() (*time.Time, error) { + if o.StartedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbMigrationStatus) SetStartedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartedOn = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_dbservermetadata.go b/resource-manager/postgresql/2024-08-01/migrations/model_dbservermetadata.go new file mode 100644 index 00000000000..7ced3718133 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_dbservermetadata.go @@ -0,0 +1,11 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbServerMetadata struct { + Location *string `json:"location,omitempty"` + Sku *ServerSku `json:"sku,omitempty"` + StorageMb *int64 `json:"storageMb,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationresource.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresource.go new file mode 100644 index 00000000000..703a86638d8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresource.go @@ -0,0 +1,18 @@ +package migrations + +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 MigrationResource struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *MigrationResourceProperties `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/postgresql/2024-08-01/migrations/model_migrationresourceforpatch.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourceforpatch.go new file mode 100644 index 00000000000..68d8fbaa3fa --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourceforpatch.go @@ -0,0 +1,9 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationResourceForPatch struct { + Properties *MigrationResourcePropertiesForPatch `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourceproperties.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourceproperties.go new file mode 100644 index 00000000000..8665ef45db6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourceproperties.go @@ -0,0 +1,62 @@ +package migrations + +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 MigrationResourceProperties struct { + Cancel *CancelEnum `json:"cancel,omitempty"` + CurrentStatus *MigrationStatus `json:"currentStatus,omitempty"` + DbsToCancelMigrationOn *[]string `json:"dbsToCancelMigrationOn,omitempty"` + DbsToMigrate *[]string `json:"dbsToMigrate,omitempty"` + DbsToTriggerCutoverOn *[]string `json:"dbsToTriggerCutoverOn,omitempty"` + MigrateRoles *MigrateRolesEnum `json:"migrateRoles,omitempty"` + MigrationId *string `json:"migrationId,omitempty"` + MigrationInstanceResourceId *string `json:"migrationInstanceResourceId,omitempty"` + MigrationMode *MigrationMode `json:"migrationMode,omitempty"` + MigrationOption *MigrationOption `json:"migrationOption,omitempty"` + MigrationWindowEndTimeInUtc *string `json:"migrationWindowEndTimeInUtc,omitempty"` + MigrationWindowStartTimeInUtc *string `json:"migrationWindowStartTimeInUtc,omitempty"` + OverwriteDbsInTarget *OverwriteDbsInTargetEnum `json:"overwriteDbsInTarget,omitempty"` + SecretParameters *MigrationSecretParameters `json:"secretParameters,omitempty"` + SetupLogicalReplicationOnSourceDbIfNeeded *LogicalReplicationOnSourceDbEnum `json:"setupLogicalReplicationOnSourceDbIfNeeded,omitempty"` + SourceDbServerFullyQualifiedDomainName *string `json:"sourceDbServerFullyQualifiedDomainName,omitempty"` + SourceDbServerMetadata *DbServerMetadata `json:"sourceDbServerMetadata,omitempty"` + SourceDbServerResourceId *string `json:"sourceDbServerResourceId,omitempty"` + SourceType *SourceType `json:"sourceType,omitempty"` + SslMode *SslMode `json:"sslMode,omitempty"` + StartDataMigration *StartDataMigrationEnum `json:"startDataMigration,omitempty"` + TargetDbServerFullyQualifiedDomainName *string `json:"targetDbServerFullyQualifiedDomainName,omitempty"` + TargetDbServerMetadata *DbServerMetadata `json:"targetDbServerMetadata,omitempty"` + TargetDbServerResourceId *string `json:"targetDbServerResourceId,omitempty"` + TriggerCutover *TriggerCutoverEnum `json:"triggerCutover,omitempty"` +} + +func (o *MigrationResourceProperties) GetMigrationWindowEndTimeInUtcAsTime() (*time.Time, error) { + if o.MigrationWindowEndTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MigrationWindowEndTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationResourceProperties) SetMigrationWindowEndTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MigrationWindowEndTimeInUtc = &formatted +} + +func (o *MigrationResourceProperties) GetMigrationWindowStartTimeInUtcAsTime() (*time.Time, error) { + if o.MigrationWindowStartTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MigrationWindowStartTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationResourceProperties) SetMigrationWindowStartTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MigrationWindowStartTimeInUtc = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourcepropertiesforpatch.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourcepropertiesforpatch.go new file mode 100644 index 00000000000..5ceee18f945 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationresourcepropertiesforpatch.go @@ -0,0 +1,40 @@ +package migrations + +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 MigrationResourcePropertiesForPatch struct { + Cancel *CancelEnum `json:"cancel,omitempty"` + DbsToCancelMigrationOn *[]string `json:"dbsToCancelMigrationOn,omitempty"` + DbsToMigrate *[]string `json:"dbsToMigrate,omitempty"` + DbsToTriggerCutoverOn *[]string `json:"dbsToTriggerCutoverOn,omitempty"` + MigrateRoles *MigrateRolesEnum `json:"migrateRoles,omitempty"` + MigrationMode *MigrationMode `json:"migrationMode,omitempty"` + MigrationWindowStartTimeInUtc *string `json:"migrationWindowStartTimeInUtc,omitempty"` + OverwriteDbsInTarget *OverwriteDbsInTargetEnum `json:"overwriteDbsInTarget,omitempty"` + SecretParameters *MigrationSecretParameters `json:"secretParameters,omitempty"` + SetupLogicalReplicationOnSourceDbIfNeeded *LogicalReplicationOnSourceDbEnum `json:"setupLogicalReplicationOnSourceDbIfNeeded,omitempty"` + SourceDbServerFullyQualifiedDomainName *string `json:"sourceDbServerFullyQualifiedDomainName,omitempty"` + SourceDbServerResourceId *string `json:"sourceDbServerResourceId,omitempty"` + StartDataMigration *StartDataMigrationEnum `json:"startDataMigration,omitempty"` + TargetDbServerFullyQualifiedDomainName *string `json:"targetDbServerFullyQualifiedDomainName,omitempty"` + TriggerCutover *TriggerCutoverEnum `json:"triggerCutover,omitempty"` +} + +func (o *MigrationResourcePropertiesForPatch) GetMigrationWindowStartTimeInUtcAsTime() (*time.Time, error) { + if o.MigrationWindowStartTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MigrationWindowStartTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationResourcePropertiesForPatch) SetMigrationWindowStartTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MigrationWindowStartTimeInUtc = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationsecretparameters.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationsecretparameters.go new file mode 100644 index 00000000000..7192688f089 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationsecretparameters.go @@ -0,0 +1,10 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationSecretParameters struct { + AdminCredentials AdminCredentials `json:"adminCredentials"` + SourceServerUsername *string `json:"sourceServerUsername,omitempty"` + TargetServerUsername *string `json:"targetServerUsername,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationstatus.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationstatus.go new file mode 100644 index 00000000000..947355c9c57 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationstatus.go @@ -0,0 +1,10 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationStatus struct { + CurrentSubStateDetails *MigrationSubStateDetails `json:"currentSubStateDetails,omitempty"` + Error *string `json:"error,omitempty"` + State *MigrationState `json:"state,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_migrationsubstatedetails.go b/resource-manager/postgresql/2024-08-01/migrations/model_migrationsubstatedetails.go new file mode 100644 index 00000000000..a2513dc92af --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_migrationsubstatedetails.go @@ -0,0 +1,10 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationSubStateDetails struct { + CurrentSubState *MigrationSubState `json:"currentSubState,omitempty"` + DbDetails *map[string]DbMigrationStatus `json:"dbDetails,omitempty"` + ValidationDetails *ValidationDetails `json:"validationDetails,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_serversku.go b/resource-manager/postgresql/2024-08-01/migrations/model_serversku.go new file mode 100644 index 00000000000..34292acb667 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_serversku.go @@ -0,0 +1,9 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerSku struct { + Name *string `json:"name,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_validationdetails.go b/resource-manager/postgresql/2024-08-01/migrations/model_validationdetails.go new file mode 100644 index 00000000000..a8cb5d920fd --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_validationdetails.go @@ -0,0 +1,42 @@ +package migrations + +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 ValidationDetails struct { + DbLevelValidationDetails *[]DbLevelValidationStatus `json:"dbLevelValidationDetails,omitempty"` + ServerLevelValidationDetails *[]ValidationSummaryItem `json:"serverLevelValidationDetails,omitempty"` + Status *ValidationState `json:"status,omitempty"` + ValidationEndTimeInUtc *string `json:"validationEndTimeInUtc,omitempty"` + ValidationStartTimeInUtc *string `json:"validationStartTimeInUtc,omitempty"` +} + +func (o *ValidationDetails) GetValidationEndTimeInUtcAsTime() (*time.Time, error) { + if o.ValidationEndTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidationEndTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ValidationDetails) SetValidationEndTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidationEndTimeInUtc = &formatted +} + +func (o *ValidationDetails) GetValidationStartTimeInUtcAsTime() (*time.Time, error) { + if o.ValidationStartTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidationStartTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ValidationDetails) SetValidationStartTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidationStartTimeInUtc = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_validationmessage.go b/resource-manager/postgresql/2024-08-01/migrations/model_validationmessage.go new file mode 100644 index 00000000000..c928fd7cdd7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_validationmessage.go @@ -0,0 +1,9 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidationMessage struct { + Message *string `json:"message,omitempty"` + State *ValidationState `json:"state,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/model_validationsummaryitem.go b/resource-manager/postgresql/2024-08-01/migrations/model_validationsummaryitem.go new file mode 100644 index 00000000000..f1caeaf62bb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/model_validationsummaryitem.go @@ -0,0 +1,10 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidationSummaryItem struct { + Messages *[]ValidationMessage `json:"messages,omitempty"` + State *ValidationState `json:"state,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/migrations/predicates.go b/resource-manager/postgresql/2024-08-01/migrations/predicates.go new file mode 100644 index 00000000000..b9eb451a481 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/predicates.go @@ -0,0 +1,32 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationResourceOperationPredicate) Matches(input MigrationResource) 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/postgresql/2024-08-01/migrations/version.go b/resource-manager/postgresql/2024-08-01/migrations/version.go new file mode 100644 index 00000000000..76771dc7019 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/migrations/version.go @@ -0,0 +1,10 @@ +package migrations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/migrations/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/post/README.md b/resource-manager/postgresql/2024-08-01/post/README.md new file mode 100644 index 00000000000..7694a3ebaa6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/post` Documentation + +The `post` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/post" +``` + + +### Client Initialization + +```go +client := post.NewPOSTClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `POSTClient.CheckMigrationNameAvailability` + +```go +ctx := context.TODO() +id := post.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := post.MigrationNameAvailabilityResource{ + // ... +} + + +read, err := client.CheckMigrationNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/postgresql/2024-08-01/post/client.go b/resource-manager/postgresql/2024-08-01/post/client.go new file mode 100644 index 00000000000..5a71c067caa --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/client.go @@ -0,0 +1,26 @@ +package post + +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 POSTClient struct { + Client *resourcemanager.Client +} + +func NewPOSTClientWithBaseURI(sdkApi sdkEnv.Api) (*POSTClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "post", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating POSTClient: %+v", err) + } + + return &POSTClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/post/constants.go b/resource-manager/postgresql/2024-08-01/post/constants.go new file mode 100644 index 00000000000..b8131265872 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/constants.go @@ -0,0 +1,51 @@ +package post + +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 MigrationNameAvailabilityReason string + +const ( + MigrationNameAvailabilityReasonAlreadyExists MigrationNameAvailabilityReason = "AlreadyExists" + MigrationNameAvailabilityReasonInvalid MigrationNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForMigrationNameAvailabilityReason() []string { + return []string{ + string(MigrationNameAvailabilityReasonAlreadyExists), + string(MigrationNameAvailabilityReasonInvalid), + } +} + +func (s *MigrationNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationNameAvailabilityReason(input string) (*MigrationNameAvailabilityReason, error) { + vals := map[string]MigrationNameAvailabilityReason{ + "alreadyexists": MigrationNameAvailabilityReasonAlreadyExists, + "invalid": MigrationNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationNameAvailabilityReason(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/post/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/post/id_flexibleserver.go new file mode 100644 index 00000000000..9be26998464 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/id_flexibleserver.go @@ -0,0 +1,130 @@ +package post + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/post/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/post/id_flexibleserver_test.go new file mode 100644 index 00000000000..e5c918cf832 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package post + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/post/method_checkmigrationnameavailability.go b/resource-manager/postgresql/2024-08-01/post/method_checkmigrationnameavailability.go new file mode 100644 index 00000000000..21b9dbecaf8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/method_checkmigrationnameavailability.go @@ -0,0 +1,58 @@ +package post + +import ( + "context" + "fmt" + "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 CheckMigrationNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrationNameAvailabilityResource +} + +// CheckMigrationNameAvailability ... +func (c POSTClient) CheckMigrationNameAvailability(ctx context.Context, id FlexibleServerId, input MigrationNameAvailabilityResource) (result CheckMigrationNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkMigrationNameAvailability", 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 + } + + var model MigrationNameAvailabilityResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/post/model_migrationnameavailabilityresource.go b/resource-manager/postgresql/2024-08-01/post/model_migrationnameavailabilityresource.go new file mode 100644 index 00000000000..02509ffa7cb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/model_migrationnameavailabilityresource.go @@ -0,0 +1,12 @@ +package post + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationNameAvailabilityResource struct { + Message *string `json:"message,omitempty"` + Name string `json:"name"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *MigrationNameAvailabilityReason `json:"reason,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/postgresql/2024-08-01/post/version.go b/resource-manager/postgresql/2024-08-01/post/version.go new file mode 100644 index 00000000000..944a8be1ef7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/post/version.go @@ -0,0 +1,10 @@ +package post + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/post/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/README.md b/resource-manager/postgresql/2024-08-01/privateendpointconnections/README.md new file mode 100644 index 00000000000..bd938b0ccf3 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateEndpointConnectionName") + +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: `PrivateEndpointConnectionsClient.ListByServer` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.PrivateEndpointConnectionDelete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateEndpointConnectionName") + +if err := client.PrivateEndpointConnectionDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.PrivateEndpointConnectionUpdate` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +if err := client.PrivateEndpointConnectionUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/client.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/constants.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/constants.go new file mode 100644 index 00000000000..c5850609650 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/constants.go @@ -0,0 +1,101 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver.go new file mode 100644 index 00000000000..7fccd19ae70 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver_test.go new file mode 100644 index 00000000000..4fdfc78d50b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..0168dfa384a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, flexibleServerName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..fbc162586d7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateEndpointConnectionName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId 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/postgresql/2024-08-01/privateendpointconnections/method_get.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..351242746d4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_get.go @@ -0,0 +1,53 @@ +package privateendpointconnections + +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 *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (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 + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_listbyserver.go new file mode 100644 index 00000000000..ffd9f5b4b56 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_listbyserver.go @@ -0,0 +1,105 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c PrivateEndpointConnectionsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate PrivateEndpointConnectionOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go new file mode 100644 index 00000000000..5a1a65a1082 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go @@ -0,0 +1,70 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionDelete ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionDeleteOperationResponse, 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 +} + +// PrivateEndpointConnectionDeleteThenPoll performs PrivateEndpointConnectionDelete then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectionupdate.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectionupdate.go new file mode 100644 index 00000000000..abcce466072 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/method_privateendpointconnectionupdate.go @@ -0,0 +1,76 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionUpdate ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// PrivateEndpointConnectionUpdateThenPoll performs PrivateEndpointConnectionUpdate then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { + result, err := c.PrivateEndpointConnectionUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..1bc8cf2a97c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..977fe056fe3 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package privateendpointconnections + +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 PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..fb540c904b6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..ec3f7a9f24c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privateendpointconnections/predicates.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/predicates.go new file mode 100644 index 00000000000..4a03a91ce52 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/predicates.go @@ -0,0 +1,27 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) 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/postgresql/2024-08-01/privateendpointconnections/version.go b/resource-manager/postgresql/2024-08-01/privateendpointconnections/version.go new file mode 100644 index 00000000000..ad70751ae64 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privateendpointconnections/version.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/README.md b/resource-manager/postgresql/2024-08-01/privatelinkresources/README.md new file mode 100644 index 00000000000..3a99f8101e1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := privatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateLinkResourceName") + +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: `PrivateLinkResourcesClient.ListByServer` + +```go +ctx := context.TODO() +id := privatelinkresources.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/client.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +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 PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver.go new file mode 100644 index 00000000000..84c10d65202 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver.go @@ -0,0 +1,130 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver_test.go new file mode 100644 index 00000000000..8057f0b92ff --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package privatelinkresources + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..35afe3f2af6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, flexibleServerName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + PrivateLinkResourceName: privateLinkResourceName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.PrivateLinkResourceName, ok = input.Parsed["privateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkResourceName", input) + } + + return nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(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 := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.PrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("privateLinkResourceName", "privateLinkResourceName"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Private Link Resource Name: %q", id.PrivateLinkResourceName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource_test.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..30a583291b5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package privatelinkresources + +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 = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateLinkResourceName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.PrivateLinkResourceName != "privateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkResourceName'", id.PrivateLinkResourceName, "privateLinkResourceName") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "privateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources/privateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + PrivateLinkResourceName: "pRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId 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/postgresql/2024-08-01/privatelinkresources/method_get.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/method_get.go new file mode 100644 index 00000000000..4fe26146181 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/method_get.go @@ -0,0 +1,53 @@ +package privatelinkresources + +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 *PrivateLinkResource +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (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 + } + + var model PrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/method_listbyserver.go new file mode 100644 index 00000000000..19e7e42633a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/method_listbyserver.go @@ -0,0 +1,105 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c PrivateLinkResourcesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/privateLinkResources", 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 *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c PrivateLinkResourcesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkResourcesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate PrivateLinkResourceOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresource.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..6e8c3d8148b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package privatelinkresources + +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 PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..3c98012cdd1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/privatelinkresources/predicates.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/predicates.go new file mode 100644 index 00000000000..19b771c3994 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) 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/postgresql/2024-08-01/privatelinkresources/version.go b/resource-manager/postgresql/2024-08-01/privatelinkresources/version.go new file mode 100644 index 00000000000..a50585a5dae --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/privatelinkresources/version.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/README.md b/resource-manager/postgresql/2024-08-01/replicas/README.md new file mode 100644 index 00000000000..270e1859213 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/replicas` Documentation + +The `replicas` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/replicas" +``` + + +### Client Initialization + +```go +client := replicas.NewReplicasClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicasClient.ListByServer` + +```go +ctx := context.TODO() +id := replicas.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/postgresql/2024-08-01/replicas/client.go b/resource-manager/postgresql/2024-08-01/replicas/client.go new file mode 100644 index 00000000000..b494c8a0a7f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/client.go @@ -0,0 +1,26 @@ +package replicas + +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 ReplicasClient struct { + Client *resourcemanager.Client +} + +func NewReplicasClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicasClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicas", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicasClient: %+v", err) + } + + return &ReplicasClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/constants.go b/resource-manager/postgresql/2024-08-01/replicas/constants.go new file mode 100644 index 00000000000..b3549240ab0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/constants.go @@ -0,0 +1,994 @@ +package replicas + +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 ActiveDirectoryAuthEnum string + +const ( + ActiveDirectoryAuthEnumDisabled ActiveDirectoryAuthEnum = "Disabled" + ActiveDirectoryAuthEnumEnabled ActiveDirectoryAuthEnum = "Enabled" +) + +func PossibleValuesForActiveDirectoryAuthEnum() []string { + return []string{ + string(ActiveDirectoryAuthEnumDisabled), + string(ActiveDirectoryAuthEnumEnabled), + } +} + +func (s *ActiveDirectoryAuthEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveDirectoryAuthEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveDirectoryAuthEnum(input string) (*ActiveDirectoryAuthEnum, error) { + vals := map[string]ActiveDirectoryAuthEnum{ + "disabled": ActiveDirectoryAuthEnumDisabled, + "enabled": ActiveDirectoryAuthEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveDirectoryAuthEnum(input) + return &out, nil +} + +type ArmServerKeyType string + +const ( + ArmServerKeyTypeAzureKeyVault ArmServerKeyType = "AzureKeyVault" + ArmServerKeyTypeSystemManaged ArmServerKeyType = "SystemManaged" +) + +func PossibleValuesForArmServerKeyType() []string { + return []string{ + string(ArmServerKeyTypeAzureKeyVault), + string(ArmServerKeyTypeSystemManaged), + } +} + +func (s *ArmServerKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseArmServerKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseArmServerKeyType(input string) (*ArmServerKeyType, error) { + vals := map[string]ArmServerKeyType{ + "azurekeyvault": ArmServerKeyTypeAzureKeyVault, + "systemmanaged": ArmServerKeyTypeSystemManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ArmServerKeyType(input) + return &out, nil +} + +type AzureManagedDiskPerformanceTiers string + +const ( + AzureManagedDiskPerformanceTiersPEightZero AzureManagedDiskPerformanceTiers = "P80" + AzureManagedDiskPerformanceTiersPFiveZero AzureManagedDiskPerformanceTiers = "P50" + AzureManagedDiskPerformanceTiersPFour AzureManagedDiskPerformanceTiers = "P4" + AzureManagedDiskPerformanceTiersPFourZero AzureManagedDiskPerformanceTiers = "P40" + AzureManagedDiskPerformanceTiersPOne AzureManagedDiskPerformanceTiers = "P1" + AzureManagedDiskPerformanceTiersPOneFive AzureManagedDiskPerformanceTiers = "P15" + AzureManagedDiskPerformanceTiersPOneZero AzureManagedDiskPerformanceTiers = "P10" + AzureManagedDiskPerformanceTiersPSevenZero AzureManagedDiskPerformanceTiers = "P70" + AzureManagedDiskPerformanceTiersPSix AzureManagedDiskPerformanceTiers = "P6" + AzureManagedDiskPerformanceTiersPSixZero AzureManagedDiskPerformanceTiers = "P60" + AzureManagedDiskPerformanceTiersPThree AzureManagedDiskPerformanceTiers = "P3" + AzureManagedDiskPerformanceTiersPThreeZero AzureManagedDiskPerformanceTiers = "P30" + AzureManagedDiskPerformanceTiersPTwo AzureManagedDiskPerformanceTiers = "P2" + AzureManagedDiskPerformanceTiersPTwoZero AzureManagedDiskPerformanceTiers = "P20" +) + +func PossibleValuesForAzureManagedDiskPerformanceTiers() []string { + return []string{ + string(AzureManagedDiskPerformanceTiersPEightZero), + string(AzureManagedDiskPerformanceTiersPFiveZero), + string(AzureManagedDiskPerformanceTiersPFour), + string(AzureManagedDiskPerformanceTiersPFourZero), + string(AzureManagedDiskPerformanceTiersPOne), + string(AzureManagedDiskPerformanceTiersPOneFive), + string(AzureManagedDiskPerformanceTiersPOneZero), + string(AzureManagedDiskPerformanceTiersPSevenZero), + string(AzureManagedDiskPerformanceTiersPSix), + string(AzureManagedDiskPerformanceTiersPSixZero), + string(AzureManagedDiskPerformanceTiersPThree), + string(AzureManagedDiskPerformanceTiersPThreeZero), + string(AzureManagedDiskPerformanceTiersPTwo), + string(AzureManagedDiskPerformanceTiersPTwoZero), + } +} + +func (s *AzureManagedDiskPerformanceTiers) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureManagedDiskPerformanceTiers(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureManagedDiskPerformanceTiers(input string) (*AzureManagedDiskPerformanceTiers, error) { + vals := map[string]AzureManagedDiskPerformanceTiers{ + "p80": AzureManagedDiskPerformanceTiersPEightZero, + "p50": AzureManagedDiskPerformanceTiersPFiveZero, + "p4": AzureManagedDiskPerformanceTiersPFour, + "p40": AzureManagedDiskPerformanceTiersPFourZero, + "p1": AzureManagedDiskPerformanceTiersPOne, + "p15": AzureManagedDiskPerformanceTiersPOneFive, + "p10": AzureManagedDiskPerformanceTiersPOneZero, + "p70": AzureManagedDiskPerformanceTiersPSevenZero, + "p6": AzureManagedDiskPerformanceTiersPSix, + "p60": AzureManagedDiskPerformanceTiersPSixZero, + "p3": AzureManagedDiskPerformanceTiersPThree, + "p30": AzureManagedDiskPerformanceTiersPThreeZero, + "p2": AzureManagedDiskPerformanceTiersPTwo, + "p20": AzureManagedDiskPerformanceTiersPTwoZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureManagedDiskPerformanceTiers(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeCreate CreateMode = "Create" + CreateModeDefault CreateMode = "Default" + CreateModeGeoRestore CreateMode = "GeoRestore" + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + CreateModeReplica CreateMode = "Replica" + CreateModeReviveDropped CreateMode = "ReviveDropped" + CreateModeUpdate CreateMode = "Update" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeCreate), + string(CreateModeDefault), + string(CreateModeGeoRestore), + string(CreateModePointInTimeRestore), + string(CreateModeReplica), + string(CreateModeReviveDropped), + string(CreateModeUpdate), + } +} + +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "create": CreateModeCreate, + "default": CreateModeDefault, + "georestore": CreateModeGeoRestore, + "pointintimerestore": CreateModePointInTimeRestore, + "replica": CreateModeReplica, + "revivedropped": CreateModeReviveDropped, + "update": CreateModeUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type GeoRedundantBackupEnum string + +const ( + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = "Disabled" + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = "Enabled" +) + +func PossibleValuesForGeoRedundantBackupEnum() []string { + return []string{ + string(GeoRedundantBackupEnumDisabled), + string(GeoRedundantBackupEnumEnabled), + } +} + +func (s *GeoRedundantBackupEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoRedundantBackupEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeoRedundantBackupEnum(input string) (*GeoRedundantBackupEnum, error) { + vals := map[string]GeoRedundantBackupEnum{ + "disabled": GeoRedundantBackupEnumDisabled, + "enabled": GeoRedundantBackupEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GeoRedundantBackupEnum(input) + return &out, nil +} + +type HighAvailabilityMode string + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + HighAvailabilityModeSameZone HighAvailabilityMode = "SameZone" + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +func PossibleValuesForHighAvailabilityMode() []string { + return []string{ + string(HighAvailabilityModeDisabled), + string(HighAvailabilityModeSameZone), + string(HighAvailabilityModeZoneRedundant), + } +} + +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { + vals := map[string]HighAvailabilityMode{ + "disabled": HighAvailabilityModeDisabled, + "samezone": HighAvailabilityModeSameZone, + "zoneredundant": HighAvailabilityModeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HighAvailabilityMode(input) + return &out, nil +} + +type KeyStatusEnum string + +const ( + KeyStatusEnumInvalid KeyStatusEnum = "Invalid" + KeyStatusEnumValid KeyStatusEnum = "Valid" +) + +func PossibleValuesForKeyStatusEnum() []string { + return []string{ + string(KeyStatusEnumInvalid), + string(KeyStatusEnumValid), + } +} + +func (s *KeyStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyStatusEnum(input string) (*KeyStatusEnum, error) { + vals := map[string]KeyStatusEnum{ + "invalid": KeyStatusEnumInvalid, + "valid": KeyStatusEnumValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyStatusEnum(input) + return &out, nil +} + +type PasswordAuthEnum string + +const ( + PasswordAuthEnumDisabled PasswordAuthEnum = "Disabled" + PasswordAuthEnumEnabled PasswordAuthEnum = "Enabled" +) + +func PossibleValuesForPasswordAuthEnum() []string { + return []string{ + string(PasswordAuthEnumDisabled), + string(PasswordAuthEnumEnabled), + } +} + +func (s *PasswordAuthEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePasswordAuthEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePasswordAuthEnum(input string) (*PasswordAuthEnum, error) { + vals := map[string]PasswordAuthEnum{ + "disabled": PasswordAuthEnumDisabled, + "enabled": PasswordAuthEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PasswordAuthEnum(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ReadReplicaPromoteMode string + +const ( + ReadReplicaPromoteModeStandalone ReadReplicaPromoteMode = "standalone" + ReadReplicaPromoteModeSwitchover ReadReplicaPromoteMode = "switchover" +) + +func PossibleValuesForReadReplicaPromoteMode() []string { + return []string{ + string(ReadReplicaPromoteModeStandalone), + string(ReadReplicaPromoteModeSwitchover), + } +} + +func (s *ReadReplicaPromoteMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReadReplicaPromoteMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReadReplicaPromoteMode(input string) (*ReadReplicaPromoteMode, error) { + vals := map[string]ReadReplicaPromoteMode{ + "standalone": ReadReplicaPromoteModeStandalone, + "switchover": ReadReplicaPromoteModeSwitchover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReadReplicaPromoteMode(input) + return &out, nil +} + +type ReplicationPromoteOption string + +const ( + ReplicationPromoteOptionForced ReplicationPromoteOption = "forced" + ReplicationPromoteOptionPlanned ReplicationPromoteOption = "planned" +) + +func PossibleValuesForReplicationPromoteOption() []string { + return []string{ + string(ReplicationPromoteOptionForced), + string(ReplicationPromoteOptionPlanned), + } +} + +func (s *ReplicationPromoteOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationPromoteOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationPromoteOption(input string) (*ReplicationPromoteOption, error) { + vals := map[string]ReplicationPromoteOption{ + "forced": ReplicationPromoteOptionForced, + "planned": ReplicationPromoteOptionPlanned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationPromoteOption(input) + return &out, nil +} + +type ReplicationRole string + +const ( + ReplicationRoleAsyncReplica ReplicationRole = "AsyncReplica" + ReplicationRoleGeoAsyncReplica ReplicationRole = "GeoAsyncReplica" + ReplicationRoleNone ReplicationRole = "None" + ReplicationRolePrimary ReplicationRole = "Primary" +) + +func PossibleValuesForReplicationRole() []string { + return []string{ + string(ReplicationRoleAsyncReplica), + string(ReplicationRoleGeoAsyncReplica), + string(ReplicationRoleNone), + string(ReplicationRolePrimary), + } +} + +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationRole(input string) (*ReplicationRole, error) { + vals := map[string]ReplicationRole{ + "asyncreplica": ReplicationRoleAsyncReplica, + "geoasyncreplica": ReplicationRoleGeoAsyncReplica, + "none": ReplicationRoleNone, + "primary": ReplicationRolePrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationRole(input) + return &out, nil +} + +type ReplicationState string + +const ( + ReplicationStateActive ReplicationState = "Active" + ReplicationStateBroken ReplicationState = "Broken" + ReplicationStateCatchup ReplicationState = "Catchup" + ReplicationStateProvisioning ReplicationState = "Provisioning" + ReplicationStateReconfiguring ReplicationState = "Reconfiguring" + ReplicationStateUpdating ReplicationState = "Updating" +) + +func PossibleValuesForReplicationState() []string { + return []string{ + string(ReplicationStateActive), + string(ReplicationStateBroken), + string(ReplicationStateCatchup), + string(ReplicationStateProvisioning), + string(ReplicationStateReconfiguring), + string(ReplicationStateUpdating), + } +} + +func (s *ReplicationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationState(input string) (*ReplicationState, error) { + vals := map[string]ReplicationState{ + "active": ReplicationStateActive, + "broken": ReplicationStateBroken, + "catchup": ReplicationStateCatchup, + "provisioning": ReplicationStateProvisioning, + "reconfiguring": ReplicationStateReconfiguring, + "updating": ReplicationStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationState(input) + return &out, nil +} + +type ServerHAState string + +const ( + ServerHAStateCreatingStandby ServerHAState = "CreatingStandby" + ServerHAStateFailingOver ServerHAState = "FailingOver" + ServerHAStateHealthy ServerHAState = "Healthy" + ServerHAStateNotEnabled ServerHAState = "NotEnabled" + ServerHAStateRemovingStandby ServerHAState = "RemovingStandby" + ServerHAStateReplicatingData ServerHAState = "ReplicatingData" +) + +func PossibleValuesForServerHAState() []string { + return []string{ + string(ServerHAStateCreatingStandby), + string(ServerHAStateFailingOver), + string(ServerHAStateHealthy), + string(ServerHAStateNotEnabled), + string(ServerHAStateRemovingStandby), + string(ServerHAStateReplicatingData), + } +} + +func (s *ServerHAState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerHAState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerHAState(input string) (*ServerHAState, error) { + vals := map[string]ServerHAState{ + "creatingstandby": ServerHAStateCreatingStandby, + "failingover": ServerHAStateFailingOver, + "healthy": ServerHAStateHealthy, + "notenabled": ServerHAStateNotEnabled, + "removingstandby": ServerHAStateRemovingStandby, + "replicatingdata": ServerHAStateReplicatingData, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerHAState(input) + return &out, nil +} + +type ServerPublicNetworkAccessState string + +const ( + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +func PossibleValuesForServerPublicNetworkAccessState() []string { + return []string{ + string(ServerPublicNetworkAccessStateDisabled), + string(ServerPublicNetworkAccessStateEnabled), + } +} + +func (s *ServerPublicNetworkAccessState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerPublicNetworkAccessState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerPublicNetworkAccessState(input string) (*ServerPublicNetworkAccessState, error) { + vals := map[string]ServerPublicNetworkAccessState{ + "disabled": ServerPublicNetworkAccessStateDisabled, + "enabled": ServerPublicNetworkAccessStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerPublicNetworkAccessState(input) + return &out, nil +} + +type ServerState string + +const ( + ServerStateDisabled ServerState = "Disabled" + ServerStateDropping ServerState = "Dropping" + ServerStateReady ServerState = "Ready" + ServerStateStarting ServerState = "Starting" + ServerStateStopped ServerState = "Stopped" + ServerStateStopping ServerState = "Stopping" + ServerStateUpdating ServerState = "Updating" +) + +func PossibleValuesForServerState() []string { + return []string{ + string(ServerStateDisabled), + string(ServerStateDropping), + string(ServerStateReady), + string(ServerStateStarting), + string(ServerStateStopped), + string(ServerStateStopping), + string(ServerStateUpdating), + } +} + +func (s *ServerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerState(input string) (*ServerState, error) { + vals := map[string]ServerState{ + "disabled": ServerStateDisabled, + "dropping": ServerStateDropping, + "ready": ServerStateReady, + "starting": ServerStateStarting, + "stopped": ServerStateStopped, + "stopping": ServerStateStopping, + "updating": ServerStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerState(input) + return &out, nil +} + +type ServerVersion string + +const ( + ServerVersionOneFive ServerVersion = "15" + ServerVersionOneFour ServerVersion = "14" + ServerVersionOneOne ServerVersion = "11" + ServerVersionOneSix ServerVersion = "16" + ServerVersionOneThree ServerVersion = "13" + ServerVersionOneTwo ServerVersion = "12" +) + +func PossibleValuesForServerVersion() []string { + return []string{ + string(ServerVersionOneFive), + string(ServerVersionOneFour), + string(ServerVersionOneOne), + string(ServerVersionOneSix), + string(ServerVersionOneThree), + string(ServerVersionOneTwo), + } +} + +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerVersion(input string) (*ServerVersion, error) { + vals := map[string]ServerVersion{ + "15": ServerVersionOneFive, + "14": ServerVersionOneFour, + "11": ServerVersionOneOne, + "16": ServerVersionOneSix, + "13": ServerVersionOneThree, + "12": ServerVersionOneTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerVersion(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBurstable SkuTier = "Burstable" + SkuTierGeneralPurpose SkuTier = "GeneralPurpose" + SkuTierMemoryOptimized SkuTier = "MemoryOptimized" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBurstable), + string(SkuTierGeneralPurpose), + string(SkuTierMemoryOptimized), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "burstable": SkuTierBurstable, + "generalpurpose": SkuTierGeneralPurpose, + "memoryoptimized": SkuTierMemoryOptimized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type StorageAutoGrow string + +const ( + StorageAutoGrowDisabled StorageAutoGrow = "Disabled" + StorageAutoGrowEnabled StorageAutoGrow = "Enabled" +) + +func PossibleValuesForStorageAutoGrow() []string { + return []string{ + string(StorageAutoGrowDisabled), + string(StorageAutoGrowEnabled), + } +} + +func (s *StorageAutoGrow) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAutoGrow(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAutoGrow(input string) (*StorageAutoGrow, error) { + vals := map[string]StorageAutoGrow{ + "disabled": StorageAutoGrowDisabled, + "enabled": StorageAutoGrowEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAutoGrow(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypePremiumLRS StorageType = "Premium_LRS" + StorageTypePremiumVTwoLRS StorageType = "PremiumV2_LRS" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypePremiumLRS), + string(StorageTypePremiumVTwoLRS), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "premium_lrs": StorageTypePremiumLRS, + "premiumv2_lrs": StorageTypePremiumVTwoLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver.go new file mode 100644 index 00000000000..f2e8777baa9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver.go @@ -0,0 +1,130 @@ +package replicas + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver_test.go new file mode 100644 index 00000000000..e4e16876663 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package replicas + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/replicas/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/replicas/method_listbyserver.go new file mode 100644 index 00000000000..16d7c7771c4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/method_listbyserver.go @@ -0,0 +1,105 @@ +package replicas + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []Server +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c ReplicasClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/replicas", 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 *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c ReplicasClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicasClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_authconfig.go b/resource-manager/postgresql/2024-08-01/replicas/model_authconfig.go new file mode 100644 index 00000000000..99157e7acd8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_authconfig.go @@ -0,0 +1,10 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthConfig struct { + ActiveDirectoryAuth *ActiveDirectoryAuthEnum `json:"activeDirectoryAuth,omitempty"` + PasswordAuth *PasswordAuthEnum `json:"passwordAuth,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_backup.go b/resource-manager/postgresql/2024-08-01/replicas/model_backup.go new file mode 100644 index 00000000000..3d8dcd04ede --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_backup.go @@ -0,0 +1,28 @@ +package replicas + +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 Backup struct { + BackupRetentionDays *int64 `json:"backupRetentionDays,omitempty"` + EarliestRestoreDate *string `json:"earliestRestoreDate,omitempty"` + GeoRedundantBackup *GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` +} + +func (o *Backup) GetEarliestRestoreDateAsTime() (*time.Time, error) { + if o.EarliestRestoreDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EarliestRestoreDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *Backup) SetEarliestRestoreDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EarliestRestoreDate = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_dataencryption.go b/resource-manager/postgresql/2024-08-01/replicas/model_dataencryption.go new file mode 100644 index 00000000000..1463a7ca6d1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_dataencryption.go @@ -0,0 +1,14 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataEncryption struct { + GeoBackupEncryptionKeyStatus *KeyStatusEnum `json:"geoBackupEncryptionKeyStatus,omitempty"` + GeoBackupKeyURI *string `json:"geoBackupKeyURI,omitempty"` + GeoBackupUserAssignedIdentityId *string `json:"geoBackupUserAssignedIdentityId,omitempty"` + PrimaryEncryptionKeyStatus *KeyStatusEnum `json:"primaryEncryptionKeyStatus,omitempty"` + PrimaryKeyURI *string `json:"primaryKeyURI,omitempty"` + PrimaryUserAssignedIdentityId *string `json:"primaryUserAssignedIdentityId,omitempty"` + Type *ArmServerKeyType `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_highavailability.go b/resource-manager/postgresql/2024-08-01/replicas/model_highavailability.go new file mode 100644 index 00000000000..84a9f120552 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_highavailability.go @@ -0,0 +1,10 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailability struct { + Mode *HighAvailabilityMode `json:"mode,omitempty"` + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` + State *ServerHAState `json:"state,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_maintenancewindow.go b/resource-manager/postgresql/2024-08-01/replicas/model_maintenancewindow.go new file mode 100644 index 00000000000..cc7a0b4cfe2 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_maintenancewindow.go @@ -0,0 +1,11 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindow struct { + CustomWindow *string `json:"customWindow,omitempty"` + DayOfWeek *int64 `json:"dayOfWeek,omitempty"` + StartHour *int64 `json:"startHour,omitempty"` + StartMinute *int64 `json:"startMinute,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_network.go b/resource-manager/postgresql/2024-08-01/replicas/model_network.go new file mode 100644 index 00000000000..9dbfaa0820c --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_network.go @@ -0,0 +1,10 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Network struct { + DelegatedSubnetResourceId *string `json:"delegatedSubnetResourceId,omitempty"` + PrivateDnsZoneArmResourceId *string `json:"privateDnsZoneArmResourceId,omitempty"` + PublicNetworkAccess *ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_privateendpoint.go b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpoint.go new file mode 100644 index 00000000000..48ed00f3333 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpoint.go @@ -0,0 +1,8 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnection.go b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnection.go new file mode 100644 index 00000000000..2ff0aaed8d4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package replicas + +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 PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnectionproperties.go b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..d3068b6993f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_privatelinkserviceconnectionstate.go b/resource-manager/postgresql/2024-08-01/replicas/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..311ee4497b7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_replica.go b/resource-manager/postgresql/2024-08-01/replicas/model_replica.go new file mode 100644 index 00000000000..ea064d6ea9e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_replica.go @@ -0,0 +1,12 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replica struct { + Capacity *int64 `json:"capacity,omitempty"` + PromoteMode *ReadReplicaPromoteMode `json:"promoteMode,omitempty"` + PromoteOption *ReplicationPromoteOption `json:"promoteOption,omitempty"` + ReplicationState *ReplicationState `json:"replicationState,omitempty"` + Role *ReplicationRole `json:"role,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_server.go b/resource-manager/postgresql/2024-08-01/replicas/model_server.go new file mode 100644 index 00000000000..ece7f9d3959 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_server.go @@ -0,0 +1,21 @@ +package replicas + +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 Server struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServerProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_serverproperties.go b/resource-manager/postgresql/2024-08-01/replicas/model_serverproperties.go new file mode 100644 index 00000000000..c5fc9547bd7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_serverproperties.go @@ -0,0 +1,46 @@ +package replicas + +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 ServerProperties struct { + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthConfig *AuthConfig `json:"authConfig,omitempty"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + Backup *Backup `json:"backup,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DataEncryption *DataEncryption `json:"dataEncryption,omitempty"` + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + MinorVersion *string `json:"minorVersion,omitempty"` + Network *Network `json:"network,omitempty"` + PointInTimeUTC *string `json:"pointInTimeUTC,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + Replica *Replica `json:"replica,omitempty"` + ReplicaCapacity *int64 `json:"replicaCapacity,omitempty"` + ReplicationRole *ReplicationRole `json:"replicationRole,omitempty"` + SourceServerResourceId *string `json:"sourceServerResourceId,omitempty"` + State *ServerState `json:"state,omitempty"` + Storage *Storage `json:"storage,omitempty"` + Version *ServerVersion `json:"version,omitempty"` +} + +func (o *ServerProperties) GetPointInTimeUTCAsTime() (*time.Time, error) { + if o.PointInTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PointInTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *ServerProperties) SetPointInTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PointInTimeUTC = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_sku.go b/resource-manager/postgresql/2024-08-01/replicas/model_sku.go new file mode 100644 index 00000000000..198e743bce6 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_sku.go @@ -0,0 +1,9 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name string `json:"name"` + Tier SkuTier `json:"tier"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/model_storage.go b/resource-manager/postgresql/2024-08-01/replicas/model_storage.go new file mode 100644 index 00000000000..94ab947a639 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/model_storage.go @@ -0,0 +1,13 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Storage struct { + AutoGrow *StorageAutoGrow `json:"autoGrow,omitempty"` + Iops *int64 `json:"iops,omitempty"` + StorageSizeGB *int64 `json:"storageSizeGB,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` + Tier *AzureManagedDiskPerformanceTiers `json:"tier,omitempty"` + Type *StorageType `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/replicas/predicates.go b/resource-manager/postgresql/2024-08-01/replicas/predicates.go new file mode 100644 index 00000000000..ea213c7c556 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/predicates.go @@ -0,0 +1,32 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ServerOperationPredicate) Matches(input Server) 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/postgresql/2024-08-01/replicas/version.go b/resource-manager/postgresql/2024-08-01/replicas/version.go new file mode 100644 index 00000000000..6b14082fef8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/replicas/version.go @@ -0,0 +1,10 @@ +package replicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicas/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/README.md b/resource-manager/postgresql/2024-08-01/serverrestart/README.md new file mode 100644 index 00000000000..b67a2753f25 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/serverrestart` Documentation + +The `serverrestart` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/serverrestart" +``` + + +### Client Initialization + +```go +client := serverrestart.NewServerRestartClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServerRestartClient.ServersRestart` + +```go +ctx := context.TODO() +id := serverrestart.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := serverrestart.RestartParameter{ + // ... +} + + +if err := client.ServersRestartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/client.go b/resource-manager/postgresql/2024-08-01/serverrestart/client.go new file mode 100644 index 00000000000..b3cc7f2e6a7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/client.go @@ -0,0 +1,26 @@ +package serverrestart + +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 ServerRestartClient struct { + Client *resourcemanager.Client +} + +func NewServerRestartClientWithBaseURI(sdkApi sdkEnv.Api) (*ServerRestartClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serverrestart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerRestartClient: %+v", err) + } + + return &ServerRestartClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/constants.go b/resource-manager/postgresql/2024-08-01/serverrestart/constants.go new file mode 100644 index 00000000000..f3e25dd3e05 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/constants.go @@ -0,0 +1,57 @@ +package serverrestart + +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 FailoverMode string + +const ( + FailoverModeForcedFailover FailoverMode = "ForcedFailover" + FailoverModeForcedSwitchover FailoverMode = "ForcedSwitchover" + FailoverModePlannedFailover FailoverMode = "PlannedFailover" + FailoverModePlannedSwitchover FailoverMode = "PlannedSwitchover" +) + +func PossibleValuesForFailoverMode() []string { + return []string{ + string(FailoverModeForcedFailover), + string(FailoverModeForcedSwitchover), + string(FailoverModePlannedFailover), + string(FailoverModePlannedSwitchover), + } +} + +func (s *FailoverMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverMode(input string) (*FailoverMode, error) { + vals := map[string]FailoverMode{ + "forcedfailover": FailoverModeForcedFailover, + "forcedswitchover": FailoverModeForcedSwitchover, + "plannedfailover": FailoverModePlannedFailover, + "plannedswitchover": FailoverModePlannedSwitchover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverMode(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver.go new file mode 100644 index 00000000000..5d1622ef152 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver.go @@ -0,0 +1,130 @@ +package serverrestart + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver_test.go new file mode 100644 index 00000000000..0a396114d99 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package serverrestart + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/serverrestart/method_serversrestart.go b/resource-manager/postgresql/2024-08-01/serverrestart/method_serversrestart.go new file mode 100644 index 00000000000..5dc0c939b87 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/method_serversrestart.go @@ -0,0 +1,74 @@ +package serverrestart + +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 ServersRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersRestart ... +func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input RestartParameter) (result ServersRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 +} + +// ServersRestartThenPoll performs ServersRestart then polls until it's completed +func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input RestartParameter) error { + result, err := c.ServersRestart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServersRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/model_restartparameter.go b/resource-manager/postgresql/2024-08-01/serverrestart/model_restartparameter.go new file mode 100644 index 00000000000..752616bf818 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/model_restartparameter.go @@ -0,0 +1,9 @@ +package serverrestart + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartParameter struct { + FailoverMode *FailoverMode `json:"failoverMode,omitempty"` + RestartWithFailover *bool `json:"restartWithFailover,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/serverrestart/version.go b/resource-manager/postgresql/2024-08-01/serverrestart/version.go new file mode 100644 index 00000000000..b6b7d58de1e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverrestart/version.go @@ -0,0 +1,10 @@ +package serverrestart + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serverrestart/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/servers/README.md b/resource-manager/postgresql/2024-08-01/servers/README.md new file mode 100644 index 00000000000..ae51876e8af --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/servers` Documentation + +The `servers` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/servers" +``` + + +### Client Initialization + +```go +client := servers.NewServersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServersClient.Create` + +```go +ctx := context.TODO() +id := servers.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := servers.Server{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServersClient.Delete` + +```go +ctx := context.TODO() +id := servers.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServersClient.Get` + +```go +ctx := context.TODO() +id := servers.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +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: `ServersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `ServersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServersClient.Update` + +```go +ctx := context.TODO() +id := servers.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +payload := servers.ServerForUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/postgresql/2024-08-01/servers/client.go b/resource-manager/postgresql/2024-08-01/servers/client.go new file mode 100644 index 00000000000..806c9525000 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/client.go @@ -0,0 +1,26 @@ +package servers + +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 ServersClient struct { + Client *resourcemanager.Client +} + +func NewServersClientWithBaseURI(sdkApi sdkEnv.Api) (*ServersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "servers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServersClient: %+v", err) + } + + return &ServersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/servers/constants.go b/resource-manager/postgresql/2024-08-01/servers/constants.go new file mode 100644 index 00000000000..23011e6a11f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/constants.go @@ -0,0 +1,1035 @@ +package servers + +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 ActiveDirectoryAuthEnum string + +const ( + ActiveDirectoryAuthEnumDisabled ActiveDirectoryAuthEnum = "Disabled" + ActiveDirectoryAuthEnumEnabled ActiveDirectoryAuthEnum = "Enabled" +) + +func PossibleValuesForActiveDirectoryAuthEnum() []string { + return []string{ + string(ActiveDirectoryAuthEnumDisabled), + string(ActiveDirectoryAuthEnumEnabled), + } +} + +func (s *ActiveDirectoryAuthEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveDirectoryAuthEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveDirectoryAuthEnum(input string) (*ActiveDirectoryAuthEnum, error) { + vals := map[string]ActiveDirectoryAuthEnum{ + "disabled": ActiveDirectoryAuthEnumDisabled, + "enabled": ActiveDirectoryAuthEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveDirectoryAuthEnum(input) + return &out, nil +} + +type ArmServerKeyType string + +const ( + ArmServerKeyTypeAzureKeyVault ArmServerKeyType = "AzureKeyVault" + ArmServerKeyTypeSystemManaged ArmServerKeyType = "SystemManaged" +) + +func PossibleValuesForArmServerKeyType() []string { + return []string{ + string(ArmServerKeyTypeAzureKeyVault), + string(ArmServerKeyTypeSystemManaged), + } +} + +func (s *ArmServerKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseArmServerKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseArmServerKeyType(input string) (*ArmServerKeyType, error) { + vals := map[string]ArmServerKeyType{ + "azurekeyvault": ArmServerKeyTypeAzureKeyVault, + "systemmanaged": ArmServerKeyTypeSystemManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ArmServerKeyType(input) + return &out, nil +} + +type AzureManagedDiskPerformanceTiers string + +const ( + AzureManagedDiskPerformanceTiersPEightZero AzureManagedDiskPerformanceTiers = "P80" + AzureManagedDiskPerformanceTiersPFiveZero AzureManagedDiskPerformanceTiers = "P50" + AzureManagedDiskPerformanceTiersPFour AzureManagedDiskPerformanceTiers = "P4" + AzureManagedDiskPerformanceTiersPFourZero AzureManagedDiskPerformanceTiers = "P40" + AzureManagedDiskPerformanceTiersPOne AzureManagedDiskPerformanceTiers = "P1" + AzureManagedDiskPerformanceTiersPOneFive AzureManagedDiskPerformanceTiers = "P15" + AzureManagedDiskPerformanceTiersPOneZero AzureManagedDiskPerformanceTiers = "P10" + AzureManagedDiskPerformanceTiersPSevenZero AzureManagedDiskPerformanceTiers = "P70" + AzureManagedDiskPerformanceTiersPSix AzureManagedDiskPerformanceTiers = "P6" + AzureManagedDiskPerformanceTiersPSixZero AzureManagedDiskPerformanceTiers = "P60" + AzureManagedDiskPerformanceTiersPThree AzureManagedDiskPerformanceTiers = "P3" + AzureManagedDiskPerformanceTiersPThreeZero AzureManagedDiskPerformanceTiers = "P30" + AzureManagedDiskPerformanceTiersPTwo AzureManagedDiskPerformanceTiers = "P2" + AzureManagedDiskPerformanceTiersPTwoZero AzureManagedDiskPerformanceTiers = "P20" +) + +func PossibleValuesForAzureManagedDiskPerformanceTiers() []string { + return []string{ + string(AzureManagedDiskPerformanceTiersPEightZero), + string(AzureManagedDiskPerformanceTiersPFiveZero), + string(AzureManagedDiskPerformanceTiersPFour), + string(AzureManagedDiskPerformanceTiersPFourZero), + string(AzureManagedDiskPerformanceTiersPOne), + string(AzureManagedDiskPerformanceTiersPOneFive), + string(AzureManagedDiskPerformanceTiersPOneZero), + string(AzureManagedDiskPerformanceTiersPSevenZero), + string(AzureManagedDiskPerformanceTiersPSix), + string(AzureManagedDiskPerformanceTiersPSixZero), + string(AzureManagedDiskPerformanceTiersPThree), + string(AzureManagedDiskPerformanceTiersPThreeZero), + string(AzureManagedDiskPerformanceTiersPTwo), + string(AzureManagedDiskPerformanceTiersPTwoZero), + } +} + +func (s *AzureManagedDiskPerformanceTiers) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureManagedDiskPerformanceTiers(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureManagedDiskPerformanceTiers(input string) (*AzureManagedDiskPerformanceTiers, error) { + vals := map[string]AzureManagedDiskPerformanceTiers{ + "p80": AzureManagedDiskPerformanceTiersPEightZero, + "p50": AzureManagedDiskPerformanceTiersPFiveZero, + "p4": AzureManagedDiskPerformanceTiersPFour, + "p40": AzureManagedDiskPerformanceTiersPFourZero, + "p1": AzureManagedDiskPerformanceTiersPOne, + "p15": AzureManagedDiskPerformanceTiersPOneFive, + "p10": AzureManagedDiskPerformanceTiersPOneZero, + "p70": AzureManagedDiskPerformanceTiersPSevenZero, + "p6": AzureManagedDiskPerformanceTiersPSix, + "p60": AzureManagedDiskPerformanceTiersPSixZero, + "p3": AzureManagedDiskPerformanceTiersPThree, + "p30": AzureManagedDiskPerformanceTiersPThreeZero, + "p2": AzureManagedDiskPerformanceTiersPTwo, + "p20": AzureManagedDiskPerformanceTiersPTwoZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureManagedDiskPerformanceTiers(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeCreate CreateMode = "Create" + CreateModeDefault CreateMode = "Default" + CreateModeGeoRestore CreateMode = "GeoRestore" + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + CreateModeReplica CreateMode = "Replica" + CreateModeReviveDropped CreateMode = "ReviveDropped" + CreateModeUpdate CreateMode = "Update" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeCreate), + string(CreateModeDefault), + string(CreateModeGeoRestore), + string(CreateModePointInTimeRestore), + string(CreateModeReplica), + string(CreateModeReviveDropped), + string(CreateModeUpdate), + } +} + +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "create": CreateModeCreate, + "default": CreateModeDefault, + "georestore": CreateModeGeoRestore, + "pointintimerestore": CreateModePointInTimeRestore, + "replica": CreateModeReplica, + "revivedropped": CreateModeReviveDropped, + "update": CreateModeUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type CreateModeForUpdate string + +const ( + CreateModeForUpdateDefault CreateModeForUpdate = "Default" + CreateModeForUpdateUpdate CreateModeForUpdate = "Update" +) + +func PossibleValuesForCreateModeForUpdate() []string { + return []string{ + string(CreateModeForUpdateDefault), + string(CreateModeForUpdateUpdate), + } +} + +func (s *CreateModeForUpdate) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateModeForUpdate(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateModeForUpdate(input string) (*CreateModeForUpdate, error) { + vals := map[string]CreateModeForUpdate{ + "default": CreateModeForUpdateDefault, + "update": CreateModeForUpdateUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateModeForUpdate(input) + return &out, nil +} + +type GeoRedundantBackupEnum string + +const ( + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = "Disabled" + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = "Enabled" +) + +func PossibleValuesForGeoRedundantBackupEnum() []string { + return []string{ + string(GeoRedundantBackupEnumDisabled), + string(GeoRedundantBackupEnumEnabled), + } +} + +func (s *GeoRedundantBackupEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeoRedundantBackupEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeoRedundantBackupEnum(input string) (*GeoRedundantBackupEnum, error) { + vals := map[string]GeoRedundantBackupEnum{ + "disabled": GeoRedundantBackupEnumDisabled, + "enabled": GeoRedundantBackupEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GeoRedundantBackupEnum(input) + return &out, nil +} + +type HighAvailabilityMode string + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + HighAvailabilityModeSameZone HighAvailabilityMode = "SameZone" + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +func PossibleValuesForHighAvailabilityMode() []string { + return []string{ + string(HighAvailabilityModeDisabled), + string(HighAvailabilityModeSameZone), + string(HighAvailabilityModeZoneRedundant), + } +} + +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { + vals := map[string]HighAvailabilityMode{ + "disabled": HighAvailabilityModeDisabled, + "samezone": HighAvailabilityModeSameZone, + "zoneredundant": HighAvailabilityModeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HighAvailabilityMode(input) + return &out, nil +} + +type KeyStatusEnum string + +const ( + KeyStatusEnumInvalid KeyStatusEnum = "Invalid" + KeyStatusEnumValid KeyStatusEnum = "Valid" +) + +func PossibleValuesForKeyStatusEnum() []string { + return []string{ + string(KeyStatusEnumInvalid), + string(KeyStatusEnumValid), + } +} + +func (s *KeyStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyStatusEnum(input string) (*KeyStatusEnum, error) { + vals := map[string]KeyStatusEnum{ + "invalid": KeyStatusEnumInvalid, + "valid": KeyStatusEnumValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyStatusEnum(input) + return &out, nil +} + +type PasswordAuthEnum string + +const ( + PasswordAuthEnumDisabled PasswordAuthEnum = "Disabled" + PasswordAuthEnumEnabled PasswordAuthEnum = "Enabled" +) + +func PossibleValuesForPasswordAuthEnum() []string { + return []string{ + string(PasswordAuthEnumDisabled), + string(PasswordAuthEnumEnabled), + } +} + +func (s *PasswordAuthEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePasswordAuthEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePasswordAuthEnum(input string) (*PasswordAuthEnum, error) { + vals := map[string]PasswordAuthEnum{ + "disabled": PasswordAuthEnumDisabled, + "enabled": PasswordAuthEnumEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PasswordAuthEnum(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ReadReplicaPromoteMode string + +const ( + ReadReplicaPromoteModeStandalone ReadReplicaPromoteMode = "standalone" + ReadReplicaPromoteModeSwitchover ReadReplicaPromoteMode = "switchover" +) + +func PossibleValuesForReadReplicaPromoteMode() []string { + return []string{ + string(ReadReplicaPromoteModeStandalone), + string(ReadReplicaPromoteModeSwitchover), + } +} + +func (s *ReadReplicaPromoteMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReadReplicaPromoteMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReadReplicaPromoteMode(input string) (*ReadReplicaPromoteMode, error) { + vals := map[string]ReadReplicaPromoteMode{ + "standalone": ReadReplicaPromoteModeStandalone, + "switchover": ReadReplicaPromoteModeSwitchover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReadReplicaPromoteMode(input) + return &out, nil +} + +type ReplicationPromoteOption string + +const ( + ReplicationPromoteOptionForced ReplicationPromoteOption = "forced" + ReplicationPromoteOptionPlanned ReplicationPromoteOption = "planned" +) + +func PossibleValuesForReplicationPromoteOption() []string { + return []string{ + string(ReplicationPromoteOptionForced), + string(ReplicationPromoteOptionPlanned), + } +} + +func (s *ReplicationPromoteOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationPromoteOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationPromoteOption(input string) (*ReplicationPromoteOption, error) { + vals := map[string]ReplicationPromoteOption{ + "forced": ReplicationPromoteOptionForced, + "planned": ReplicationPromoteOptionPlanned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationPromoteOption(input) + return &out, nil +} + +type ReplicationRole string + +const ( + ReplicationRoleAsyncReplica ReplicationRole = "AsyncReplica" + ReplicationRoleGeoAsyncReplica ReplicationRole = "GeoAsyncReplica" + ReplicationRoleNone ReplicationRole = "None" + ReplicationRolePrimary ReplicationRole = "Primary" +) + +func PossibleValuesForReplicationRole() []string { + return []string{ + string(ReplicationRoleAsyncReplica), + string(ReplicationRoleGeoAsyncReplica), + string(ReplicationRoleNone), + string(ReplicationRolePrimary), + } +} + +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationRole(input string) (*ReplicationRole, error) { + vals := map[string]ReplicationRole{ + "asyncreplica": ReplicationRoleAsyncReplica, + "geoasyncreplica": ReplicationRoleGeoAsyncReplica, + "none": ReplicationRoleNone, + "primary": ReplicationRolePrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationRole(input) + return &out, nil +} + +type ReplicationState string + +const ( + ReplicationStateActive ReplicationState = "Active" + ReplicationStateBroken ReplicationState = "Broken" + ReplicationStateCatchup ReplicationState = "Catchup" + ReplicationStateProvisioning ReplicationState = "Provisioning" + ReplicationStateReconfiguring ReplicationState = "Reconfiguring" + ReplicationStateUpdating ReplicationState = "Updating" +) + +func PossibleValuesForReplicationState() []string { + return []string{ + string(ReplicationStateActive), + string(ReplicationStateBroken), + string(ReplicationStateCatchup), + string(ReplicationStateProvisioning), + string(ReplicationStateReconfiguring), + string(ReplicationStateUpdating), + } +} + +func (s *ReplicationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationState(input string) (*ReplicationState, error) { + vals := map[string]ReplicationState{ + "active": ReplicationStateActive, + "broken": ReplicationStateBroken, + "catchup": ReplicationStateCatchup, + "provisioning": ReplicationStateProvisioning, + "reconfiguring": ReplicationStateReconfiguring, + "updating": ReplicationStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationState(input) + return &out, nil +} + +type ServerHAState string + +const ( + ServerHAStateCreatingStandby ServerHAState = "CreatingStandby" + ServerHAStateFailingOver ServerHAState = "FailingOver" + ServerHAStateHealthy ServerHAState = "Healthy" + ServerHAStateNotEnabled ServerHAState = "NotEnabled" + ServerHAStateRemovingStandby ServerHAState = "RemovingStandby" + ServerHAStateReplicatingData ServerHAState = "ReplicatingData" +) + +func PossibleValuesForServerHAState() []string { + return []string{ + string(ServerHAStateCreatingStandby), + string(ServerHAStateFailingOver), + string(ServerHAStateHealthy), + string(ServerHAStateNotEnabled), + string(ServerHAStateRemovingStandby), + string(ServerHAStateReplicatingData), + } +} + +func (s *ServerHAState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerHAState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerHAState(input string) (*ServerHAState, error) { + vals := map[string]ServerHAState{ + "creatingstandby": ServerHAStateCreatingStandby, + "failingover": ServerHAStateFailingOver, + "healthy": ServerHAStateHealthy, + "notenabled": ServerHAStateNotEnabled, + "removingstandby": ServerHAStateRemovingStandby, + "replicatingdata": ServerHAStateReplicatingData, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerHAState(input) + return &out, nil +} + +type ServerPublicNetworkAccessState string + +const ( + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +func PossibleValuesForServerPublicNetworkAccessState() []string { + return []string{ + string(ServerPublicNetworkAccessStateDisabled), + string(ServerPublicNetworkAccessStateEnabled), + } +} + +func (s *ServerPublicNetworkAccessState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerPublicNetworkAccessState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerPublicNetworkAccessState(input string) (*ServerPublicNetworkAccessState, error) { + vals := map[string]ServerPublicNetworkAccessState{ + "disabled": ServerPublicNetworkAccessStateDisabled, + "enabled": ServerPublicNetworkAccessStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerPublicNetworkAccessState(input) + return &out, nil +} + +type ServerState string + +const ( + ServerStateDisabled ServerState = "Disabled" + ServerStateDropping ServerState = "Dropping" + ServerStateReady ServerState = "Ready" + ServerStateStarting ServerState = "Starting" + ServerStateStopped ServerState = "Stopped" + ServerStateStopping ServerState = "Stopping" + ServerStateUpdating ServerState = "Updating" +) + +func PossibleValuesForServerState() []string { + return []string{ + string(ServerStateDisabled), + string(ServerStateDropping), + string(ServerStateReady), + string(ServerStateStarting), + string(ServerStateStopped), + string(ServerStateStopping), + string(ServerStateUpdating), + } +} + +func (s *ServerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerState(input string) (*ServerState, error) { + vals := map[string]ServerState{ + "disabled": ServerStateDisabled, + "dropping": ServerStateDropping, + "ready": ServerStateReady, + "starting": ServerStateStarting, + "stopped": ServerStateStopped, + "stopping": ServerStateStopping, + "updating": ServerStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerState(input) + return &out, nil +} + +type ServerVersion string + +const ( + ServerVersionOneFive ServerVersion = "15" + ServerVersionOneFour ServerVersion = "14" + ServerVersionOneOne ServerVersion = "11" + ServerVersionOneSix ServerVersion = "16" + ServerVersionOneThree ServerVersion = "13" + ServerVersionOneTwo ServerVersion = "12" +) + +func PossibleValuesForServerVersion() []string { + return []string{ + string(ServerVersionOneFive), + string(ServerVersionOneFour), + string(ServerVersionOneOne), + string(ServerVersionOneSix), + string(ServerVersionOneThree), + string(ServerVersionOneTwo), + } +} + +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerVersion(input string) (*ServerVersion, error) { + vals := map[string]ServerVersion{ + "15": ServerVersionOneFive, + "14": ServerVersionOneFour, + "11": ServerVersionOneOne, + "16": ServerVersionOneSix, + "13": ServerVersionOneThree, + "12": ServerVersionOneTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerVersion(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBurstable SkuTier = "Burstable" + SkuTierGeneralPurpose SkuTier = "GeneralPurpose" + SkuTierMemoryOptimized SkuTier = "MemoryOptimized" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBurstable), + string(SkuTierGeneralPurpose), + string(SkuTierMemoryOptimized), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "burstable": SkuTierBurstable, + "generalpurpose": SkuTierGeneralPurpose, + "memoryoptimized": SkuTierMemoryOptimized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type StorageAutoGrow string + +const ( + StorageAutoGrowDisabled StorageAutoGrow = "Disabled" + StorageAutoGrowEnabled StorageAutoGrow = "Enabled" +) + +func PossibleValuesForStorageAutoGrow() []string { + return []string{ + string(StorageAutoGrowDisabled), + string(StorageAutoGrowEnabled), + } +} + +func (s *StorageAutoGrow) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAutoGrow(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAutoGrow(input string) (*StorageAutoGrow, error) { + vals := map[string]StorageAutoGrow{ + "disabled": StorageAutoGrowDisabled, + "enabled": StorageAutoGrowEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAutoGrow(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypePremiumLRS StorageType = "Premium_LRS" + StorageTypePremiumVTwoLRS StorageType = "PremiumV2_LRS" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypePremiumLRS), + string(StorageTypePremiumVTwoLRS), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "premium_lrs": StorageTypePremiumLRS, + "premiumv2_lrs": StorageTypePremiumVTwoLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver.go new file mode 100644 index 00000000000..de631236f43 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver.go @@ -0,0 +1,130 @@ +package servers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver_test.go new file mode 100644 index 00000000000..7392481e94a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package servers + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/servers/method_create.go b/resource-manager/postgresql/2024-08-01/servers/method_create.go new file mode 100644 index 00000000000..e5340cf8248 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_create.go @@ -0,0 +1,76 @@ +package servers + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Server +} + +// Create ... +func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/servers/method_delete.go b/resource-manager/postgresql/2024-08-01/servers/method_delete.go new file mode 100644 index 00000000000..8f4fee59957 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_delete.go @@ -0,0 +1,71 @@ +package servers + +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 ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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/postgresql/2024-08-01/servers/method_get.go b/resource-manager/postgresql/2024-08-01/servers/method_get.go new file mode 100644 index 00000000000..fea9d5443d8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_get.go @@ -0,0 +1,53 @@ +package servers + +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 *Server +} + +// Get ... +func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (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 + } + + var model Server + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/servers/method_list.go b/resource-manager/postgresql/2024-08-01/servers/method_list.go new file mode 100644 index 00000000000..e288bb76ead --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_list.go @@ -0,0 +1,106 @@ +package servers + +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 *[]Server +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Server +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforPostgreSQL/flexibleServers", 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 *[]Server `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 ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/postgresql/2024-08-01/servers/method_listbyresourcegroup.go b/resource-manager/postgresql/2024-08-01/servers/method_listbyresourcegroup.go new file mode 100644 index 00000000000..f2e980ef6e1 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package servers + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Server +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforPostgreSQL/flexibleServers", 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 *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/servers/method_update.go b/resource-manager/postgresql/2024-08-01/servers/method_update.go new file mode 100644 index 00000000000..78039579848 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/method_update.go @@ -0,0 +1,75 @@ +package servers + +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 + Model *Server +} + +// Update ... +func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (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 ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) 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/postgresql/2024-08-01/servers/model_authconfig.go b/resource-manager/postgresql/2024-08-01/servers/model_authconfig.go new file mode 100644 index 00000000000..82537c38df0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_authconfig.go @@ -0,0 +1,10 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthConfig struct { + ActiveDirectoryAuth *ActiveDirectoryAuthEnum `json:"activeDirectoryAuth,omitempty"` + PasswordAuth *PasswordAuthEnum `json:"passwordAuth,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_backup.go b/resource-manager/postgresql/2024-08-01/servers/model_backup.go new file mode 100644 index 00000000000..94079534357 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_backup.go @@ -0,0 +1,28 @@ +package servers + +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 Backup struct { + BackupRetentionDays *int64 `json:"backupRetentionDays,omitempty"` + EarliestRestoreDate *string `json:"earliestRestoreDate,omitempty"` + GeoRedundantBackup *GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` +} + +func (o *Backup) GetEarliestRestoreDateAsTime() (*time.Time, error) { + if o.EarliestRestoreDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EarliestRestoreDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *Backup) SetEarliestRestoreDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EarliestRestoreDate = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_dataencryption.go b/resource-manager/postgresql/2024-08-01/servers/model_dataencryption.go new file mode 100644 index 00000000000..00229fec775 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_dataencryption.go @@ -0,0 +1,14 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataEncryption struct { + GeoBackupEncryptionKeyStatus *KeyStatusEnum `json:"geoBackupEncryptionKeyStatus,omitempty"` + GeoBackupKeyURI *string `json:"geoBackupKeyURI,omitempty"` + GeoBackupUserAssignedIdentityId *string `json:"geoBackupUserAssignedIdentityId,omitempty"` + PrimaryEncryptionKeyStatus *KeyStatusEnum `json:"primaryEncryptionKeyStatus,omitempty"` + PrimaryKeyURI *string `json:"primaryKeyURI,omitempty"` + PrimaryUserAssignedIdentityId *string `json:"primaryUserAssignedIdentityId,omitempty"` + Type *ArmServerKeyType `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_highavailability.go b/resource-manager/postgresql/2024-08-01/servers/model_highavailability.go new file mode 100644 index 00000000000..76727402318 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_highavailability.go @@ -0,0 +1,10 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailability struct { + Mode *HighAvailabilityMode `json:"mode,omitempty"` + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` + State *ServerHAState `json:"state,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_maintenancewindow.go b/resource-manager/postgresql/2024-08-01/servers/model_maintenancewindow.go new file mode 100644 index 00000000000..e3316db4574 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_maintenancewindow.go @@ -0,0 +1,11 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindow struct { + CustomWindow *string `json:"customWindow,omitempty"` + DayOfWeek *int64 `json:"dayOfWeek,omitempty"` + StartHour *int64 `json:"startHour,omitempty"` + StartMinute *int64 `json:"startMinute,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_network.go b/resource-manager/postgresql/2024-08-01/servers/model_network.go new file mode 100644 index 00000000000..7aeb70fc3a0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_network.go @@ -0,0 +1,10 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Network struct { + DelegatedSubnetResourceId *string `json:"delegatedSubnetResourceId,omitempty"` + PrivateDnsZoneArmResourceId *string `json:"privateDnsZoneArmResourceId,omitempty"` + PublicNetworkAccess *ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_privateendpoint.go b/resource-manager/postgresql/2024-08-01/servers/model_privateendpoint.go new file mode 100644 index 00000000000..edbc5878b03 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_privateendpoint.go @@ -0,0 +1,8 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnection.go b/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnection.go new file mode 100644 index 00000000000..d6ff31c5dad --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package servers + +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 PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnectionproperties.go b/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..ee2ec79f43b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_privatelinkserviceconnectionstate.go b/resource-manager/postgresql/2024-08-01/servers/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..8a2ade12ed8 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_replica.go b/resource-manager/postgresql/2024-08-01/servers/model_replica.go new file mode 100644 index 00000000000..12e298b4893 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_replica.go @@ -0,0 +1,12 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replica struct { + Capacity *int64 `json:"capacity,omitempty"` + PromoteMode *ReadReplicaPromoteMode `json:"promoteMode,omitempty"` + PromoteOption *ReplicationPromoteOption `json:"promoteOption,omitempty"` + ReplicationState *ReplicationState `json:"replicationState,omitempty"` + Role *ReplicationRole `json:"role,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_server.go b/resource-manager/postgresql/2024-08-01/servers/model_server.go new file mode 100644 index 00000000000..bbf3ab9ba4e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_server.go @@ -0,0 +1,21 @@ +package servers + +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 Server struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServerProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go b/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go new file mode 100644 index 00000000000..17611eb8b4b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_serverforupdate.go @@ -0,0 +1,15 @@ +package servers + +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 ServerForUpdate struct { + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Properties *ServerPropertiesForUpdate `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_serverproperties.go b/resource-manager/postgresql/2024-08-01/servers/model_serverproperties.go new file mode 100644 index 00000000000..eb9243f81d3 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_serverproperties.go @@ -0,0 +1,46 @@ +package servers + +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 ServerProperties struct { + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthConfig *AuthConfig `json:"authConfig,omitempty"` + AvailabilityZone *string `json:"availabilityZone,omitempty"` + Backup *Backup `json:"backup,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DataEncryption *DataEncryption `json:"dataEncryption,omitempty"` + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + MinorVersion *string `json:"minorVersion,omitempty"` + Network *Network `json:"network,omitempty"` + PointInTimeUTC *string `json:"pointInTimeUTC,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + Replica *Replica `json:"replica,omitempty"` + ReplicaCapacity *int64 `json:"replicaCapacity,omitempty"` + ReplicationRole *ReplicationRole `json:"replicationRole,omitempty"` + SourceServerResourceId *string `json:"sourceServerResourceId,omitempty"` + State *ServerState `json:"state,omitempty"` + Storage *Storage `json:"storage,omitempty"` + Version *ServerVersion `json:"version,omitempty"` +} + +func (o *ServerProperties) GetPointInTimeUTCAsTime() (*time.Time, error) { + if o.PointInTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PointInTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *ServerProperties) SetPointInTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PointInTimeUTC = &formatted +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_serverpropertiesforupdate.go b/resource-manager/postgresql/2024-08-01/servers/model_serverpropertiesforupdate.go new file mode 100644 index 00000000000..e865ead1b94 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_serverpropertiesforupdate.go @@ -0,0 +1,20 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerPropertiesForUpdate struct { + AdministratorLogin *string `json:"administratorLogin,omitempty"` + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + AuthConfig *AuthConfig `json:"authConfig,omitempty"` + Backup *Backup `json:"backup,omitempty"` + CreateMode *CreateModeForUpdate `json:"createMode,omitempty"` + DataEncryption *DataEncryption `json:"dataEncryption,omitempty"` + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + Network *Network `json:"network,omitempty"` + Replica *Replica `json:"replica,omitempty"` + ReplicationRole *ReplicationRole `json:"replicationRole,omitempty"` + Storage *Storage `json:"storage,omitempty"` + Version *ServerVersion `json:"version,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_sku.go b/resource-manager/postgresql/2024-08-01/servers/model_sku.go new file mode 100644 index 00000000000..6302164cd2e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_sku.go @@ -0,0 +1,9 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name string `json:"name"` + Tier SkuTier `json:"tier"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/model_storage.go b/resource-manager/postgresql/2024-08-01/servers/model_storage.go new file mode 100644 index 00000000000..5bd77807cd4 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/model_storage.go @@ -0,0 +1,13 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Storage struct { + AutoGrow *StorageAutoGrow `json:"autoGrow,omitempty"` + Iops *int64 `json:"iops,omitempty"` + StorageSizeGB *int64 `json:"storageSizeGB,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` + Tier *AzureManagedDiskPerformanceTiers `json:"tier,omitempty"` + Type *StorageType `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/servers/predicates.go b/resource-manager/postgresql/2024-08-01/servers/predicates.go new file mode 100644 index 00000000000..8b49f30ccbe --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/predicates.go @@ -0,0 +1,32 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ServerOperationPredicate) Matches(input Server) 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/postgresql/2024-08-01/servers/version.go b/resource-manager/postgresql/2024-08-01/servers/version.go new file mode 100644 index 00000000000..92a6dea43cd --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/servers/version.go @@ -0,0 +1,10 @@ +package servers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/servers/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/serverstart/client.go b/resource-manager/postgresql/2024-08-01/serverstart/client.go new file mode 100644 index 00000000000..9dbb3fb1350 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstart/client.go @@ -0,0 +1,26 @@ +package serverstart + +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 ServerStartClient struct { + Client *resourcemanager.Client +} + +func NewServerStartClientWithBaseURI(sdkApi sdkEnv.Api) (*ServerStartClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serverstart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStartClient: %+v", err) + } + + return &ServerStartClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver.go new file mode 100644 index 00000000000..00db66b7c48 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver.go @@ -0,0 +1,130 @@ +package serverstart + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver_test.go new file mode 100644 index 00000000000..12ca7a20c49 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstart/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package serverstart + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/serverstart/method_serversstart.go b/resource-manager/postgresql/2024-08-01/serverstart/method_serversstart.go new file mode 100644 index 00000000000..1a899141006 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstart/method_serversstart.go @@ -0,0 +1,70 @@ +package serverstart + +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 ServersStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStart ... +func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// ServersStartThenPoll performs ServersStart then polls until it's completed +func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverstart/version.go b/resource-manager/postgresql/2024-08-01/serverstart/version.go new file mode 100644 index 00000000000..986faf740d5 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstart/version.go @@ -0,0 +1,10 @@ +package serverstart + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serverstart/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/serverstop/client.go b/resource-manager/postgresql/2024-08-01/serverstop/client.go new file mode 100644 index 00000000000..6a321e699a9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstop/client.go @@ -0,0 +1,26 @@ +package serverstop + +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 ServerStopClient struct { + Client *resourcemanager.Client +} + +func NewServerStopClientWithBaseURI(sdkApi sdkEnv.Api) (*ServerStopClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serverstop", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStopClient: %+v", err) + } + + return &ServerStopClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver.go new file mode 100644 index 00000000000..a0530579a5b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver.go @@ -0,0 +1,130 @@ +package serverstop + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver_test.go new file mode 100644 index 00000000000..fddd48472ca --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstop/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package serverstop + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/serverstop/method_serversstop.go b/resource-manager/postgresql/2024-08-01/serverstop/method_serversstop.go new file mode 100644 index 00000000000..d0a3995d65e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstop/method_serversstop.go @@ -0,0 +1,70 @@ +package serverstop + +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 ServersStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStop ... +func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 +} + +// ServersStopThenPoll performs ServersStop then polls until it's completed +func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/serverstop/version.go b/resource-manager/postgresql/2024-08-01/serverstop/version.go new file mode 100644 index 00000000000..e61f97b459b --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/serverstop/version.go @@ -0,0 +1,10 @@ +package serverstop + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serverstop/2024-08-01" +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/README.md b/resource-manager/postgresql/2024-08-01/virtualendpoints/README.md new file mode 100644 index 00000000000..7abc1ca8f6d --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2024-08-01/virtualendpoints` Documentation + +The `virtualendpoints` SDK allows for interaction with Azure Resource Manager `postgresql` (API Version `2024-08-01`). + +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/postgresql/2024-08-01/virtualendpoints" +``` + + +### Client Initialization + +```go +client := virtualendpoints.NewVirtualEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualEndpointsClient.Create` + +```go +ctx := context.TODO() +id := virtualendpoints.NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName") + +payload := virtualendpoints.VirtualEndpointResource{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualEndpointsClient.Delete` + +```go +ctx := context.TODO() +id := virtualendpoints.NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualEndpointsClient.Get` + +```go +ctx := context.TODO() +id := virtualendpoints.NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName") + +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: `VirtualEndpointsClient.ListByServer` + +```go +ctx := context.TODO() +id := virtualendpoints.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + +// alternatively `client.ListByServer(ctx, id)` can be used to do batched pagination +items, err := client.ListByServerComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualEndpointsClient.Update` + +```go +ctx := context.TODO() +id := virtualendpoints.NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName") + +payload := virtualendpoints.VirtualEndpointResourceForPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/client.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/client.go new file mode 100644 index 00000000000..9a36fc79759 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/client.go @@ -0,0 +1,26 @@ +package virtualendpoints + +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 VirtualEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualEndpointsClient: %+v", err) + } + + return &VirtualEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/constants.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/constants.go new file mode 100644 index 00000000000..751ffa8c473 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/constants.go @@ -0,0 +1,48 @@ +package virtualendpoints + +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 VirtualEndpointType string + +const ( + VirtualEndpointTypeReadWrite VirtualEndpointType = "ReadWrite" +) + +func PossibleValuesForVirtualEndpointType() []string { + return []string{ + string(VirtualEndpointTypeReadWrite), + } +} + +func (s *VirtualEndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualEndpointType(input string) (*VirtualEndpointType, error) { + vals := map[string]VirtualEndpointType{ + "readwrite": VirtualEndpointTypeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualEndpointType(input) + return &out, nil +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver.go new file mode 100644 index 00000000000..788ed87f88f --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver.go @@ -0,0 +1,130 @@ +package virtualendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FlexibleServerId{}) +} + +var _ resourceids.ResourceId = &FlexibleServerId{} + +// FlexibleServerId is a struct representing the Resource ID for a Flexible Server +type FlexibleServerId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string +} + +// NewFlexibleServerID returns a new FlexibleServerId struct +func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId { + return FlexibleServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + } +} + +// ParseFlexibleServerID parses 'input' into a FlexibleServerId +func ParseFlexibleServerID(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId +// note: this method should only be used for API response data and not user input +func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlexibleServerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + return nil +} + +// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID +func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flexible Server ID +func (id FlexibleServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID +func (id FlexibleServerId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + } +} + +// String returns a human-readable description of this Flexible Server ID +func (id FlexibleServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + } + return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver_test.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver_test.go new file mode 100644 index 00000000000..8249441574a --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_flexibleserver_test.go @@ -0,0 +1,282 @@ +package virtualendpoints + +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 = &FlexibleServerId{} + +func TestNewFlexibleServerID(t *testing.T) { + id := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } +} + +func TestFormatFlexibleServerID(t *testing.T) { + actual := NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlexibleServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestParseFlexibleServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlexibleServerId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Expected: &FlexibleServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlexibleServerIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + } +} + +func TestSegmentsForFlexibleServerId(t *testing.T) { + segments := FlexibleServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlexibleServerId 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/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint.go new file mode 100644 index 00000000000..f63dd125eda --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint.go @@ -0,0 +1,139 @@ +package virtualendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VirtualEndpointId{}) +} + +var _ resourceids.ResourceId = &VirtualEndpointId{} + +// VirtualEndpointId is a struct representing the Resource ID for a Virtual Endpoint +type VirtualEndpointId struct { + SubscriptionId string + ResourceGroupName string + FlexibleServerName string + VirtualEndpointName string +} + +// NewVirtualEndpointID returns a new VirtualEndpointId struct +func NewVirtualEndpointID(subscriptionId string, resourceGroupName string, flexibleServerName string, virtualEndpointName string) VirtualEndpointId { + return VirtualEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FlexibleServerName: flexibleServerName, + VirtualEndpointName: virtualEndpointName, + } +} + +// ParseVirtualEndpointID parses 'input' into a VirtualEndpointId +func ParseVirtualEndpointID(input string) (*VirtualEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualEndpointIDInsensitively parses 'input' case-insensitively into a VirtualEndpointId +// note: this method should only be used for API response data and not user input +func ParseVirtualEndpointIDInsensitively(input string) (*VirtualEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualEndpointId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input) + } + + if id.VirtualEndpointName, ok = input.Parsed["virtualEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualEndpointName", input) + } + + return nil +} + +// ValidateVirtualEndpointID checks that 'input' can be parsed as a Virtual Endpoint ID +func ValidateVirtualEndpointID(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 := ParseVirtualEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Endpoint ID +func (id VirtualEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforPostgreSQL/flexibleServers/%s/virtualEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName, id.VirtualEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Endpoint ID +func (id VirtualEndpointId) 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("staticMicrosoftDBforPostgreSQL", "Microsoft.DBforPostgreSQL", "Microsoft.DBforPostgreSQL"), + resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"), + resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"), + resourceids.StaticSegment("staticVirtualEndpoints", "virtualEndpoints", "virtualEndpoints"), + resourceids.UserSpecifiedSegment("virtualEndpointName", "virtualEndpointName"), + } +} + +// String returns a human-readable description of this Virtual Endpoint ID +func (id VirtualEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName), + fmt.Sprintf("Virtual Endpoint Name: %q", id.VirtualEndpointName), + } + return fmt.Sprintf("Virtual Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint_test.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint_test.go new file mode 100644 index 00000000000..e90e6c52ad9 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/id_virtualendpoint_test.go @@ -0,0 +1,327 @@ +package virtualendpoints + +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 = &VirtualEndpointId{} + +func TestNewVirtualEndpointID(t *testing.T) { + id := NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName") + + 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.FlexibleServerName != "flexibleServerName" { + t.Fatalf("Expected %q but got %q for Segment 'FlexibleServerName'", id.FlexibleServerName, "flexibleServerName") + } + + if id.VirtualEndpointName != "virtualEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualEndpointName'", id.VirtualEndpointName, "virtualEndpointName") + } +} + +func TestFormatVirtualEndpointID(t *testing.T) { + actual := NewVirtualEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName", "virtualEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualEndpointId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName", + Expected: &VirtualEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + VirtualEndpointName: "virtualEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualEndpointID(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.VirtualEndpointName != v.Expected.VirtualEndpointName { + t.Fatalf("Expected %q but got %q for VirtualEndpointName", v.Expected.VirtualEndpointName, actual.VirtualEndpointName) + } + + } +} + +func TestParseVirtualEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualEndpointId + }{ + { + // 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.DBforPostgreSQL", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/vIrTuAlEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName", + Expected: &VirtualEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FlexibleServerName: "flexibleServerName", + VirtualEndpointName: "virtualEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DBforPostgreSQL/flexibleServers/flexibleServerName/virtualEndpoints/virtualEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/vIrTuAlEnDpOiNtS/vIrTuAlEnDpOiNtNaMe", + Expected: &VirtualEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FlexibleServerName: "fLeXiBlEsErVeRnAmE", + VirtualEndpointName: "vIrTuAlEnDpOiNtNaMe", + }, + }, + { + // 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.dBfOrPoStGrEsQl/fLeXiBlEsErVeRs/fLeXiBlEsErVeRnAmE/vIrTuAlEnDpOiNtS/vIrTuAlEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualEndpointIDInsensitively(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.FlexibleServerName != v.Expected.FlexibleServerName { + t.Fatalf("Expected %q but got %q for FlexibleServerName", v.Expected.FlexibleServerName, actual.FlexibleServerName) + } + + if actual.VirtualEndpointName != v.Expected.VirtualEndpointName { + t.Fatalf("Expected %q but got %q for VirtualEndpointName", v.Expected.VirtualEndpointName, actual.VirtualEndpointName) + } + + } +} + +func TestSegmentsForVirtualEndpointId(t *testing.T) { + segments := VirtualEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualEndpointId 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/postgresql/2024-08-01/virtualendpoints/method_create.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_create.go new file mode 100644 index 00000000000..e1734310b6e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_create.go @@ -0,0 +1,76 @@ +package virtualendpoints + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualEndpointResource +} + +// Create ... +func (c VirtualEndpointsClient) Create(ctx context.Context, id VirtualEndpointId, input VirtualEndpointResource) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c VirtualEndpointsClient) CreateThenPoll(ctx context.Context, id VirtualEndpointId, input VirtualEndpointResource) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/method_delete.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_delete.go new file mode 100644 index 00000000000..e465e5f8fa0 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_delete.go @@ -0,0 +1,70 @@ +package virtualendpoints + +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 VirtualEndpointsClient) Delete(ctx context.Context, id VirtualEndpointId) (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 VirtualEndpointsClient) DeleteThenPoll(ctx context.Context, id VirtualEndpointId) 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/postgresql/2024-08-01/virtualendpoints/method_get.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_get.go new file mode 100644 index 00000000000..06d9bb5fecb --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_get.go @@ -0,0 +1,53 @@ +package virtualendpoints + +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 *VirtualEndpointResource +} + +// Get ... +func (c VirtualEndpointsClient) Get(ctx context.Context, id VirtualEndpointId) (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 + } + + var model VirtualEndpointResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/method_listbyserver.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_listbyserver.go new file mode 100644 index 00000000000..fc806518306 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_listbyserver.go @@ -0,0 +1,105 @@ +package virtualendpoints + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualEndpointResource +} + +type ListByServerCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualEndpointResource +} + +type ListByServerCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServerCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByServer ... +func (c VirtualEndpointsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServerCustomPager{}, + Path: fmt.Sprintf("%s/virtualEndpoints", 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 *[]VirtualEndpointResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c VirtualEndpointsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, VirtualEndpointResourceOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualEndpointsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate VirtualEndpointResourceOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]VirtualEndpointResource, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServerCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/method_update.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_update.go new file mode 100644 index 00000000000..3e6a71684d7 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/method_update.go @@ -0,0 +1,75 @@ +package virtualendpoints + +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 + Model *VirtualEndpointResource +} + +// Update ... +func (c VirtualEndpointsClient) Update(ctx context.Context, id VirtualEndpointId, input VirtualEndpointResourceForPatch) (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 VirtualEndpointsClient) UpdateThenPoll(ctx context.Context, id VirtualEndpointId, input VirtualEndpointResourceForPatch) 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/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresource.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresource.go new file mode 100644 index 00000000000..5924aefac2e --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresource.go @@ -0,0 +1,16 @@ +package virtualendpoints + +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 VirtualEndpointResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualEndpointResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceforpatch.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceforpatch.go new file mode 100644 index 00000000000..141027b0b63 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceforpatch.go @@ -0,0 +1,8 @@ +package virtualendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualEndpointResourceForPatch struct { + Properties *VirtualEndpointResourceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceproperties.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceproperties.go new file mode 100644 index 00000000000..8384fc61746 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/model_virtualendpointresourceproperties.go @@ -0,0 +1,10 @@ +package virtualendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualEndpointResourceProperties struct { + EndpointType *VirtualEndpointType `json:"endpointType,omitempty"` + Members *[]string `json:"members,omitempty"` + VirtualEndpoints *[]string `json:"virtualEndpoints,omitempty"` +} diff --git a/resource-manager/postgresql/2024-08-01/virtualendpoints/predicates.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/predicates.go new file mode 100644 index 00000000000..dd12a082467 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/predicates.go @@ -0,0 +1,27 @@ +package virtualendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualEndpointResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p VirtualEndpointResourceOperationPredicate) Matches(input VirtualEndpointResource) 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/postgresql/2024-08-01/virtualendpoints/version.go b/resource-manager/postgresql/2024-08-01/virtualendpoints/version.go new file mode 100644 index 00000000000..e7bc0b24434 --- /dev/null +++ b/resource-manager/postgresql/2024-08-01/virtualendpoints/version.go @@ -0,0 +1,10 @@ +package virtualendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-08-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualendpoints/2024-08-01" +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/README.md b/resource-manager/search/2024-06-01-preview/adminkeys/README.md new file mode 100644 index 00000000000..82a82a5f648 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/adminkeys` Documentation + +The `adminkeys` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/adminkeys" +``` + + +### Client Initialization + +```go +client := adminkeys.NewAdminKeysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdminKeysClient.Get` + +```go +ctx := context.TODO() +id := adminkeys.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Get(ctx, id, adminkeys.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminKeysClient.Regenerate` + +```go +ctx := context.TODO() +id := adminkeys.NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary") + +read, err := client.Regenerate(ctx, id, adminkeys.DefaultRegenerateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/client.go b/resource-manager/search/2024-06-01-preview/adminkeys/client.go new file mode 100644 index 00000000000..9107624f0f1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/client.go @@ -0,0 +1,26 @@ +package adminkeys + +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 AdminKeysClient struct { + Client *resourcemanager.Client +} + +func NewAdminKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*AdminKeysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "adminkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdminKeysClient: %+v", err) + } + + return &AdminKeysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/constants.go b/resource-manager/search/2024-06-01-preview/adminkeys/constants.go new file mode 100644 index 00000000000..e56b7ce771e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/constants.go @@ -0,0 +1,51 @@ +package adminkeys + +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 AdminKeyKind string + +const ( + AdminKeyKindPrimary AdminKeyKind = "primary" + AdminKeyKindSecondary AdminKeyKind = "secondary" +) + +func PossibleValuesForAdminKeyKind() []string { + return []string{ + string(AdminKeyKindPrimary), + string(AdminKeyKindSecondary), + } +} + +func (s *AdminKeyKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdminKeyKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdminKeyKind(input string) (*AdminKeyKind, error) { + vals := map[string]AdminKeyKind{ + "primary": AdminKeyKindPrimary, + "secondary": AdminKeyKindSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdminKeyKind(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go new file mode 100644 index 00000000000..2d72e49e661 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind.go @@ -0,0 +1,147 @@ +package adminkeys + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&KeyKindId{}) +} + +var _ resourceids.ResourceId = &KeyKindId{} + +// KeyKindId is a struct representing the Resource ID for a Key Kind +type KeyKindId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + KeyKind AdminKeyKind +} + +// NewKeyKindID returns a new KeyKindId struct +func NewKeyKindID(subscriptionId string, resourceGroupName string, searchServiceName string, keyKind AdminKeyKind) KeyKindId { + return KeyKindId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + KeyKind: keyKind, + } +} + +// ParseKeyKindID parses 'input' into a KeyKindId +func ParseKeyKindID(input string) (*KeyKindId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyKindId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyKindId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKeyKindIDInsensitively parses 'input' case-insensitively into a KeyKindId +// note: this method should only be used for API response data and not user input +func ParseKeyKindIDInsensitively(input string) (*KeyKindId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyKindId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyKindId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KeyKindId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if v, ok := input.Parsed["keyKind"]; true { + if !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyKind", input) + } + + keyKind, err := parseAdminKeyKind(v) + if err != nil { + return fmt.Errorf("parsing %q: %+v", v, err) + } + id.KeyKind = *keyKind + } + + return nil +} + +// ValidateKeyKindID checks that 'input' can be parsed as a Key Kind ID +func ValidateKeyKindID(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 := ParseKeyKindID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Key Kind ID +func (id KeyKindId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/regenerateAdminKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, string(id.KeyKind)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Key Kind ID +func (id KeyKindId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticRegenerateAdminKey", "regenerateAdminKey", "regenerateAdminKey"), + resourceids.ConstantSegment("keyKind", PossibleValuesForAdminKeyKind(), "primary"), + } +} + +// String returns a human-readable description of this Key Kind ID +func (id KeyKindId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Key Kind: %q", string(id.KeyKind)), + } + return fmt.Sprintf("Key Kind (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go new file mode 100644 index 00000000000..656c1a2028d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_keykind_test.go @@ -0,0 +1,327 @@ +package adminkeys + +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 = &KeyKindId{} + +func TestNewKeyKindID(t *testing.T) { + id := NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.KeyKind != "primary" { + t.Fatalf("Expected %q but got %q for Segment 'KeyKind'", id.KeyKind, "primary") + } +} + +func TestFormatKeyKindID(t *testing.T) { + actual := NewKeyKindID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "primary").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKeyKindID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyKindId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + KeyKind: "primary", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyKindID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.KeyKind != v.Expected.KeyKind { + t.Fatalf("Expected %q but got %q for KeyKind", v.Expected.KeyKind, actual.KeyKind) + } + + } +} + +func TestParseKeyKindIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyKindId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + KeyKind: "primary", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/regenerateAdminKey/primary/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY/pRiMaRy", + Expected: &KeyKindId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + KeyKind: "primary", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/rEgEnErAtEaDmInKeY/pRiMaRy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyKindIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.KeyKind != v.Expected.KeyKind { + t.Fatalf("Expected %q but got %q for KeyKind", v.Expected.KeyKind, actual.KeyKind) + } + + } +} + +func TestSegmentsForKeyKindId(t *testing.T) { + segments := KeyKindId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KeyKindId 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/search/2024-06-01-preview/adminkeys/id_searchservice.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go new file mode 100644 index 00000000000..d5042de36ef --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice.go @@ -0,0 +1,130 @@ +package adminkeys + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go new file mode 100644 index 00000000000..069f8b63199 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/id_searchservice_test.go @@ -0,0 +1,282 @@ +package adminkeys + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/adminkeys/method_get.go b/resource-manager/search/2024-06-01-preview/adminkeys/method_get.go new file mode 100644 index 00000000000..fde80779fd5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/method_get.go @@ -0,0 +1,83 @@ +package adminkeys + +import ( + "context" + "fmt" + "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 *AdminKeyResult +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c AdminKeysClient) Get(ctx context.Context, id SearchServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/listAdminKeys", 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 + } + + var model AdminKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go b/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go new file mode 100644 index 00000000000..9dc7bd60009 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/method_regenerate.go @@ -0,0 +1,83 @@ +package adminkeys + +import ( + "context" + "fmt" + "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 RegenerateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AdminKeyResult +} + +type RegenerateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultRegenerateOperationOptions() RegenerateOperationOptions { + return RegenerateOperationOptions{} +} + +func (o RegenerateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o RegenerateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegenerateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Regenerate ... +func (c AdminKeysClient) Regenerate(ctx context.Context, id KeyKindId, options RegenerateOperationOptions) (result RegenerateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + 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 + } + + var model AdminKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go b/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go new file mode 100644 index 00000000000..0edd8c79f80 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/model_adminkeyresult.go @@ -0,0 +1,9 @@ +package adminkeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminKeyResult struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/adminkeys/version.go b/resource-manager/search/2024-06-01-preview/adminkeys/version.go new file mode 100644 index 00000000000..af7cd853fda --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/adminkeys/version.go @@ -0,0 +1,10 @@ +package adminkeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/adminkeys/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/client.go b/resource-manager/search/2024-06-01-preview/client.go new file mode 100644 index 00000000000..7326b0f2331 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/client.go @@ -0,0 +1,91 @@ +package v2024_06_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/search/2024-06-01-preview/adminkeys" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/querykeys" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/services" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/usages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AdminKeys *adminkeys.AdminKeysClient + NetworkSecurityPerimeterConfigurations *networksecurityperimeterconfigurations.NetworkSecurityPerimeterConfigurationsClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + QueryKeys *querykeys.QueryKeysClient + Services *services.ServicesClient + SharedPrivateLinkResources *sharedprivatelinkresources.SharedPrivateLinkResourcesClient + Usages *usages.UsagesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + adminKeysClient, err := adminkeys.NewAdminKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AdminKeys client: %+v", err) + } + configureFunc(adminKeysClient.Client) + + networkSecurityPerimeterConfigurationsClient, err := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterConfigurations client: %+v", err) + } + configureFunc(networkSecurityPerimeterConfigurationsClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + queryKeysClient, err := querykeys.NewQueryKeysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building QueryKeys client: %+v", err) + } + configureFunc(queryKeysClient.Client) + + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) + } + configureFunc(servicesClient.Client) + + sharedPrivateLinkResourcesClient, err := sharedprivatelinkresources.NewSharedPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SharedPrivateLinkResources client: %+v", err) + } + configureFunc(sharedPrivateLinkResourcesClient.Client) + + usagesClient, err := usages.NewUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Usages client: %+v", err) + } + configureFunc(usagesClient.Client) + + return &Client{ + AdminKeys: adminKeysClient, + NetworkSecurityPerimeterConfigurations: networkSecurityPerimeterConfigurationsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + QueryKeys: queryKeysClient, + Services: servicesClient, + SharedPrivateLinkResources: sharedPrivateLinkResourcesClient, + Usages: usagesClient, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md new file mode 100644 index 00000000000..c6e88d7e15f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations` Documentation + +The `networksecurityperimeterconfigurations` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/networksecurityperimeterconfigurations" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + +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: `NetworkSecurityPerimeterConfigurationsClient.ListByService` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id)` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimeterConfigurationsClient.Reconcile` + +```go +ctx := context.TODO() +id := networksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + +if err := client.ReconcileThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go new file mode 100644 index 00000000000..20530b9e06a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterconfigurations + +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 NetworkSecurityPerimeterConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterConfigurationsClient: %+v", err) + } + + return &NetworkSecurityPerimeterConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go new file mode 100644 index 00000000000..171bb79a10f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration.go @@ -0,0 +1,139 @@ +package networksecurityperimeterconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterConfigurationId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterConfigurationId{} + +// NetworkSecurityPerimeterConfigurationId is a struct representing the Resource ID for a Network Security Perimeter Configuration +type NetworkSecurityPerimeterConfigurationId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + NetworkSecurityPerimeterConfigurationName string +} + +// NewNetworkSecurityPerimeterConfigurationID returns a new NetworkSecurityPerimeterConfigurationId struct +func NewNetworkSecurityPerimeterConfigurationID(subscriptionId string, resourceGroupName string, searchServiceName string, networkSecurityPerimeterConfigurationName string) NetworkSecurityPerimeterConfigurationId { + return NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + NetworkSecurityPerimeterConfigurationName: networkSecurityPerimeterConfigurationName, + } +} + +// ParseNetworkSecurityPerimeterConfigurationID parses 'input' into a NetworkSecurityPerimeterConfigurationId +func ParseNetworkSecurityPerimeterConfigurationID(input string) (*NetworkSecurityPerimeterConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterConfigurationIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterConfigurationId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterConfigurationIDInsensitively(input string) (*NetworkSecurityPerimeterConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterConfigurationId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.NetworkSecurityPerimeterConfigurationName, ok = input.Parsed["networkSecurityPerimeterConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterConfigurationName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterConfigurationID checks that 'input' can be parsed as a Network Security Perimeter Configuration ID +func ValidateNetworkSecurityPerimeterConfigurationID(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 := ParseNetworkSecurityPerimeterConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/networkSecurityPerimeterConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.NetworkSecurityPerimeterConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticNetworkSecurityPerimeterConfigurations", "networkSecurityPerimeterConfigurations", "networkSecurityPerimeterConfigurations"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterConfigurationName", "networkSecurityPerimeterConfigurationName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter Configuration ID +func (id NetworkSecurityPerimeterConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Network Security Perimeter Configuration Name: %q", id.NetworkSecurityPerimeterConfigurationName), + } + return fmt.Sprintf("Network Security Perimeter Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go new file mode 100644 index 00000000000..5c8779f2ef4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_networksecurityperimeterconfiguration_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterconfigurations + +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 = &NetworkSecurityPerimeterConfigurationId{} + +func TestNewNetworkSecurityPerimeterConfigurationID(t *testing.T) { + id := NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.NetworkSecurityPerimeterConfigurationName != "networkSecurityPerimeterConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterConfigurationName'", id.NetworkSecurityPerimeterConfigurationName, "networkSecurityPerimeterConfigurationName") + } +} + +func TestFormatNetworkSecurityPerimeterConfigurationID(t *testing.T) { + actual := NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "networkSecurityPerimeterConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterConfigurationId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + NetworkSecurityPerimeterConfigurationName: "networkSecurityPerimeterConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterConfigurationID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.NetworkSecurityPerimeterConfigurationName != v.Expected.NetworkSecurityPerimeterConfigurationName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterConfigurationName", v.Expected.NetworkSecurityPerimeterConfigurationName, actual.NetworkSecurityPerimeterConfigurationName) + } + + } +} + +func TestParseNetworkSecurityPerimeterConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterConfigurationId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + NetworkSecurityPerimeterConfigurationName: "networkSecurityPerimeterConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/networkSecurityPerimeterConfigurations/networkSecurityPerimeterConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe", + Expected: &NetworkSecurityPerimeterConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + NetworkSecurityPerimeterConfigurationName: "nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnS/nEtWoRkSeCuRiTyPeRiMeTeRcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterConfigurationIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.NetworkSecurityPerimeterConfigurationName != v.Expected.NetworkSecurityPerimeterConfigurationName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterConfigurationName", v.Expected.NetworkSecurityPerimeterConfigurationName, actual.NetworkSecurityPerimeterConfigurationName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterConfigurationId(t *testing.T) { + segments := NetworkSecurityPerimeterConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterConfigurationId 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/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go new file mode 100644 index 00000000000..3013fe00c26 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice.go @@ -0,0 +1,130 @@ +package networksecurityperimeterconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go new file mode 100644 index 00000000000..80787fc0333 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/id_searchservice_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterconfigurations + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go new file mode 100644 index 00000000000..ff7885e0a3d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterconfigurations + +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 *NetworkSecurityPerimeterConfiguration +} + +// Get ... +func (c NetworkSecurityPerimeterConfigurationsClient) Get(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) (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 + } + + var model NetworkSecurityPerimeterConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go new file mode 100644 index 00000000000..efd3fd70917 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_listbyservice.go @@ -0,0 +1,105 @@ +package networksecurityperimeterconfigurations + +import ( + "context" + "fmt" + "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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityPerimeterConfiguration +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityPerimeterConfiguration +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c NetworkSecurityPerimeterConfigurationsClient) ListByService(ctx context.Context, id SearchServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/networkSecurityPerimeterConfigurations", 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 *[]NetworkSecurityPerimeterConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterConfigurationsClient) ListByServiceComplete(ctx context.Context, id SearchServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, NetworkSecurityPerimeterConfigurationOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterConfigurationsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, predicate NetworkSecurityPerimeterConfigurationOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NetworkSecurityPerimeterConfiguration, 0) + + resp, err := c.ListByService(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go new file mode 100644 index 00000000000..45935ee0f4b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/method_reconcile.go @@ -0,0 +1,69 @@ +package networksecurityperimeterconfigurations + +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 ReconcileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Reconcile ... +func (c NetworkSecurityPerimeterConfigurationsClient) Reconcile(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) (result ReconcileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconcile", 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 +} + +// ReconcileThenPoll performs Reconcile then polls until it's completed +func (c NetworkSecurityPerimeterConfigurationsClient) ReconcileThenPoll(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) error { + result, err := c.Reconcile(ctx, id) + if err != nil { + return fmt.Errorf("performing Reconcile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reconcile: %+v", err) + } + + return nil +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go new file mode 100644 index 00000000000..44c20a00fad --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfiguration.go @@ -0,0 +1,11 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityPerimeterConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go new file mode 100644 index 00000000000..bbb025c967f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_networksecurityperimeterconfigurationproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfigurationProperties struct { + NetworkSecurityPerimeter *NSPConfigPerimeter `json:"networkSecurityPerimeter,omitempty"` + Profile *NSPConfigProfile `json:"profile,omitempty"` + ProvisioningIssues *[]NSPProvisioningIssue `json:"provisioningIssues,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceAssociation *NSPConfigAssociation `json:"resourceAssociation,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go new file mode 100644 index 00000000000..0b853ab1da5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessrule.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAccessRule struct { + Name *string `json:"name,omitempty"` + Properties *NSPConfigAccessRuleProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go new file mode 100644 index 00000000000..503a9df5f0c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigaccessruleproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAccessRuleProperties struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Direction *string `json:"direction,omitempty"` + FullyQualifiedDomainNames *[]string `json:"fullyQualifiedDomainNames,omitempty"` + NetworkSecurityPerimeters *[]NSPConfigNetworkSecurityPerimeterRule `json:"networkSecurityPerimeters,omitempty"` + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go new file mode 100644 index 00000000000..0322378c71b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigassociation.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigAssociation struct { + AccessMode *string `json:"accessMode,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go new file mode 100644 index 00000000000..c529b35b6bb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfignetworksecurityperimeterrule.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigNetworkSecurityPerimeterRule struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + PerimeterGuid *string `json:"perimeterGuid,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go new file mode 100644 index 00000000000..245acf0922b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigperimeter.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigPerimeter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + PerimeterGuid *string `json:"perimeterGuid,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go new file mode 100644 index 00000000000..91e4365d818 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspconfigprofile.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPConfigProfile struct { + AccessRules *[]NSPConfigAccessRule `json:"accessRules,omitempty"` + AccessRulesVersion *string `json:"accessRulesVersion,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go new file mode 100644 index 00000000000..522a879dcd9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissue.go @@ -0,0 +1,9 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPProvisioningIssue struct { + Name *string `json:"name,omitempty"` + Properties *NSPProvisioningIssueProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go new file mode 100644 index 00000000000..9d59f8ebd6b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/model_nspprovisioningissueproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NSPProvisioningIssueProperties struct { + Description *string `json:"description,omitempty"` + IssueType *string `json:"issueType,omitempty"` + Severity *string `json:"severity,omitempty"` + SuggestedAccessRules *[]string `json:"suggestedAccessRules,omitempty"` + SuggestedResourceIds *[]string `json:"suggestedResourceIds,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go new file mode 100644 index 00000000000..fd3dce574e9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NetworkSecurityPerimeterConfigurationOperationPredicate) Matches(input NetworkSecurityPerimeterConfiguration) 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/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go new file mode 100644 index 00000000000..100b2a2dacd --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/networksecurityperimeterconfigurations/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterconfigurations/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md b/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md new file mode 100644 index 00000000000..453fe88c03f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +read, err := client.Delete(ctx, id, privateendpointconnections.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +read, err := client.Get(ctx, id, privateendpointconnections.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.ListByService` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id, privateendpointconnections.DefaultListByServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id, privateendpointconnections.DefaultListByServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Update` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +read, err := client.Update(ctx, id, payload, privateendpointconnections.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go new file mode 100644 index 00000000000..0a2ffc9b8d9 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/constants.go @@ -0,0 +1,110 @@ +package privateendpointconnections + +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 PrivateLinkServiceConnectionProvisioningState string + +const ( + PrivateLinkServiceConnectionProvisioningStateCanceled PrivateLinkServiceConnectionProvisioningState = "Canceled" + PrivateLinkServiceConnectionProvisioningStateDeleting PrivateLinkServiceConnectionProvisioningState = "Deleting" + PrivateLinkServiceConnectionProvisioningStateFailed PrivateLinkServiceConnectionProvisioningState = "Failed" + PrivateLinkServiceConnectionProvisioningStateIncomplete PrivateLinkServiceConnectionProvisioningState = "Incomplete" + PrivateLinkServiceConnectionProvisioningStateSucceeded PrivateLinkServiceConnectionProvisioningState = "Succeeded" + PrivateLinkServiceConnectionProvisioningStateUpdating PrivateLinkServiceConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateLinkServiceConnectionProvisioningState() []string { + return []string{ + string(PrivateLinkServiceConnectionProvisioningStateCanceled), + string(PrivateLinkServiceConnectionProvisioningStateDeleting), + string(PrivateLinkServiceConnectionProvisioningStateFailed), + string(PrivateLinkServiceConnectionProvisioningStateIncomplete), + string(PrivateLinkServiceConnectionProvisioningStateSucceeded), + string(PrivateLinkServiceConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateLinkServiceConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionProvisioningState(input string) (*PrivateLinkServiceConnectionProvisioningState, error) { + vals := map[string]PrivateLinkServiceConnectionProvisioningState{ + "canceled": PrivateLinkServiceConnectionProvisioningStateCanceled, + "deleting": PrivateLinkServiceConnectionProvisioningStateDeleting, + "failed": PrivateLinkServiceConnectionProvisioningStateFailed, + "incomplete": PrivateLinkServiceConnectionProvisioningStateIncomplete, + "succeeded": PrivateLinkServiceConnectionProvisioningStateSucceeded, + "updating": PrivateLinkServiceConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..ff4fba73a97 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, searchServiceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..22e24206c7e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId 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/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go new file mode 100644 index 00000000000..61264f6abdc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go new file mode 100644 index 00000000000..f4e029064ff --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/id_searchservice_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/privateendpointconnections/method_delete.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..f9336461111 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_delete.go @@ -0,0 +1,83 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..a1dba5099b0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_get.go @@ -0,0 +1,83 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 *PrivateEndpointConnection +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go new file mode 100644 index 00000000000..141beda1427 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_listbyservice.go @@ -0,0 +1,134 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type ListByServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionsClient) ListByServiceComplete(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions, predicate PrivateEndpointConnectionOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go new file mode 100644 index 00000000000..26bcf2eb73c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/method_update.go @@ -0,0 +1,87 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type UpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PrivateEndpointConnectionsClient) Update(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..fde7f4db0fc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..a58a78d8b1f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateLinkServiceConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go new file mode 100644 index 00000000000..f4bbf6f4340 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..b3208efc0df --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go new file mode 100644 index 00000000000..4a03a91ce52 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/predicates.go @@ -0,0 +1,27 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) 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/search/2024-06-01-preview/privateendpointconnections/version.go b/resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go new file mode 100644 index 00000000000..0c94b8af129 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privateendpointconnections/version.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md b/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md new file mode 100644 index 00000000000..20f7029ee4c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.ListSupported` + +```go +ctx := context.TODO() +id := privatelinkresources.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.ListSupported(ctx, id, privatelinkresources.DefaultListSupportedOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +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 PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go new file mode 100644 index 00000000000..05eaeb7a093 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice.go @@ -0,0 +1,130 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go new file mode 100644 index 00000000000..02832b94794 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/id_searchservice_test.go @@ -0,0 +1,282 @@ +package privatelinkresources + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/privatelinkresources/method_listsupported.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go new file mode 100644 index 00000000000..51995458025 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/method_listsupported.go @@ -0,0 +1,83 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "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 ListSupportedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesResult +} + +type ListSupportedOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListSupportedOperationOptions() ListSupportedOperationOptions { + return ListSupportedOperationOptions{} +} + +func (o ListSupportedOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListSupportedOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListSupportedOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ListSupported ... +func (c PrivateLinkResourcesClient) ListSupported(ctx context.Context, id SearchServiceId, options ListSupportedOperationOptions) (result ListSupportedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/privateLinkResources", 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 + } + + var model PrivateLinkResourcesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..69e8ae0e57a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..dbfb1c5c59e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go new file mode 100644 index 00000000000..bf82201cbe6 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_privatelinkresourcesresult.go @@ -0,0 +1,8 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go new file mode 100644 index 00000000000..ce815b56d20 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceProperties struct { + Description *string `json:"description,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go new file mode 100644 index 00000000000..cf05c08fe62 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/model_shareableprivatelinkresourcetype.go @@ -0,0 +1,9 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ShareablePrivateLinkResourceType struct { + Name *string `json:"name,omitempty"` + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go b/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go new file mode 100644 index 00000000000..33bc8724a14 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/privatelinkresources/version.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/README.md b/resource-manager/search/2024-06-01-preview/querykeys/README.md new file mode 100644 index 00000000000..5e1b629c4cc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/querykeys` Documentation + +The `querykeys` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/querykeys" +``` + + +### Client Initialization + +```go +client := querykeys.NewQueryKeysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueryKeysClient.Create` + +```go +ctx := context.TODO() +id := querykeys.NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName") + +read, err := client.Create(ctx, id, querykeys.DefaultCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryKeysClient.Delete` + +```go +ctx := context.TODO() +id := querykeys.NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName") + +read, err := client.Delete(ctx, id, querykeys.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueryKeysClient.ListBySearchService` + +```go +ctx := context.TODO() +id := querykeys.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListBySearchService(ctx, id, querykeys.DefaultListBySearchServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListBySearchServiceComplete(ctx, id, querykeys.DefaultListBySearchServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/search/2024-06-01-preview/querykeys/client.go b/resource-manager/search/2024-06-01-preview/querykeys/client.go new file mode 100644 index 00000000000..225c811f3d8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/client.go @@ -0,0 +1,26 @@ +package querykeys + +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 QueryKeysClient struct { + Client *resourcemanager.Client +} + +func NewQueryKeysClientWithBaseURI(sdkApi sdkEnv.Api) (*QueryKeysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "querykeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QueryKeysClient: %+v", err) + } + + return &QueryKeysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go new file mode 100644 index 00000000000..dc859a9cb10 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey.go @@ -0,0 +1,139 @@ +package querykeys + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CreateQueryKeyId{}) +} + +var _ resourceids.ResourceId = &CreateQueryKeyId{} + +// CreateQueryKeyId is a struct representing the Resource ID for a Create Query Key +type CreateQueryKeyId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + CreateQueryKeyName string +} + +// NewCreateQueryKeyID returns a new CreateQueryKeyId struct +func NewCreateQueryKeyID(subscriptionId string, resourceGroupName string, searchServiceName string, createQueryKeyName string) CreateQueryKeyId { + return CreateQueryKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + CreateQueryKeyName: createQueryKeyName, + } +} + +// ParseCreateQueryKeyID parses 'input' into a CreateQueryKeyId +func ParseCreateQueryKeyID(input string) (*CreateQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CreateQueryKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CreateQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCreateQueryKeyIDInsensitively parses 'input' case-insensitively into a CreateQueryKeyId +// note: this method should only be used for API response data and not user input +func ParseCreateQueryKeyIDInsensitively(input string) (*CreateQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&CreateQueryKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CreateQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CreateQueryKeyId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.CreateQueryKeyName, ok = input.Parsed["createQueryKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "createQueryKeyName", input) + } + + return nil +} + +// ValidateCreateQueryKeyID checks that 'input' can be parsed as a Create Query Key ID +func ValidateCreateQueryKeyID(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 := ParseCreateQueryKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Create Query Key ID +func (id CreateQueryKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/createQueryKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.CreateQueryKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Create Query Key ID +func (id CreateQueryKeyId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticCreateQueryKey", "createQueryKey", "createQueryKey"), + resourceids.UserSpecifiedSegment("createQueryKeyName", "createQueryKeyName"), + } +} + +// String returns a human-readable description of this Create Query Key ID +func (id CreateQueryKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Create Query Key Name: %q", id.CreateQueryKeyName), + } + return fmt.Sprintf("Create Query Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go new file mode 100644 index 00000000000..4aea4df9f15 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_createquerykey_test.go @@ -0,0 +1,327 @@ +package querykeys + +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 = &CreateQueryKeyId{} + +func TestNewCreateQueryKeyID(t *testing.T) { + id := NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.CreateQueryKeyName != "createQueryKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'CreateQueryKeyName'", id.CreateQueryKeyName, "createQueryKeyName") + } +} + +func TestFormatCreateQueryKeyID(t *testing.T) { + actual := NewCreateQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "createQueryKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCreateQueryKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CreateQueryKeyId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + CreateQueryKeyName: "createQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCreateQueryKeyID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.CreateQueryKeyName != v.Expected.CreateQueryKeyName { + t.Fatalf("Expected %q but got %q for CreateQueryKeyName", v.Expected.CreateQueryKeyName, actual.CreateQueryKeyName) + } + + } +} + +func TestParseCreateQueryKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CreateQueryKeyId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + CreateQueryKeyName: "createQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/createQueryKey/createQueryKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY/cReAtEqUeRyKeYnAmE", + Expected: &CreateQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + CreateQueryKeyName: "cReAtEqUeRyKeYnAmE", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/cReAtEqUeRyKeY/cReAtEqUeRyKeYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCreateQueryKeyIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.CreateQueryKeyName != v.Expected.CreateQueryKeyName { + t.Fatalf("Expected %q but got %q for CreateQueryKeyName", v.Expected.CreateQueryKeyName, actual.CreateQueryKeyName) + } + + } +} + +func TestSegmentsForCreateQueryKeyId(t *testing.T) { + segments := CreateQueryKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CreateQueryKeyId 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/search/2024-06-01-preview/querykeys/id_deletequerykey.go b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go new file mode 100644 index 00000000000..2d538c92b2e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey.go @@ -0,0 +1,139 @@ +package querykeys + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DeleteQueryKeyId{}) +} + +var _ resourceids.ResourceId = &DeleteQueryKeyId{} + +// DeleteQueryKeyId is a struct representing the Resource ID for a Delete Query Key +type DeleteQueryKeyId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + DeleteQueryKeyName string +} + +// NewDeleteQueryKeyID returns a new DeleteQueryKeyId struct +func NewDeleteQueryKeyID(subscriptionId string, resourceGroupName string, searchServiceName string, deleteQueryKeyName string) DeleteQueryKeyId { + return DeleteQueryKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + DeleteQueryKeyName: deleteQueryKeyName, + } +} + +// ParseDeleteQueryKeyID parses 'input' into a DeleteQueryKeyId +func ParseDeleteQueryKeyID(input string) (*DeleteQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteQueryKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeleteQueryKeyIDInsensitively parses 'input' case-insensitively into a DeleteQueryKeyId +// note: this method should only be used for API response data and not user input +func ParseDeleteQueryKeyIDInsensitively(input string) (*DeleteQueryKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteQueryKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteQueryKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeleteQueryKeyId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.DeleteQueryKeyName, ok = input.Parsed["deleteQueryKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deleteQueryKeyName", input) + } + + return nil +} + +// ValidateDeleteQueryKeyID checks that 'input' can be parsed as a Delete Query Key ID +func ValidateDeleteQueryKeyID(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 := ParseDeleteQueryKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Delete Query Key ID +func (id DeleteQueryKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/deleteQueryKey/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.DeleteQueryKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Delete Query Key ID +func (id DeleteQueryKeyId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticDeleteQueryKey", "deleteQueryKey", "deleteQueryKey"), + resourceids.UserSpecifiedSegment("deleteQueryKeyName", "deleteQueryKeyName"), + } +} + +// String returns a human-readable description of this Delete Query Key ID +func (id DeleteQueryKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Delete Query Key Name: %q", id.DeleteQueryKeyName), + } + return fmt.Sprintf("Delete Query Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go new file mode 100644 index 00000000000..a52be96e5e7 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_deletequerykey_test.go @@ -0,0 +1,327 @@ +package querykeys + +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 = &DeleteQueryKeyId{} + +func TestNewDeleteQueryKeyID(t *testing.T) { + id := NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.DeleteQueryKeyName != "deleteQueryKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'DeleteQueryKeyName'", id.DeleteQueryKeyName, "deleteQueryKeyName") + } +} + +func TestFormatDeleteQueryKeyID(t *testing.T) { + actual := NewDeleteQueryKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "deleteQueryKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeleteQueryKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteQueryKeyId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + DeleteQueryKeyName: "deleteQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteQueryKeyID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.DeleteQueryKeyName != v.Expected.DeleteQueryKeyName { + t.Fatalf("Expected %q but got %q for DeleteQueryKeyName", v.Expected.DeleteQueryKeyName, actual.DeleteQueryKeyName) + } + + } +} + +func TestParseDeleteQueryKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteQueryKeyId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + DeleteQueryKeyName: "deleteQueryKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/deleteQueryKey/deleteQueryKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY/dElEtEqUeRyKeYnAmE", + Expected: &DeleteQueryKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + DeleteQueryKeyName: "dElEtEqUeRyKeYnAmE", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/dElEtEqUeRyKeY/dElEtEqUeRyKeYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteQueryKeyIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.DeleteQueryKeyName != v.Expected.DeleteQueryKeyName { + t.Fatalf("Expected %q but got %q for DeleteQueryKeyName", v.Expected.DeleteQueryKeyName, actual.DeleteQueryKeyName) + } + + } +} + +func TestSegmentsForDeleteQueryKeyId(t *testing.T) { + segments := DeleteQueryKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeleteQueryKeyId 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/search/2024-06-01-preview/querykeys/id_searchservice.go b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go new file mode 100644 index 00000000000..b68e0c91044 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice.go @@ -0,0 +1,130 @@ +package querykeys + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go new file mode 100644 index 00000000000..6b08f4b6112 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/id_searchservice_test.go @@ -0,0 +1,282 @@ +package querykeys + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/querykeys/method_create.go b/resource-manager/search/2024-06-01-preview/querykeys/method_create.go new file mode 100644 index 00000000000..017b1da6e06 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_create.go @@ -0,0 +1,83 @@ +package querykeys + +import ( + "context" + "fmt" + "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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QueryKey +} + +type CreateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c QueryKeysClient) Create(ctx context.Context, id CreateQueryKeyId, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + 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 + } + + var model QueryKey + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go b/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go new file mode 100644 index 00000000000..6b83eb0df5d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_delete.go @@ -0,0 +1,77 @@ +package querykeys + +import ( + "context" + "fmt" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c QueryKeysClient) Delete(ctx context.Context, id DeleteQueryKeyId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go b/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go new file mode 100644 index 00000000000..7419a6cdd95 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/method_listbysearchservice.go @@ -0,0 +1,134 @@ +package querykeys + +import ( + "context" + "fmt" + "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 ListBySearchServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]QueryKey +} + +type ListBySearchServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []QueryKey +} + +type ListBySearchServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySearchServiceOperationOptions() ListBySearchServiceOperationOptions { + return ListBySearchServiceOperationOptions{} +} + +func (o ListBySearchServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySearchServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySearchServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySearchServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySearchServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySearchService ... +func (c QueryKeysClient) ListBySearchService(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions) (result ListBySearchServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListBySearchServiceCustomPager{}, + Path: fmt.Sprintf("%s/listQueryKeys", 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 *[]QueryKey `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySearchServiceComplete retrieves all the results into a single object +func (c QueryKeysClient) ListBySearchServiceComplete(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions) (ListBySearchServiceCompleteResult, error) { + return c.ListBySearchServiceCompleteMatchingPredicate(ctx, id, options, QueryKeyOperationPredicate{}) +} + +// ListBySearchServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QueryKeysClient) ListBySearchServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListBySearchServiceOperationOptions, predicate QueryKeyOperationPredicate) (result ListBySearchServiceCompleteResult, err error) { + items := make([]QueryKey, 0) + + resp, err := c.ListBySearchService(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySearchServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go b/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go new file mode 100644 index 00000000000..e326c22a5fa --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/model_querykey.go @@ -0,0 +1,9 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryKey struct { + Key *string `json:"key,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/predicates.go b/resource-manager/search/2024-06-01-preview/querykeys/predicates.go new file mode 100644 index 00000000000..6287d6738be --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/predicates.go @@ -0,0 +1,22 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryKeyOperationPredicate struct { + Key *string + Name *string +} + +func (p QueryKeyOperationPredicate) Matches(input QueryKey) bool { + + if p.Key != nil && (input.Key == nil || *p.Key != *input.Key) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/search/2024-06-01-preview/querykeys/version.go b/resource-manager/search/2024-06-01-preview/querykeys/version.go new file mode 100644 index 00000000000..39441cc58a7 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/querykeys/version.go @@ -0,0 +1,10 @@ +package querykeys + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/querykeys/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/services/README.md b/resource-manager/search/2024-06-01-preview/services/README.md new file mode 100644 index 00000000000..3b6ee6af048 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/README.md @@ -0,0 +1,146 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/services` Documentation + +The `services` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/services" +``` + + +### Client Initialization + +```go +client := services.NewServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServicesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := services.CheckNameAvailabilityInput{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload, services.DefaultCheckNameAvailabilityOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +payload := services.SearchService{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, services.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServicesClient.Delete` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Delete(ctx, id, services.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.Get` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +read, err := client.Get(ctx, id, services.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServicesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, services.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, services.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServicesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, services.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, services.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServicesClient.Update` + +```go +ctx := context.TODO() +id := services.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +payload := services.SearchServiceUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload, services.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/services/client.go b/resource-manager/search/2024-06-01-preview/services/client.go new file mode 100644 index 00000000000..24dd876692e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/client.go @@ -0,0 +1,26 @@ +package services + +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 ServicesClient struct { + Client *resourcemanager.Client +} + +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) + } + + return &ServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/services/constants.go b/resource-manager/search/2024-06-01-preview/services/constants.go new file mode 100644 index 00000000000..681344f8fba --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/constants.go @@ -0,0 +1,776 @@ +package services + +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 AadAuthFailureMode string + +const ( + AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge AadAuthFailureMode = "http401WithBearerChallenge" + AadAuthFailureModeHTTPFourZeroThree AadAuthFailureMode = "http403" +) + +func PossibleValuesForAadAuthFailureMode() []string { + return []string{ + string(AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge), + string(AadAuthFailureModeHTTPFourZeroThree), + } +} + +func (s *AadAuthFailureMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAadAuthFailureMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAadAuthFailureMode(input string) (*AadAuthFailureMode, error) { + vals := map[string]AadAuthFailureMode{ + "http401withbearerchallenge": AadAuthFailureModeHTTPFourZeroOneWithBearerChallenge, + "http403": AadAuthFailureModeHTTPFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AadAuthFailureMode(input) + return &out, nil +} + +type HostingMode string + +const ( + HostingModeDefault HostingMode = "default" + HostingModeHighDensity HostingMode = "highDensity" +) + +func PossibleValuesForHostingMode() []string { + return []string{ + string(HostingModeDefault), + string(HostingModeHighDensity), + } +} + +func (s *HostingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingMode(input string) (*HostingMode, error) { + vals := map[string]HostingMode{ + "default": HostingModeDefault, + "highdensity": HostingModeHighDensity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingMode(input) + return &out, nil +} + +type PrivateLinkServiceConnectionProvisioningState string + +const ( + PrivateLinkServiceConnectionProvisioningStateCanceled PrivateLinkServiceConnectionProvisioningState = "Canceled" + PrivateLinkServiceConnectionProvisioningStateDeleting PrivateLinkServiceConnectionProvisioningState = "Deleting" + PrivateLinkServiceConnectionProvisioningStateFailed PrivateLinkServiceConnectionProvisioningState = "Failed" + PrivateLinkServiceConnectionProvisioningStateIncomplete PrivateLinkServiceConnectionProvisioningState = "Incomplete" + PrivateLinkServiceConnectionProvisioningStateSucceeded PrivateLinkServiceConnectionProvisioningState = "Succeeded" + PrivateLinkServiceConnectionProvisioningStateUpdating PrivateLinkServiceConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateLinkServiceConnectionProvisioningState() []string { + return []string{ + string(PrivateLinkServiceConnectionProvisioningStateCanceled), + string(PrivateLinkServiceConnectionProvisioningStateDeleting), + string(PrivateLinkServiceConnectionProvisioningStateFailed), + string(PrivateLinkServiceConnectionProvisioningStateIncomplete), + string(PrivateLinkServiceConnectionProvisioningStateSucceeded), + string(PrivateLinkServiceConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateLinkServiceConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionProvisioningState(input string) (*PrivateLinkServiceConnectionProvisioningState, error) { + vals := map[string]PrivateLinkServiceConnectionProvisioningState{ + "canceled": PrivateLinkServiceConnectionProvisioningStateCanceled, + "deleting": PrivateLinkServiceConnectionProvisioningStateDeleting, + "failed": PrivateLinkServiceConnectionProvisioningStateFailed, + "incomplete": PrivateLinkServiceConnectionProvisioningStateIncomplete, + "succeeded": PrivateLinkServiceConnectionProvisioningStateSucceeded, + "updating": PrivateLinkServiceConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type ResourceType string + +const ( + ResourceTypeSearchServices ResourceType = "searchServices" +) + +func PossibleValuesForResourceType() []string { + return []string{ + string(ResourceTypeSearchServices), + } +} + +func (s *ResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceType(input string) (*ResourceType, error) { + vals := map[string]ResourceType{ + "searchservices": ResourceTypeSearchServices, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceType(input) + return &out, nil +} + +type SearchBypass string + +const ( + SearchBypassAzurePortal SearchBypass = "AzurePortal" + SearchBypassAzureServices SearchBypass = "AzureServices" + SearchBypassNone SearchBypass = "None" +) + +func PossibleValuesForSearchBypass() []string { + return []string{ + string(SearchBypassAzurePortal), + string(SearchBypassAzureServices), + string(SearchBypassNone), + } +} + +func (s *SearchBypass) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchBypass(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchBypass(input string) (*SearchBypass, error) { + vals := map[string]SearchBypass{ + "azureportal": SearchBypassAzurePortal, + "azureservices": SearchBypassAzureServices, + "none": SearchBypassNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchBypass(input) + return &out, nil +} + +type SearchDisabledDataExfiltrationOption string + +const ( + SearchDisabledDataExfiltrationOptionAll SearchDisabledDataExfiltrationOption = "All" +) + +func PossibleValuesForSearchDisabledDataExfiltrationOption() []string { + return []string{ + string(SearchDisabledDataExfiltrationOptionAll), + } +} + +func (s *SearchDisabledDataExfiltrationOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchDisabledDataExfiltrationOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchDisabledDataExfiltrationOption(input string) (*SearchDisabledDataExfiltrationOption, error) { + vals := map[string]SearchDisabledDataExfiltrationOption{ + "all": SearchDisabledDataExfiltrationOptionAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchDisabledDataExfiltrationOption(input) + return &out, nil +} + +type SearchEncryptionComplianceStatus string + +const ( + SearchEncryptionComplianceStatusCompliant SearchEncryptionComplianceStatus = "Compliant" + SearchEncryptionComplianceStatusNonCompliant SearchEncryptionComplianceStatus = "NonCompliant" +) + +func PossibleValuesForSearchEncryptionComplianceStatus() []string { + return []string{ + string(SearchEncryptionComplianceStatusCompliant), + string(SearchEncryptionComplianceStatusNonCompliant), + } +} + +func (s *SearchEncryptionComplianceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchEncryptionComplianceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchEncryptionComplianceStatus(input string) (*SearchEncryptionComplianceStatus, error) { + vals := map[string]SearchEncryptionComplianceStatus{ + "compliant": SearchEncryptionComplianceStatusCompliant, + "noncompliant": SearchEncryptionComplianceStatusNonCompliant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchEncryptionComplianceStatus(input) + return &out, nil +} + +type SearchEncryptionWithCmk string + +const ( + SearchEncryptionWithCmkDisabled SearchEncryptionWithCmk = "Disabled" + SearchEncryptionWithCmkEnabled SearchEncryptionWithCmk = "Enabled" + SearchEncryptionWithCmkUnspecified SearchEncryptionWithCmk = "Unspecified" +) + +func PossibleValuesForSearchEncryptionWithCmk() []string { + return []string{ + string(SearchEncryptionWithCmkDisabled), + string(SearchEncryptionWithCmkEnabled), + string(SearchEncryptionWithCmkUnspecified), + } +} + +func (s *SearchEncryptionWithCmk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchEncryptionWithCmk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchEncryptionWithCmk(input string) (*SearchEncryptionWithCmk, error) { + vals := map[string]SearchEncryptionWithCmk{ + "disabled": SearchEncryptionWithCmkDisabled, + "enabled": SearchEncryptionWithCmkEnabled, + "unspecified": SearchEncryptionWithCmkUnspecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchEncryptionWithCmk(input) + return &out, nil +} + +type SearchSemanticSearch string + +const ( + SearchSemanticSearchDisabled SearchSemanticSearch = "disabled" + SearchSemanticSearchFree SearchSemanticSearch = "free" + SearchSemanticSearchStandard SearchSemanticSearch = "standard" +) + +func PossibleValuesForSearchSemanticSearch() []string { + return []string{ + string(SearchSemanticSearchDisabled), + string(SearchSemanticSearchFree), + string(SearchSemanticSearchStandard), + } +} + +func (s *SearchSemanticSearch) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchSemanticSearch(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchSemanticSearch(input string) (*SearchSemanticSearch, error) { + vals := map[string]SearchSemanticSearch{ + "disabled": SearchSemanticSearchDisabled, + "free": SearchSemanticSearchFree, + "standard": SearchSemanticSearchStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchSemanticSearch(input) + return &out, nil +} + +type SearchServiceStatus string + +const ( + SearchServiceStatusDegraded SearchServiceStatus = "degraded" + SearchServiceStatusDeleting SearchServiceStatus = "deleting" + SearchServiceStatusDisabled SearchServiceStatus = "disabled" + SearchServiceStatusError SearchServiceStatus = "error" + SearchServiceStatusProvisioning SearchServiceStatus = "provisioning" + SearchServiceStatusRunning SearchServiceStatus = "running" + SearchServiceStatusStopped SearchServiceStatus = "stopped" +) + +func PossibleValuesForSearchServiceStatus() []string { + return []string{ + string(SearchServiceStatusDegraded), + string(SearchServiceStatusDeleting), + string(SearchServiceStatusDisabled), + string(SearchServiceStatusError), + string(SearchServiceStatusProvisioning), + string(SearchServiceStatusRunning), + string(SearchServiceStatusStopped), + } +} + +func (s *SearchServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSearchServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSearchServiceStatus(input string) (*SearchServiceStatus, error) { + vals := map[string]SearchServiceStatus{ + "degraded": SearchServiceStatusDegraded, + "deleting": SearchServiceStatusDeleting, + "disabled": SearchServiceStatusDisabled, + "error": SearchServiceStatusError, + "provisioning": SearchServiceStatusProvisioning, + "running": SearchServiceStatusRunning, + "stopped": SearchServiceStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SearchServiceStatus(input) + return &out, nil +} + +type SharedPrivateLinkResourceProvisioningState string + +const ( + SharedPrivateLinkResourceProvisioningStateDeleting SharedPrivateLinkResourceProvisioningState = "Deleting" + SharedPrivateLinkResourceProvisioningStateFailed SharedPrivateLinkResourceProvisioningState = "Failed" + SharedPrivateLinkResourceProvisioningStateIncomplete SharedPrivateLinkResourceProvisioningState = "Incomplete" + SharedPrivateLinkResourceProvisioningStateSucceeded SharedPrivateLinkResourceProvisioningState = "Succeeded" + SharedPrivateLinkResourceProvisioningStateUpdating SharedPrivateLinkResourceProvisioningState = "Updating" +) + +func PossibleValuesForSharedPrivateLinkResourceProvisioningState() []string { + return []string{ + string(SharedPrivateLinkResourceProvisioningStateDeleting), + string(SharedPrivateLinkResourceProvisioningStateFailed), + string(SharedPrivateLinkResourceProvisioningStateIncomplete), + string(SharedPrivateLinkResourceProvisioningStateSucceeded), + string(SharedPrivateLinkResourceProvisioningStateUpdating), + } +} + +func (s *SharedPrivateLinkResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceProvisioningState(input string) (*SharedPrivateLinkResourceProvisioningState, error) { + vals := map[string]SharedPrivateLinkResourceProvisioningState{ + "deleting": SharedPrivateLinkResourceProvisioningStateDeleting, + "failed": SharedPrivateLinkResourceProvisioningStateFailed, + "incomplete": SharedPrivateLinkResourceProvisioningStateIncomplete, + "succeeded": SharedPrivateLinkResourceProvisioningStateSucceeded, + "updating": SharedPrivateLinkResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceProvisioningState(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "basic" + SkuNameFree SkuName = "free" + SkuNameStandard SkuName = "standard" + SkuNameStandardThree SkuName = "standard3" + SkuNameStandardTwo SkuName = "standard2" + SkuNameStorageOptimizedLOne SkuName = "storage_optimized_l1" + SkuNameStorageOptimizedLTwo SkuName = "storage_optimized_l2" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameFree), + string(SkuNameStandard), + string(SkuNameStandardThree), + string(SkuNameStandardTwo), + string(SkuNameStorageOptimizedLOne), + string(SkuNameStorageOptimizedLTwo), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "free": SkuNameFree, + "standard": SkuNameStandard, + "standard3": SkuNameStandardThree, + "standard2": SkuNameStandardTwo, + "storage_optimized_l1": SkuNameStorageOptimizedLOne, + "storage_optimized_l2": SkuNameStorageOptimizedLTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type UnavailableNameReason string + +const ( + UnavailableNameReasonAlreadyExists UnavailableNameReason = "AlreadyExists" + UnavailableNameReasonInvalid UnavailableNameReason = "Invalid" +) + +func PossibleValuesForUnavailableNameReason() []string { + return []string{ + string(UnavailableNameReasonAlreadyExists), + string(UnavailableNameReasonInvalid), + } +} + +func (s *UnavailableNameReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnavailableNameReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnavailableNameReason(input string) (*UnavailableNameReason, error) { + vals := map[string]UnavailableNameReason{ + "alreadyexists": UnavailableNameReasonAlreadyExists, + "invalid": UnavailableNameReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnavailableNameReason(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/services/id_searchservice.go b/resource-manager/search/2024-06-01-preview/services/id_searchservice.go new file mode 100644 index 00000000000..1cb359dc995 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/id_searchservice.go @@ -0,0 +1,130 @@ +package services + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go new file mode 100644 index 00000000000..b057ee877be --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/id_searchservice_test.go @@ -0,0 +1,282 @@ +package services + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/services/method_checknameavailability.go b/resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go new file mode 100644 index 00000000000..fc2d16f5577 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_checknameavailability.go @@ -0,0 +1,88 @@ +package services + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityOutput +} + +type CheckNameAvailabilityOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCheckNameAvailabilityOperationOptions() CheckNameAvailabilityOperationOptions { + return CheckNameAvailabilityOperationOptions{} +} + +func (o CheckNameAvailabilityOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CheckNameAvailabilityOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CheckNameAvailabilityOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CheckNameAvailability ... +func (c ServicesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityInput, options CheckNameAvailabilityOperationOptions) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/providers/Microsoft.Search/checkNameAvailability", 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 + } + + var model CheckNameAvailabilityOutput + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go b/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go new file mode 100644 index 00000000000..eb913bcdc6b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_createorupdate.go @@ -0,0 +1,104 @@ +package services + +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 + Model *SearchService +} + +type CreateOrUpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ServicesClient) CreateOrUpdate(ctx context.Context, id SearchServiceId, input SearchService, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 ServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id SearchServiceId, input SearchService, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/search/2024-06-01-preview/services/method_delete.go b/resource-manager/search/2024-06-01-preview/services/method_delete.go new file mode 100644 index 00000000000..da3e636b27e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_delete.go @@ -0,0 +1,77 @@ +package services + +import ( + "context" + "fmt" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ServicesClient) Delete(ctx context.Context, id SearchServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_get.go b/resource-manager/search/2024-06-01-preview/services/method_get.go new file mode 100644 index 00000000000..7d3bc50da98 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_get.go @@ -0,0 +1,83 @@ +package services + +import ( + "context" + "fmt" + "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 *SearchService +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c ServicesClient) Get(ctx context.Context, id SearchServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model SearchService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go b/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e27921b39d4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package services + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SearchService +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SearchService +} + +type ListByResourceGroupOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ServicesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Search/searchServices", 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 *[]SearchService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServicesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SearchServiceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServicesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SearchServiceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SearchService, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go b/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go new file mode 100644 index 00000000000..c72273bc4d8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_listbysubscription.go @@ -0,0 +1,135 @@ +package services + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SearchService +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SearchService +} + +type ListBySubscriptionOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c ServicesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Search/searchServices", 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 *[]SearchService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ServicesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, SearchServiceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServicesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate SearchServiceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SearchService, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/method_update.go b/resource-manager/search/2024-06-01-preview/services/method_update.go new file mode 100644 index 00000000000..2fcfddaf54e --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/method_update.go @@ -0,0 +1,87 @@ +package services + +import ( + "context" + "fmt" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SearchService +} + +type UpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ServicesClient) Update(ctx context.Context, id SearchServiceId, input SearchServiceUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + 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 + } + + var model SearchService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go new file mode 100644 index 00000000000..a0c8c13c73a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityinput.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityInput struct { + Name string `json:"name"` + Type ResourceType `json:"type"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go new file mode 100644 index 00000000000..f10992a6cde --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_checknameavailabilityoutput.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOutput struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *UnavailableNameReason `json:"reason,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go b/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go new file mode 100644 index 00000000000..aa7d26142fb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_dataplaneaadorapikeyauthoption.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPlaneAadOrApiKeyAuthOption struct { + AadAuthFailureMode *AadAuthFailureMode `json:"aadAuthFailureMode,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go b/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go new file mode 100644 index 00000000000..7a32d0d1f1d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_dataplaneauthoptions.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataPlaneAuthOptions struct { + AadOrApiKey *DataPlaneAadOrApiKeyAuthOption `json:"aadOrApiKey,omitempty"` + ApiKeyOnly *interface{} `json:"apiKeyOnly,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go b/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go new file mode 100644 index 00000000000..6f4bfcca62f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_encryptionwithcmk.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionWithCmk struct { + EncryptionComplianceStatus *SearchEncryptionComplianceStatus `json:"encryptionComplianceStatus,omitempty"` + Enforcement *SearchEncryptionWithCmk `json:"enforcement,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_iprule.go b/resource-manager/search/2024-06-01-preview/services/model_iprule.go new file mode 100644 index 00000000000..f05c1d347f1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_iprule.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPRule struct { + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go b/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go new file mode 100644 index 00000000000..eaba6740a80 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_networkruleset.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkRuleSet struct { + Bypass *SearchBypass `json:"bypass,omitempty"` + IPRules *[]IPRule `json:"ipRules,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go new file mode 100644 index 00000000000..bb3fe5c797d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..2e955f64b7f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *PrivateLinkServiceConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go new file mode 100644 index 00000000000..ba85df04a41 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivateendpoint.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..594793a1615 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_privateendpointconnectionpropertiesprivatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchservice.go b/resource-manager/search/2024-06-01-preview/services/model_searchservice.go new file mode 100644 index 00000000000..6193f974ae0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchservice.go @@ -0,0 +1,19 @@ +package services + +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 SearchService struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SearchServiceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go b/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go new file mode 100644 index 00000000000..a6314f4a591 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchserviceproperties.go @@ -0,0 +1,23 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchServiceProperties struct { + AuthOptions *DataPlaneAuthOptions `json:"authOptions,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + DisabledDataExfiltrationOptions *[]SearchDisabledDataExfiltrationOption `json:"disabledDataExfiltrationOptions,omitempty"` + ETag *string `json:"eTag,omitempty"` + EncryptionWithCmk *EncryptionWithCmk `json:"encryptionWithCmk,omitempty"` + HostingMode *HostingMode `json:"hostingMode,omitempty"` + NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + PartitionCount *int64 `json:"partitionCount,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ReplicaCount *int64 `json:"replicaCount,omitempty"` + SemanticSearch *SearchSemanticSearch `json:"semanticSearch,omitempty"` + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + Status *SearchServiceStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go b/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go new file mode 100644 index 00000000000..d80e077366c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_searchserviceupdate.go @@ -0,0 +1,19 @@ +package services + +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 SearchServiceUpdate struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SearchServiceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..2052d81b1cb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresource.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..dcfbd937645 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,13 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + ProvisioningState *SharedPrivateLinkResourceProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + ResourceRegion *string `json:"resourceRegion,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/model_sku.go b/resource-manager/search/2024-06-01-preview/services/model_sku.go new file mode 100644 index 00000000000..043547ca6d4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/model_sku.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/services/predicates.go b/resource-manager/search/2024-06-01-preview/services/predicates.go new file mode 100644 index 00000000000..8743fe1ac71 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/predicates.go @@ -0,0 +1,32 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SearchServiceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SearchServiceOperationPredicate) Matches(input SearchService) 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/search/2024-06-01-preview/services/version.go b/resource-manager/search/2024-06-01-preview/services/version.go new file mode 100644 index 00000000000..04cd96be6f5 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/services/version.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/services/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md new file mode 100644 index 00000000000..72fa4f7fba0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources` Documentation + +The `sharedprivatelinkresources` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/sharedprivatelinkresources" +``` + + +### Client Initialization + +```go +client := sharedprivatelinkresources.NewSharedPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +payload := sharedprivatelinkresources.SharedPrivateLinkResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, sharedprivatelinkresources.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.Delete` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +if err := client.DeleteThenPoll(ctx, id, sharedprivatelinkresources.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + +read, err := client.Get(ctx, id, sharedprivatelinkresources.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SharedPrivateLinkResourcesClient.ListByService` + +```go +ctx := context.TODO() +id := sharedprivatelinkresources.NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + +// alternatively `client.ListByService(ctx, id, sharedprivatelinkresources.DefaultListByServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id, sharedprivatelinkresources.DefaultListByServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go new file mode 100644 index 00000000000..4e06c2f4a5d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package sharedprivatelinkresources + +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 SharedPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewSharedPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*SharedPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sharedprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SharedPrivateLinkResourcesClient: %+v", err) + } + + return &SharedPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go new file mode 100644 index 00000000000..1e34bb59acc --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/constants.go @@ -0,0 +1,107 @@ +package sharedprivatelinkresources + +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 SharedPrivateLinkResourceProvisioningState string + +const ( + SharedPrivateLinkResourceProvisioningStateDeleting SharedPrivateLinkResourceProvisioningState = "Deleting" + SharedPrivateLinkResourceProvisioningStateFailed SharedPrivateLinkResourceProvisioningState = "Failed" + SharedPrivateLinkResourceProvisioningStateIncomplete SharedPrivateLinkResourceProvisioningState = "Incomplete" + SharedPrivateLinkResourceProvisioningStateSucceeded SharedPrivateLinkResourceProvisioningState = "Succeeded" + SharedPrivateLinkResourceProvisioningStateUpdating SharedPrivateLinkResourceProvisioningState = "Updating" +) + +func PossibleValuesForSharedPrivateLinkResourceProvisioningState() []string { + return []string{ + string(SharedPrivateLinkResourceProvisioningStateDeleting), + string(SharedPrivateLinkResourceProvisioningStateFailed), + string(SharedPrivateLinkResourceProvisioningStateIncomplete), + string(SharedPrivateLinkResourceProvisioningStateSucceeded), + string(SharedPrivateLinkResourceProvisioningStateUpdating), + } +} + +func (s *SharedPrivateLinkResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceProvisioningState(input string) (*SharedPrivateLinkResourceProvisioningState, error) { + vals := map[string]SharedPrivateLinkResourceProvisioningState{ + "deleting": SharedPrivateLinkResourceProvisioningStateDeleting, + "failed": SharedPrivateLinkResourceProvisioningStateFailed, + "incomplete": SharedPrivateLinkResourceProvisioningStateIncomplete, + "succeeded": SharedPrivateLinkResourceProvisioningStateSucceeded, + "updating": SharedPrivateLinkResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceProvisioningState(input) + return &out, nil +} + +type SharedPrivateLinkResourceStatus string + +const ( + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" +) + +func PossibleValuesForSharedPrivateLinkResourceStatus() []string { + return []string{ + string(SharedPrivateLinkResourceStatusApproved), + string(SharedPrivateLinkResourceStatusDisconnected), + string(SharedPrivateLinkResourceStatusPending), + string(SharedPrivateLinkResourceStatusRejected), + } +} + +func (s *SharedPrivateLinkResourceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharedPrivateLinkResourceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharedPrivateLinkResourceStatus(input string) (*SharedPrivateLinkResourceStatus, error) { + vals := map[string]SharedPrivateLinkResourceStatus{ + "approved": SharedPrivateLinkResourceStatusApproved, + "disconnected": SharedPrivateLinkResourceStatusDisconnected, + "pending": SharedPrivateLinkResourceStatusPending, + "rejected": SharedPrivateLinkResourceStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharedPrivateLinkResourceStatus(input) + return &out, nil +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go new file mode 100644 index 00000000000..225d4b0ceb2 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice.go @@ -0,0 +1,130 @@ +package sharedprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SearchServiceId{}) +} + +var _ resourceids.ResourceId = &SearchServiceId{} + +// SearchServiceId is a struct representing the Resource ID for a Search Service +type SearchServiceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string +} + +// NewSearchServiceID returns a new SearchServiceId struct +func NewSearchServiceID(subscriptionId string, resourceGroupName string, searchServiceName string) SearchServiceId { + return SearchServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + } +} + +// ParseSearchServiceID parses 'input' into a SearchServiceId +func ParseSearchServiceID(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSearchServiceIDInsensitively parses 'input' case-insensitively into a SearchServiceId +// note: this method should only be used for API response data and not user input +func ParseSearchServiceIDInsensitively(input string) (*SearchServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SearchServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SearchServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SearchServiceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + return nil +} + +// ValidateSearchServiceID checks that 'input' can be parsed as a Search Service ID +func ValidateSearchServiceID(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 := ParseSearchServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Search Service ID +func (id SearchServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Search Service ID +func (id SearchServiceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + } +} + +// String returns a human-readable description of this Search Service ID +func (id SearchServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + } + return fmt.Sprintf("Search Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go new file mode 100644 index 00000000000..82567ff2cb0 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_searchservice_test.go @@ -0,0 +1,282 @@ +package sharedprivatelinkresources + +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 = &SearchServiceId{} + +func TestNewSearchServiceID(t *testing.T) { + id := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } +} + +func TestFormatSearchServiceID(t *testing.T) { + actual := NewSearchServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSearchServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestParseSearchServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SearchServiceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Expected: &SearchServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSearchServiceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + } +} + +func TestSegmentsForSearchServiceId(t *testing.T) { + segments := SearchServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SearchServiceId 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/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go new file mode 100644 index 00000000000..9148a3fdf54 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource.go @@ -0,0 +1,139 @@ +package sharedprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SharedPrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &SharedPrivateLinkResourceId{} + +// SharedPrivateLinkResourceId is a struct representing the Resource ID for a Shared Private Link Resource +type SharedPrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + SearchServiceName string + SharedPrivateLinkResourceName string +} + +// NewSharedPrivateLinkResourceID returns a new SharedPrivateLinkResourceId struct +func NewSharedPrivateLinkResourceID(subscriptionId string, resourceGroupName string, searchServiceName string, sharedPrivateLinkResourceName string) SharedPrivateLinkResourceId { + return SharedPrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SearchServiceName: searchServiceName, + SharedPrivateLinkResourceName: sharedPrivateLinkResourceName, + } +} + +// ParseSharedPrivateLinkResourceID parses 'input' into a SharedPrivateLinkResourceId +func ParseSharedPrivateLinkResourceID(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSharedPrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a SharedPrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParseSharedPrivateLinkResourceIDInsensitively(input string) (*SharedPrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SharedPrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SharedPrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SharedPrivateLinkResourceId) 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.SearchServiceName, ok = input.Parsed["searchServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "searchServiceName", input) + } + + if id.SharedPrivateLinkResourceName, ok = input.Parsed["sharedPrivateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sharedPrivateLinkResourceName", input) + } + + return nil +} + +// ValidateSharedPrivateLinkResourceID checks that 'input' can be parsed as a Shared Private Link Resource ID +func ValidateSharedPrivateLinkResourceID(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 := ParseSharedPrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Search/searchServices/%s/sharedPrivateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SearchServiceName, id.SharedPrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) 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("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticSearchServices", "searchServices", "searchServices"), + resourceids.UserSpecifiedSegment("searchServiceName", "searchServiceName"), + resourceids.StaticSegment("staticSharedPrivateLinkResources", "sharedPrivateLinkResources", "sharedPrivateLinkResources"), + resourceids.UserSpecifiedSegment("sharedPrivateLinkResourceName", "sharedPrivateLinkResourceName"), + } +} + +// String returns a human-readable description of this Shared Private Link Resource ID +func (id SharedPrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Search Service Name: %q", id.SearchServiceName), + fmt.Sprintf("Shared Private Link Resource Name: %q", id.SharedPrivateLinkResourceName), + } + return fmt.Sprintf("Shared Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go new file mode 100644 index 00000000000..7772fd93faa --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/id_sharedprivatelinkresource_test.go @@ -0,0 +1,327 @@ +package sharedprivatelinkresources + +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 = &SharedPrivateLinkResourceId{} + +func TestNewSharedPrivateLinkResourceID(t *testing.T) { + id := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName") + + 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.SearchServiceName != "searchServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'SearchServiceName'", id.SearchServiceName, "searchServiceName") + } + + if id.SharedPrivateLinkResourceName != "sharedPrivateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'SharedPrivateLinkResourceName'", id.SharedPrivateLinkResourceName, "sharedPrivateLinkResourceName") + } +} + +func TestFormatSharedPrivateLinkResourceID(t *testing.T) { + actual := NewSharedPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "searchServiceName", "sharedPrivateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSharedPrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceID(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestParseSharedPrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SharedPrivateLinkResourceId + }{ + { + // 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.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SearchServiceName: "searchServiceName", + SharedPrivateLinkResourceName: "sharedPrivateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Search/searchServices/searchServiceName/sharedPrivateLinkResources/sharedPrivateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeNaMe", + Expected: &SharedPrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SearchServiceName: "sEaRcHsErViCeNaMe", + SharedPrivateLinkResourceName: "sHaReDpRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // 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.sEaRcH/sEaRcHsErViCeS/sEaRcHsErViCeNaMe/sHaReDpRiVaTeLiNkReSoUrCeS/sHaReDpRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSharedPrivateLinkResourceIDInsensitively(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.SearchServiceName != v.Expected.SearchServiceName { + t.Fatalf("Expected %q but got %q for SearchServiceName", v.Expected.SearchServiceName, actual.SearchServiceName) + } + + if actual.SharedPrivateLinkResourceName != v.Expected.SharedPrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for SharedPrivateLinkResourceName", v.Expected.SharedPrivateLinkResourceName, actual.SharedPrivateLinkResourceName) + } + + } +} + +func TestSegmentsForSharedPrivateLinkResourceId(t *testing.T) { + segments := SharedPrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SharedPrivateLinkResourceId 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/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go new file mode 100644 index 00000000000..502bb307fd4 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_createorupdate.go @@ -0,0 +1,104 @@ +package sharedprivatelinkresources + +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 + Model *SharedPrivateLinkResource +} + +type CreateOrUpdateOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SharedPrivateLinkResourcesClient) CreateOrUpdate(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 SharedPrivateLinkResourcesClient) CreateOrUpdateThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, input SharedPrivateLinkResource, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go new file mode 100644 index 00000000000..8d405761166 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_delete.go @@ -0,0 +1,99 @@ +package sharedprivatelinkresources + +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 +} + +type DeleteOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c SharedPrivateLinkResourcesClient) Delete(ctx context.Context, id SharedPrivateLinkResourceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 SharedPrivateLinkResourcesClient) DeleteThenPoll(ctx context.Context, id SharedPrivateLinkResourceId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go new file mode 100644 index 00000000000..aefab346f1d --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_get.go @@ -0,0 +1,83 @@ +package sharedprivatelinkresources + +import ( + "context" + "fmt" + "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 *SharedPrivateLinkResource +} + +type GetOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c SharedPrivateLinkResourcesClient) Get(ctx context.Context, id SharedPrivateLinkResourceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model SharedPrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go new file mode 100644 index 00000000000..989aebe9b50 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/method_listbyservice.go @@ -0,0 +1,134 @@ +package sharedprivatelinkresources + +import ( + "context" + "fmt" + "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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedPrivateLinkResource +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []SharedPrivateLinkResource +} + +type ListByServiceOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c SharedPrivateLinkResourcesClient) ListByService(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/sharedPrivateLinkResources", 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 *[]SharedPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c SharedPrivateLinkResourcesClient) ListByServiceComplete(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, SharedPrivateLinkResourceOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SharedPrivateLinkResourcesClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id SearchServiceId, options ListByServiceOperationOptions, predicate SharedPrivateLinkResourceOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]SharedPrivateLinkResource, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..dfe11288236 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresource.go @@ -0,0 +1,11 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go new file mode 100644 index 00000000000..25934430949 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/model_sharedprivatelinkresourceproperties.go @@ -0,0 +1,13 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + ProvisioningState *SharedPrivateLinkResourceProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + ResourceRegion *string `json:"resourceRegion,omitempty"` + Status *SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go new file mode 100644 index 00000000000..b4d0b794bcb --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SharedPrivateLinkResourceOperationPredicate) Matches(input SharedPrivateLinkResource) 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/search/2024-06-01-preview/sharedprivatelinkresources/version.go b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go new file mode 100644 index 00000000000..b4bee4d183c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/sharedprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package sharedprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sharedprivatelinkresources/2024-06-01-preview" +} diff --git a/resource-manager/search/2024-06-01-preview/usages/README.md b/resource-manager/search/2024-06-01-preview/usages/README.md new file mode 100644 index 00000000000..7f4066c413a --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/search/2024-06-01-preview/usages` Documentation + +The `usages` SDK allows for interaction with Azure Resource Manager `search` (API Version `2024-06-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/search/2024-06-01-preview/usages" +``` + + +### Client Initialization + +```go +client := usages.NewUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UsagesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := usages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListBySubscription(ctx, id, usages.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, usages.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `UsagesClient.UsageBySubscriptionSku` + +```go +ctx := context.TODO() +id := usages.NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName") + +read, err := client.UsageBySubscriptionSku(ctx, id, usages.DefaultUsageBySubscriptionSkuOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/search/2024-06-01-preview/usages/client.go b/resource-manager/search/2024-06-01-preview/usages/client.go new file mode 100644 index 00000000000..5b6ce18413b --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/client.go @@ -0,0 +1,26 @@ +package usages + +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 UsagesClient struct { + Client *resourcemanager.Client +} + +func NewUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*UsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "usages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsagesClient: %+v", err) + } + + return &UsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_location.go b/resource-manager/search/2024-06-01-preview/usages/id_location.go new file mode 100644 index 00000000000..9c965faf9c6 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_location.go @@ -0,0 +1,121 @@ +package usages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Search/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_location_test.go b/resource-manager/search/2024-06-01-preview/usages/id_location_test.go new file mode 100644 index 00000000000..9542fbf99e2 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_location_test.go @@ -0,0 +1,237 @@ +package usages + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/search/2024-06-01-preview/usages/id_usage.go b/resource-manager/search/2024-06-01-preview/usages/id_usage.go new file mode 100644 index 00000000000..b4a582125ed --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_usage.go @@ -0,0 +1,130 @@ +package usages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&UsageId{}) +} + +var _ resourceids.ResourceId = &UsageId{} + +// UsageId is a struct representing the Resource ID for a Usage +type UsageId struct { + SubscriptionId string + LocationName string + UsageName string +} + +// NewUsageID returns a new UsageId struct +func NewUsageID(subscriptionId string, locationName string, usageName string) UsageId { + return UsageId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + UsageName: usageName, + } +} + +// ParseUsageID parses 'input' into a UsageId +func ParseUsageID(input string) (*UsageId, error) { + parser := resourceids.NewParserFromResourceIdType(&UsageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UsageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUsageIDInsensitively parses 'input' case-insensitively into a UsageId +// note: this method should only be used for API response data and not user input +func ParseUsageIDInsensitively(input string) (*UsageId, error) { + parser := resourceids.NewParserFromResourceIdType(&UsageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UsageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UsageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.UsageName, ok = input.Parsed["usageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "usageName", input) + } + + return nil +} + +// ValidateUsageID checks that 'input' can be parsed as a Usage ID +func ValidateUsageID(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 := ParseUsageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Usage ID +func (id UsageId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Search/locations/%s/usages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.UsageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Usage ID +func (id UsageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSearch", "Microsoft.Search", "Microsoft.Search"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticUsages", "usages", "usages"), + resourceids.UserSpecifiedSegment("usageName", "usageName"), + } +} + +// String returns a human-readable description of this Usage ID +func (id UsageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Usage Name: %q", id.UsageName), + } + return fmt.Sprintf("Usage (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go b/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go new file mode 100644 index 00000000000..1b38f124b7f --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/id_usage_test.go @@ -0,0 +1,282 @@ +package usages + +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 = &UsageId{} + +func TestNewUsageID(t *testing.T) { + id := NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.UsageName != "usageName" { + t.Fatalf("Expected %q but got %q for Segment 'UsageName'", id.UsageName, "usageName") + } +} + +func TestFormatUsageID(t *testing.T) { + actual := NewUsageID("12345678-1234-9876-4563-123456789012", "locationName", "usageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUsageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UsageId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + UsageName: "usageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUsageID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.UsageName != v.Expected.UsageName { + t.Fatalf("Expected %q but got %q for UsageName", v.Expected.UsageName, actual.UsageName) + } + + } +} + +func TestParseUsageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UsageId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + UsageName: "usageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Search/locations/locationName/usages/usageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS/uSaGeNaMe", + Expected: &UsageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + UsageName: "uSaGeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sEaRcH/lOcAtIoNs/lOcAtIoNnAmE/uSaGeS/uSaGeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUsageIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.UsageName != v.Expected.UsageName { + t.Fatalf("Expected %q but got %q for UsageName", v.Expected.UsageName, actual.UsageName) + } + + } +} + +func TestSegmentsForUsageId(t *testing.T) { + segments := UsageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UsageId 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/search/2024-06-01-preview/usages/method_listbysubscription.go b/resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go new file mode 100644 index 00000000000..086c77f98e8 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/method_listbysubscription.go @@ -0,0 +1,134 @@ +package usages + +import ( + "context" + "fmt" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]QuotaUsageResult +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []QuotaUsageResult +} + +type ListBySubscriptionOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c UsagesClient) ListBySubscription(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]QuotaUsageResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c UsagesClient) ListBySubscriptionComplete(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, QuotaUsageResultOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsagesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id LocationId, options ListBySubscriptionOperationOptions, predicate QuotaUsageResultOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]QuotaUsageResult, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go b/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go new file mode 100644 index 00000000000..cad37446749 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/method_usagebysubscriptionsku.go @@ -0,0 +1,83 @@ +package usages + +import ( + "context" + "fmt" + "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 UsageBySubscriptionSkuOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QuotaUsageResult +} + +type UsageBySubscriptionSkuOperationOptions struct { + XMsClientRequestId *string +} + +func DefaultUsageBySubscriptionSkuOperationOptions() UsageBySubscriptionSkuOperationOptions { + return UsageBySubscriptionSkuOperationOptions{} +} + +func (o UsageBySubscriptionSkuOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsClientRequestId != nil { + out.Append("x-ms-client-request-id", fmt.Sprintf("%v", *o.XMsClientRequestId)) + } + return &out +} + +func (o UsageBySubscriptionSkuOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UsageBySubscriptionSkuOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UsageBySubscriptionSku ... +func (c UsagesClient) UsageBySubscriptionSku(ctx context.Context, id UsageId, options UsageBySubscriptionSkuOperationOptions) (result UsageBySubscriptionSkuOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model QuotaUsageResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go new file mode 100644 index 00000000000..d6e8cec840c --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresult.go @@ -0,0 +1,12 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResult struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *QuotaUsageResultName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go new file mode 100644 index 00000000000..b8acf6bea95 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/model_quotausageresultname.go @@ -0,0 +1,9 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResultName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/search/2024-06-01-preview/usages/predicates.go b/resource-manager/search/2024-06-01-preview/usages/predicates.go new file mode 100644 index 00000000000..cf2a95bafc1 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/predicates.go @@ -0,0 +1,32 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUsageResultOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 + Unit *string +} + +func (p QuotaUsageResultOperationPredicate) Matches(input QuotaUsageResult) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} diff --git a/resource-manager/search/2024-06-01-preview/usages/version.go b/resource-manager/search/2024-06-01-preview/usages/version.go new file mode 100644 index 00000000000..611ce6cd051 --- /dev/null +++ b/resource-manager/search/2024-06-01-preview/usages/version.go @@ -0,0 +1,10 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-06-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/usages/2024-06-01-preview" +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go index 3d3d567781e..c1ad7b8d50d 100644 --- a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go index e2cb7617883..1c11378cc2e 100644 --- a/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/web/2023-12-01/webapps/model_siteproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go index dcb3e020b67..7f844ec7578 100644 --- a/resource-manager/web/2023-12-01/webapps/model_siteproperties.go +++ b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go @@ -24,6 +24,7 @@ type SiteProperties struct { DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/README.md b/resource-manager/web/2024-04-01/appservicecertificateorders/README.md new file mode 100644 index 00000000000..e15956d9dfc --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/README.md @@ -0,0 +1,381 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appservicecertificateorders` Documentation + +The `appservicecertificateorders` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appservicecertificateorders" +``` + + +### Client Initialization + +```go +client := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificateResource{ + // ... +} + + +if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Delete` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.DeleteCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.DeleteCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Get` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +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: `AppServiceCertificateOrdersClient.GetCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.GetCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `AppServiceCertificateOrdersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListCertificates` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +// alternatively `client.ListCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Reissue` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.ReissueCertificateOrderRequest{ + // ... +} + + +read, err := client.Reissue(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Renew` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.RenewCertificateOrderRequest{ + // ... +} + + +read, err := client.Renew(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendEmail` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.ResendEmail(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendRequestEmails` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.NameIdentifier{ + // ... +} + + +read, err := client.ResendRequestEmails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateActions` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateActions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateEmailHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveSiteSeal` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.SiteSealRequest{ + // ... +} + + +read, err := client.RetrieveSiteSeal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Update` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrderPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.UpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificatePatchResource{ + // ... +} + + +read, err := client.UpdateCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ValidatePurchaseInformation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +read, err := client.ValidatePurchaseInformation(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.VerifyDomainOwnership` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.VerifyDomainOwnership(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/client.go b/resource-manager/web/2024-04-01/appservicecertificateorders/client.go new file mode 100644 index 00000000000..a4c0860883e --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/client.go @@ -0,0 +1,26 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrdersClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) + } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/constants.go b/resource-manager/web/2024-04-01/appservicecertificateorders/constants.go new file mode 100644 index 00000000000..7fd04266697 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/constants.go @@ -0,0 +1,355 @@ +package appservicecertificateorders + +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 CertificateOrderActionType string + +const ( + CertificateOrderActionTypeCertificateExpirationWarning CertificateOrderActionType = "CertificateExpirationWarning" + CertificateOrderActionTypeCertificateExpired CertificateOrderActionType = "CertificateExpired" + CertificateOrderActionTypeCertificateIssued CertificateOrderActionType = "CertificateIssued" + CertificateOrderActionTypeCertificateOrderCanceled CertificateOrderActionType = "CertificateOrderCanceled" + CertificateOrderActionTypeCertificateOrderCreated CertificateOrderActionType = "CertificateOrderCreated" + CertificateOrderActionTypeCertificateRevoked CertificateOrderActionType = "CertificateRevoked" + CertificateOrderActionTypeDomainValidationComplete CertificateOrderActionType = "DomainValidationComplete" + CertificateOrderActionTypeFraudCleared CertificateOrderActionType = "FraudCleared" + CertificateOrderActionTypeFraudDetected CertificateOrderActionType = "FraudDetected" + CertificateOrderActionTypeFraudDocumentationRequired CertificateOrderActionType = "FraudDocumentationRequired" + CertificateOrderActionTypeOrgNameChange CertificateOrderActionType = "OrgNameChange" + CertificateOrderActionTypeOrgValidationComplete CertificateOrderActionType = "OrgValidationComplete" + CertificateOrderActionTypeSanDrop CertificateOrderActionType = "SanDrop" + CertificateOrderActionTypeUnknown CertificateOrderActionType = "Unknown" +) + +func PossibleValuesForCertificateOrderActionType() []string { + return []string{ + string(CertificateOrderActionTypeCertificateExpirationWarning), + string(CertificateOrderActionTypeCertificateExpired), + string(CertificateOrderActionTypeCertificateIssued), + string(CertificateOrderActionTypeCertificateOrderCanceled), + string(CertificateOrderActionTypeCertificateOrderCreated), + string(CertificateOrderActionTypeCertificateRevoked), + string(CertificateOrderActionTypeDomainValidationComplete), + string(CertificateOrderActionTypeFraudCleared), + string(CertificateOrderActionTypeFraudDetected), + string(CertificateOrderActionTypeFraudDocumentationRequired), + string(CertificateOrderActionTypeOrgNameChange), + string(CertificateOrderActionTypeOrgValidationComplete), + string(CertificateOrderActionTypeSanDrop), + string(CertificateOrderActionTypeUnknown), + } +} + +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { + vals := map[string]CertificateOrderActionType{ + "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, + "certificateexpired": CertificateOrderActionTypeCertificateExpired, + "certificateissued": CertificateOrderActionTypeCertificateIssued, + "certificateordercanceled": CertificateOrderActionTypeCertificateOrderCanceled, + "certificateordercreated": CertificateOrderActionTypeCertificateOrderCreated, + "certificaterevoked": CertificateOrderActionTypeCertificateRevoked, + "domainvalidationcomplete": CertificateOrderActionTypeDomainValidationComplete, + "fraudcleared": CertificateOrderActionTypeFraudCleared, + "frauddetected": CertificateOrderActionTypeFraudDetected, + "frauddocumentationrequired": CertificateOrderActionTypeFraudDocumentationRequired, + "orgnamechange": CertificateOrderActionTypeOrgNameChange, + "orgvalidationcomplete": CertificateOrderActionTypeOrgValidationComplete, + "sandrop": CertificateOrderActionTypeSanDrop, + "unknown": CertificateOrderActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderActionType(input) + return &out, nil +} + +type CertificateOrderStatus string + +const ( + CertificateOrderStatusCanceled CertificateOrderStatus = "Canceled" + CertificateOrderStatusDenied CertificateOrderStatus = "Denied" + CertificateOrderStatusExpired CertificateOrderStatus = "Expired" + CertificateOrderStatusIssued CertificateOrderStatus = "Issued" + CertificateOrderStatusNotSubmitted CertificateOrderStatus = "NotSubmitted" + CertificateOrderStatusPendingRekey CertificateOrderStatus = "PendingRekey" + CertificateOrderStatusPendingissuance CertificateOrderStatus = "Pendingissuance" + CertificateOrderStatusPendingrevocation CertificateOrderStatus = "Pendingrevocation" + CertificateOrderStatusRevoked CertificateOrderStatus = "Revoked" + CertificateOrderStatusUnused CertificateOrderStatus = "Unused" +) + +func PossibleValuesForCertificateOrderStatus() []string { + return []string{ + string(CertificateOrderStatusCanceled), + string(CertificateOrderStatusDenied), + string(CertificateOrderStatusExpired), + string(CertificateOrderStatusIssued), + string(CertificateOrderStatusNotSubmitted), + string(CertificateOrderStatusPendingRekey), + string(CertificateOrderStatusPendingissuance), + string(CertificateOrderStatusPendingrevocation), + string(CertificateOrderStatusRevoked), + string(CertificateOrderStatusUnused), + } +} + +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { + vals := map[string]CertificateOrderStatus{ + "canceled": CertificateOrderStatusCanceled, + "denied": CertificateOrderStatusDenied, + "expired": CertificateOrderStatusExpired, + "issued": CertificateOrderStatusIssued, + "notsubmitted": CertificateOrderStatusNotSubmitted, + "pendingrekey": CertificateOrderStatusPendingRekey, + "pendingissuance": CertificateOrderStatusPendingissuance, + "pendingrevocation": CertificateOrderStatusPendingrevocation, + "revoked": CertificateOrderStatusRevoked, + "unused": CertificateOrderStatusUnused, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderStatus(input) + return &out, nil +} + +type CertificateProductType string + +const ( + CertificateProductTypeStandardDomainValidatedSsl CertificateProductType = "StandardDomainValidatedSsl" + CertificateProductTypeStandardDomainValidatedWildCardSsl CertificateProductType = "StandardDomainValidatedWildCardSsl" +) + +func PossibleValuesForCertificateProductType() []string { + return []string{ + string(CertificateProductTypeStandardDomainValidatedSsl), + string(CertificateProductTypeStandardDomainValidatedWildCardSsl), + } +} + +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProductType(input string) (*CertificateProductType, error) { + vals := map[string]CertificateProductType{ + "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, + "standarddomainvalidatedwildcardssl": CertificateProductTypeStandardDomainValidatedWildCardSsl, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProductType(input) + return &out, nil +} + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder.go b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder.go new file mode 100644 index 00000000000..5b740005895 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder.go @@ -0,0 +1,130 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(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 := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder_test.go b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder_test.go new file mode 100644 index 00000000000..bdd7d952c00 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package appservicecertificateorders + +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 = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + + 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.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId 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/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate.go new file mode 100644 index 00000000000..91835e730de --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate.go @@ -0,0 +1,139 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateOrderCertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderCertificateId{} + +// CertificateOrderCertificateId is a struct representing the Resource ID for a Certificate Order Certificate +type CertificateOrderCertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + CertificateName string +} + +// NewCertificateOrderCertificateID returns a new CertificateOrderCertificateId struct +func NewCertificateOrderCertificateID(subscriptionId string, resourceGroupName string, certificateOrderName string, certificateName string) CertificateOrderCertificateId { + return CertificateOrderCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + CertificateName: certificateName, + } +} + +// ParseCertificateOrderCertificateID parses 'input' into a CertificateOrderCertificateId +func ParseCertificateOrderCertificateID(input string) (*CertificateOrderCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderCertificateIDInsensitively parses 'input' case-insensitively into a CertificateOrderCertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderCertificateIDInsensitively(input string) (*CertificateOrderCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderCertificateId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateOrderCertificateID checks that 'input' can be parsed as a Certificate Order Certificate ID +func ValidateCertificateOrderCertificateID(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 := ParseCertificateOrderCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order Certificate ID +func (id CertificateOrderCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order Certificate ID +func (id CertificateOrderCertificateId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate Order Certificate ID +func (id CertificateOrderCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate Order Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate_test.go b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate_test.go new file mode 100644 index 00000000000..8b5bb4327c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/id_certificateordercertificate_test.go @@ -0,0 +1,327 @@ +package appservicecertificateorders + +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 = &CertificateOrderCertificateId{} + +func TestNewCertificateOrderCertificateID(t *testing.T) { + id := NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + + 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.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatCertificateOrderCertificateID(t *testing.T) { + actual := NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderCertificateId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderCertificateID(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateOrderCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderCertificateId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderCertificateIDInsensitively(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateOrderCertificateId(t *testing.T) { + segments := CertificateOrderCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderCertificateId 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/web/2024-04-01/appservicecertificateorders/method_createorupdate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 00000000000..0ee50f71694 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +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 + Model *AppServiceCertificateOrder +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (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 AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) 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/web/2024-04-01/appservicecertificateorders/method_createorupdatecertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 00000000000..013318e02e8 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +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 CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, 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 +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_delete.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_delete.go new file mode 100644 index 00000000000..f8f40a08c11 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_deletecertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 00000000000..98b4359fd23 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateOrderCertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_get.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_get.go new file mode 100644 index 00000000000..452a170346a --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_get.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +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 *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (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 + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_getcertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 00000000000..712789271ae --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +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 GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateOrderCertificateId) (result GetCertificateOperationResponse, 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 + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_list.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_list.go new file mode 100644 index 00000000000..dc2a1437f6d --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_list.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +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 *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", 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 *[]AppServiceCertificateOrder `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 AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/appservicecertificateorders/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e800bd4359e --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", 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 *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_listcertificates.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 00000000000..04a478191c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,105 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateResource +} + +type ListCertificatesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCertificatesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCertificatesCustomPager{}, + Path: fmt.Sprintf("%s/certificates", 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 *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_reissue.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 00000000000..91b863f81f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_renew.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_renew.go new file mode 100644 index 00000000000..0d15451ed17 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendemail.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendemail.go new file mode 100644 index 00000000000..49de4389c59 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendemail.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ResendEmailOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendEmail", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendrequestemails.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 00000000000..e758b4dd706 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateactions.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 00000000000..51a8af70e7f --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", 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 + } + + var model []CertificateOrderAction + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 00000000000..84feccdb804 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", 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 + } + + var model []CertificateEmail + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievesiteseal.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 00000000000..160d1b5010b --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", 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 + } + + var model SiteSeal + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_update.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_update.go new file mode 100644 index 00000000000..cebc44fbccc --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_update.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_updatecertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 00000000000..dbb5136b153 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +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 UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_validatepurchaseinformation.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 00000000000..1a4c9a08f69 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +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 ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/method_verifydomainownership.go b/resource-manager/web/2024-04-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 00000000000..413d5008994 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificate.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificate.go new file mode 100644 index 00000000000..5572932e257 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificate.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificate struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + ProvisioningState *KeyVaultSecretStatus `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorder.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorder.go new file mode 100644 index 00000000000..3f171abb6db --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorder.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrder struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go new file mode 100644 index 00000000000..f0b6b7d477d --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go new file mode 100644 index 00000000000..4657e81b440 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrderPatchResourceProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderproperties.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderproperties.go new file mode 100644 index 00000000000..9b30d4ae973 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateorderproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrderProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificatepatchresource.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificatepatchresource.go new file mode 100644 index 00000000000..8f8d91b6c87 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificatepatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateresource.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateresource.go new file mode 100644 index 00000000000..7cd601e38f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_appservicecertificateresource.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificatedetails.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificatedetails.go new file mode 100644 index 00000000000..6905351a7c5 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificatedetails.go @@ -0,0 +1,46 @@ +package appservicecertificateorders + +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 CertificateDetails struct { + Issuer *string `json:"issuer,omitempty"` + NotAfter *string `json:"notAfter,omitempty"` + NotBefore *string `json:"notBefore,omitempty"` + RawData *string `json:"rawData,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +func (o *CertificateDetails) GetNotAfterAsTime() (*time.Time, error) { + if o.NotAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotAfter = &formatted +} + +func (o *CertificateDetails) GetNotBeforeAsTime() (*time.Time, error) { + if o.NotBefore == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotBefore, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotBeforeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotBefore = &formatted +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateemail.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateemail.go new file mode 100644 index 00000000000..27ec4e4d6f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateemail.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +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 CertificateEmail struct { + EmailId *string `json:"emailId,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *CertificateEmail) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateEmail) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateorderaction.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateorderaction.go new file mode 100644 index 00000000000..5a7f75ca664 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateorderaction.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +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 CertificateOrderAction struct { + ActionType *CertificateOrderActionType `json:"actionType,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` +} + +func (o *CertificateOrderAction) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateOrderAction) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateordercontact.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateordercontact.go new file mode 100644 index 00000000000..65e867d2102 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_certificateordercontact.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderContact struct { + Email *string `json:"email,omitempty"` + NameFirst *string `json:"nameFirst,omitempty"` + NameLast *string `json:"nameLast,omitempty"` + Phone *string `json:"phone,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_nameidentifier.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_nameidentifier.go new file mode 100644 index 00000000000..72477ac557d --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequest.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequest.go new file mode 100644 index 00000000000..15d4fec9572 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReissueCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go new file mode 100644 index 00000000000..edcc06283c9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + DelayExistingRevokeInHours *int64 `json:"delayExistingRevokeInHours,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequest.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequest.go new file mode 100644 index 00000000000..cacc0bada97 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RenewCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go new file mode 100644 index 00000000000..161c783b54e --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_siteseal.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_siteseal.go new file mode 100644 index 00000000000..64f302c54e8 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_siteseal.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSeal struct { + Html string `json:"html"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/model_sitesealrequest.go b/resource-manager/web/2024-04-01/appservicecertificateorders/model_sitesealrequest.go new file mode 100644 index 00000000000..ed81319016d --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/model_sitesealrequest.go @@ -0,0 +1,9 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSealRequest struct { + LightTheme *bool `json:"lightTheme,omitempty"` + Locale *string `json:"locale,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appservicecertificateorders/predicates.go b/resource-manager/web/2024-04-01/appservicecertificateorders/predicates.go new file mode 100644 index 00000000000..e7457040d0b --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/predicates.go @@ -0,0 +1,70 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateOrderOperationPredicate) Matches(input AppServiceCertificateOrder) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type AppServiceCertificateResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateResourceOperationPredicate) Matches(input AppServiceCertificateResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/appservicecertificateorders/version.go b/resource-manager/web/2024-04-01/appservicecertificateorders/version.go new file mode 100644 index 00000000000..3e0c9fcc283 --- /dev/null +++ b/resource-manager/web/2024-04-01/appservicecertificateorders/version.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appservicecertificateorders/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/README.md b/resource-manager/web/2024-04-01/appserviceenvironments/README.md new file mode 100644 index 00000000000..2c451296983 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/README.md @@ -0,0 +1,833 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceenvironments` Documentation + +The `appserviceenvironments` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceenvironments" +``` + + +### Client Initialization + +```go +client := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +payload := appserviceenvironments.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ChangeVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.VirtualNetworkProfile{ + // ... +} + + +// alternatively `client.ChangeVnet(ctx, id, payload)` can be used to do batched pagination +items, err := client.ChangeVnetComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AppServiceEnvironmentResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateMultiRolePoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateWorkerPoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +if err := client.DeleteThenPoll(ctx, id, appserviceenvironments.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeleteAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.DeleteAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +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: `AppServiceEnvironmentsClient.GetAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetAseV3NetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetAseV3NetworkingConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetDiagnosticsItem` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName") + +read, err := client.GetDiagnosticsItem(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetInboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetInboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetInboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetMultiRolePool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetVipInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetVipInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +read, err := client.GetWorkerPool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `AppServiceEnvironmentsClient.ListAppServicePlans` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListAppServicePlans(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServicePlansComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListCapacities` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListCapacities(ctx, id)` can be used to do batched pagination +items, err := client.ListCapacitiesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListDiagnostics` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ListDiagnostics(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleMetricDefinitions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRoleMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName") + +// alternatively `client.ListMultiRolePoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRolePoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRolePools(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRoleUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListOperations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ListOperations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListUsages(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListWebApps(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWebWorkerMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerUsages` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWebWorkerUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName") + +// alternatively `client.ListWorkerPoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolSkus` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWorkerPoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListWorkerPools(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Reboot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.Reboot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Resume` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.Resume(ctx, id)` can be used to do batched pagination +items, err := client.ResumeComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Suspend` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.Suspend(ctx, id)` can be used to do batched pagination +items, err := client.SuspendComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.TestUpgradeAvailableNotification` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.TestUpgradeAvailableNotification(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AppServiceEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.CustomDnsSuffixConfiguration{ + // ... +} + + +read, err := client.UpdateAseCustomDnsSuffixConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseNetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AseV3NetworkingConfiguration{ + // ... +} + + +read, err := client.UpdateAseNetworkingConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateMultiRolePool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateWorkerPool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Upgrade` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +if err := client.UpgradeThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/client.go b/resource-manager/web/2024-04-01/appserviceenvironments/client.go new file mode 100644 index 00000000000..706ca7d556d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/client.go @@ -0,0 +1,26 @@ +package appserviceenvironments + +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 AppServiceEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceEnvironmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appserviceenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceEnvironmentsClient: %+v", err) + } + + return &AppServiceEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/constants.go b/resource-manager/web/2024-04-01/appserviceenvironments/constants.go new file mode 100644 index 00000000000..bd1d791b853 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/constants.go @@ -0,0 +1,1715 @@ +package appserviceenvironments + +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 AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ComputeModeOptions string + +const ( + ComputeModeOptionsDedicated ComputeModeOptions = "Dedicated" + ComputeModeOptionsDynamic ComputeModeOptions = "Dynamic" + ComputeModeOptionsShared ComputeModeOptions = "Shared" +) + +func PossibleValuesForComputeModeOptions() []string { + return []string{ + string(ComputeModeOptionsDedicated), + string(ComputeModeOptionsDynamic), + string(ComputeModeOptionsShared), + } +} + +func (s *ComputeModeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeModeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeModeOptions(input string) (*ComputeModeOptions, error) { + vals := map[string]ComputeModeOptions{ + "dedicated": ComputeModeOptionsDedicated, + "dynamic": ComputeModeOptionsDynamic, + "shared": ComputeModeOptionsShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeModeOptions(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WorkerSizeOptions string + +const ( + WorkerSizeOptionsDOne WorkerSizeOptions = "D1" + WorkerSizeOptionsDThree WorkerSizeOptions = "D3" + WorkerSizeOptionsDTwo WorkerSizeOptions = "D2" + WorkerSizeOptionsDefault WorkerSizeOptions = "Default" + WorkerSizeOptionsLarge WorkerSizeOptions = "Large" + WorkerSizeOptionsLargeVThree WorkerSizeOptions = "LargeV3" + WorkerSizeOptionsMedium WorkerSizeOptions = "Medium" + WorkerSizeOptionsMediumVThree WorkerSizeOptions = "MediumV3" + WorkerSizeOptionsNestedSmall WorkerSizeOptions = "NestedSmall" + WorkerSizeOptionsNestedSmallLinux WorkerSizeOptions = "NestedSmallLinux" + WorkerSizeOptionsSmall WorkerSizeOptions = "Small" + WorkerSizeOptionsSmallVThree WorkerSizeOptions = "SmallV3" +) + +func PossibleValuesForWorkerSizeOptions() []string { + return []string{ + string(WorkerSizeOptionsDOne), + string(WorkerSizeOptionsDThree), + string(WorkerSizeOptionsDTwo), + string(WorkerSizeOptionsDefault), + string(WorkerSizeOptionsLarge), + string(WorkerSizeOptionsLargeVThree), + string(WorkerSizeOptionsMedium), + string(WorkerSizeOptionsMediumVThree), + string(WorkerSizeOptionsNestedSmall), + string(WorkerSizeOptionsNestedSmallLinux), + string(WorkerSizeOptionsSmall), + string(WorkerSizeOptionsSmallVThree), + } +} + +func (s *WorkerSizeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkerSizeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkerSizeOptions(input string) (*WorkerSizeOptions, error) { + vals := map[string]WorkerSizeOptions{ + "d1": WorkerSizeOptionsDOne, + "d3": WorkerSizeOptionsDThree, + "d2": WorkerSizeOptionsDTwo, + "default": WorkerSizeOptionsDefault, + "large": WorkerSizeOptionsLarge, + "largev3": WorkerSizeOptionsLargeVThree, + "medium": WorkerSizeOptionsMedium, + "mediumv3": WorkerSizeOptionsMediumVThree, + "nestedsmall": WorkerSizeOptionsNestedSmall, + "nestedsmalllinux": WorkerSizeOptionsNestedSmallLinux, + "small": WorkerSizeOptionsSmall, + "smallv3": WorkerSizeOptionsSmallVThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkerSizeOptions(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance.go new file mode 100644 index 00000000000..88c10f8ab90 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance.go @@ -0,0 +1,141 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DefaultInstanceId{}) +} + +var _ resourceids.ResourceId = &DefaultInstanceId{} + +// DefaultInstanceId is a struct representing the Resource ID for a Default Instance +type DefaultInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + InstanceName string +} + +// NewDefaultInstanceID returns a new DefaultInstanceId struct +func NewDefaultInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, instanceName string) DefaultInstanceId { + return DefaultInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + InstanceName: instanceName, + } +} + +// ParseDefaultInstanceID parses 'input' into a DefaultInstanceId +func ParseDefaultInstanceID(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultInstanceIDInsensitively parses 'input' case-insensitively into a DefaultInstanceId +// note: this method should only be used for API response data and not user input +func ParseDefaultInstanceIDInsensitively(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultInstanceId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateDefaultInstanceID checks that 'input' can be parsed as a Default Instance ID +func ValidateDefaultInstanceID(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 := ParseDefaultInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default Instance ID +func (id DefaultInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/multiRolePools/default/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default Instance ID +func (id DefaultInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticMultiRolePools", "multiRolePools", "multiRolePools"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceName"), + } +} + +// String returns a human-readable description of this Default Instance ID +func (id DefaultInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Default Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance_test.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance_test.go new file mode 100644 index 00000000000..a260dfe3401 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_defaultinstance_test.go @@ -0,0 +1,357 @@ +package appserviceenvironments + +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 = &DefaultInstanceId{} + +func TestNewDefaultInstanceID(t *testing.T) { + id := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.InstanceName != "instanceName" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceName") + } +} + +func TestFormatDefaultInstanceID(t *testing.T) { + actual := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseDefaultInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEnAmE", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + InstanceName: "iNsTaNcEnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForDefaultInstanceId(t *testing.T) { + segments := DefaultInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultInstanceId 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/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go new file mode 100644 index 00000000000..9c0321e3f7a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDiagnosticId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDiagnosticId{} + +// HostingEnvironmentDiagnosticId is a struct representing the Resource ID for a Hosting Environment Diagnostic +type HostingEnvironmentDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DiagnosticName string +} + +// NewHostingEnvironmentDiagnosticID returns a new HostingEnvironmentDiagnosticId struct +func NewHostingEnvironmentDiagnosticID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, diagnosticName string) HostingEnvironmentDiagnosticId { + return HostingEnvironmentDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DiagnosticName: diagnosticName, + } +} + +// ParseHostingEnvironmentDiagnosticID parses 'input' into a HostingEnvironmentDiagnosticId +func ParseHostingEnvironmentDiagnosticID(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDiagnosticIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDiagnosticIDInsensitively(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDiagnosticId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDiagnosticID checks that 'input' can be parsed as a Hosting Environment Diagnostic ID +func ValidateHostingEnvironmentDiagnosticID(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 := ParseHostingEnvironmentDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Hosting Environment Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go new file mode 100644 index 00000000000..e998d9bcef1 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &HostingEnvironmentDiagnosticId{} + +func TestNewHostingEnvironmentDiagnosticID(t *testing.T) { + id := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatHostingEnvironmentDiagnosticID(t *testing.T) { + actual := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseHostingEnvironmentDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDiagnosticId(t *testing.T) { + segments := HostingEnvironmentDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDiagnosticId 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/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go new file mode 100644 index 00000000000..415a31bdc7e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentPrivateEndpointConnectionId{} + +// HostingEnvironmentPrivateEndpointConnectionId is a struct representing the Resource ID for a Hosting Environment Private Endpoint Connection +type HostingEnvironmentPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + PrivateEndpointConnectionName string +} + +// NewHostingEnvironmentPrivateEndpointConnectionID returns a new HostingEnvironmentPrivateEndpointConnectionId struct +func NewHostingEnvironmentPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, privateEndpointConnectionName string) HostingEnvironmentPrivateEndpointConnectionId { + return HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseHostingEnvironmentPrivateEndpointConnectionID parses 'input' into a HostingEnvironmentPrivateEndpointConnectionId +func ParseHostingEnvironmentPrivateEndpointConnectionID(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentPrivateEndpointConnectionId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateHostingEnvironmentPrivateEndpointConnectionID checks that 'input' can be parsed as a Hosting Environment Private Endpoint Connection ID +func ValidateHostingEnvironmentPrivateEndpointConnectionID(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 := ParseHostingEnvironmentPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Hosting Environment Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go new file mode 100644 index 00000000000..f343f7258e6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &HostingEnvironmentPrivateEndpointConnectionId{} + +func TestNewHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + id := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + actual := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForHostingEnvironmentPrivateEndpointConnectionId(t *testing.T) { + segments := HostingEnvironmentPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentPrivateEndpointConnectionId 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/web/2024-04-01/appserviceenvironments/id_workerpool.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpool.go new file mode 100644 index 00000000000..dd10e8ad690 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpool.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkerPoolId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolId{} + +// WorkerPoolId is a struct representing the Resource ID for a Worker Pool +type WorkerPoolId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string +} + +// NewWorkerPoolID returns a new WorkerPoolId struct +func NewWorkerPoolID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string) WorkerPoolId { + return WorkerPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + } +} + +// ParseWorkerPoolID parses 'input' into a WorkerPoolId +func ParseWorkerPoolID(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolIDInsensitively parses 'input' case-insensitively into a WorkerPoolId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolIDInsensitively(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + return nil +} + +// ValidateWorkerPoolID checks that 'input' can be parsed as a Worker Pool ID +func ValidateWorkerPoolID(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 := ParseWorkerPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool ID +func (id WorkerPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool ID +func (id WorkerPoolId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolName"), + } +} + +// String returns a human-readable description of this Worker Pool ID +func (id WorkerPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + } + return fmt.Sprintf("Worker Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpool_test.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpool_test.go new file mode 100644 index 00000000000..df611010d06 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpool_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &WorkerPoolId{} + +func TestNewWorkerPoolID(t *testing.T) { + id := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.WorkerPoolName != "workerPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolName") + } +} + +func TestFormatWorkerPoolID(t *testing.T) { + actual := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestParseWorkerPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + WorkerPoolName: "wOrKeRpOoLnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestSegmentsForWorkerPoolId(t *testing.T) { + segments := WorkerPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolId 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/web/2024-04-01/appserviceenvironments/id_workerpoolinstance.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpoolinstance.go new file mode 100644 index 00000000000..50a42965552 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpoolinstance.go @@ -0,0 +1,148 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkerPoolInstanceId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolInstanceId{} + +// WorkerPoolInstanceId is a struct representing the Resource ID for a Worker Pool Instance +type WorkerPoolInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string + InstanceName string +} + +// NewWorkerPoolInstanceID returns a new WorkerPoolInstanceId struct +func NewWorkerPoolInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string, instanceName string) WorkerPoolInstanceId { + return WorkerPoolInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + InstanceName: instanceName, + } +} + +// ParseWorkerPoolInstanceID parses 'input' into a WorkerPoolInstanceId +func ParseWorkerPoolInstanceID(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolInstanceIDInsensitively parses 'input' case-insensitively into a WorkerPoolInstanceId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolInstanceIDInsensitively(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolInstanceId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateWorkerPoolInstanceID checks that 'input' can be parsed as a Worker Pool Instance ID +func ValidateWorkerPoolInstanceID(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 := ParseWorkerPoolInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool Instance ID +func (id WorkerPoolInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool Instance ID +func (id WorkerPoolInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceName"), + } +} + +// String returns a human-readable description of this Worker Pool Instance ID +func (id WorkerPoolInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Worker Pool Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpoolinstance_test.go b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpoolinstance_test.go new file mode 100644 index 00000000000..b23611ebd58 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/id_workerpoolinstance_test.go @@ -0,0 +1,372 @@ +package appserviceenvironments + +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 = &WorkerPoolInstanceId{} + +func TestNewWorkerPoolInstanceID(t *testing.T) { + id := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.WorkerPoolName != "workerPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolName") + } + + if id.InstanceName != "instanceName" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceName") + } +} + +func TestFormatWorkerPoolInstanceID(t *testing.T) { + actual := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseWorkerPoolInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs/iNsTaNcEnAmE", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + WorkerPoolName: "wOrKeRpOoLnAmE", + InstanceName: "iNsTaNcEnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs/iNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForWorkerPoolInstanceId(t *testing.T) { + segments := WorkerPoolInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolInstanceId 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/web/2024-04-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..5bd10a90134 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_changevnet.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_changevnet.go new file mode 100644 index 00000000000..6bf6156af62 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_changevnet.go @@ -0,0 +1,94 @@ +package appserviceenvironments + +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 ChangeVnetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ChangeVnetCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ChangeVnetCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ChangeVnetCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ChangeVnet ... +func (c AppServiceEnvironmentsClient) ChangeVnet(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) (result ChangeVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ChangeVnetCustomPager{}, + Path: fmt.Sprintf("%s/changeVirtualNetwork", 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 +} + +// ChangeVnetThenPoll performs ChangeVnet then polls until it's completed +func (c AppServiceEnvironmentsClient) ChangeVnetThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) error { + result, err := c.ChangeVnet(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ChangeVnet: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ChangeVnet: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdate.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdate.go new file mode 100644 index 00000000000..0e325049b7f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdate.go @@ -0,0 +1,77 @@ +package appserviceenvironments + +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 + Model *AppServiceEnvironmentResource +} + +// CreateOrUpdate ... +func (c AppServiceEnvironmentsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 AppServiceEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) 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/web/2024-04-01/appserviceenvironments/method_createorupdatemultirolepool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdatemultirolepool.go new file mode 100644 index 00000000000..680b38261e5 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdatemultirolepool.go @@ -0,0 +1,76 @@ +package appserviceenvironments + +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 CreateOrUpdateMultiRolePoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result CreateOrUpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/multiRolePools/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 +} + +// CreateOrUpdateMultiRolePoolThenPoll performs CreateOrUpdateMultiRolePool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePoolThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateMultiRolePool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateMultiRolePool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateMultiRolePool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdateworkerpool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdateworkerpool.go new file mode 100644 index 00000000000..a3cb8c751fd --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_createorupdateworkerpool.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +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 CreateOrUpdateWorkerPoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result CreateOrUpdateWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateWorkerPoolThenPoll performs CreateOrUpdateWorkerPool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPoolThenPoll(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateWorkerPool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateWorkerPool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateWorkerPool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_delete.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_delete.go new file mode 100644 index 00000000000..f8fb37d265b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_delete.go @@ -0,0 +1,100 @@ +package appserviceenvironments + +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 +} + +type DeleteOperationOptions struct { + ForceDelete *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDelete != nil { + out.Append("forceDelete", fmt.Sprintf("%v", *o.ForceDelete)) + } + return &out +} + +// Delete ... +func (c AppServiceEnvironmentsClient) Delete(ctx context.Context, id commonids.AppServiceEnvironmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 AppServiceEnvironmentsClient) DeleteThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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/web/2024-04-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..c5871258555 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 DeleteAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeleteAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) DeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f15f2fafc23 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package appserviceenvironments + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_get.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_get.go new file mode 100644 index 00000000000..19b2bdb044f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_get.go @@ -0,0 +1,54 @@ +package appserviceenvironments + +import ( + "context" + "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 *AppServiceEnvironmentResource +} + +// Get ... +func (c AppServiceEnvironmentsClient) Get(ctx context.Context, id commonids.AppServiceEnvironmentId) (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 + } + + var model AppServiceEnvironmentResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..01f38db8a6e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 GetAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// GetAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getasev3networkingconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getasev3networkingconfiguration.go new file mode 100644 index 00000000000..3815d5e3c5e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getasev3networkingconfiguration.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 GetAseV3NetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// GetAseV3NetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseV3NetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/networking", 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 + } + + var model AseV3NetworkingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getdiagnosticsitem.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getdiagnosticsitem.go new file mode 100644 index 00000000000..681cc63213c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getdiagnosticsitem.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +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 GetDiagnosticsItemOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostingEnvironmentDiagnostics +} + +// GetDiagnosticsItem ... +func (c AppServiceEnvironmentsClient) GetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (result GetDiagnosticsItemOperationResponse, 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 + } + + var model HostingEnvironmentDiagnostics + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..0ba5559383d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 GetInboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetInboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetInboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetInboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/inboundNetworkDependenciesEndpoints", 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 *[]InboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetInboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, InboundEnvironmentEndpointOperationPredicate{}) +} + +// GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate InboundEnvironmentEndpointOperationPredicate) (result GetInboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]InboundEnvironmentEndpoint, 0) + + resp, err := c.GetInboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetInboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getmultirolepool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getmultirolepool.go new file mode 100644 index 00000000000..7cbd25047b9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getmultirolepool.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 GetMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetMultiRolePool ... +func (c AppServiceEnvironmentsClient) GetMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/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 + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..0e457723e3d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 GetOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetOutboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetOutboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetOutboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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 *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate OutboundEnvironmentEndpointOperationPredicate) (result GetOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.GetOutboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnection.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..714c1276f69 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, 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 + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..c4ecbd05aaf --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivateendpointconnectionlist.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivatelinkresources.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivatelinkresources.go new file mode 100644 index 00000000000..ecd193a3901 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getprivatelinkresources.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c AppServiceEnvironmentsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getvipinfo.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getvipinfo.go new file mode 100644 index 00000000000..ef0c4a7c970 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getvipinfo.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 GetVipInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AddressResponse +} + +// GetVipInfo ... +func (c AppServiceEnvironmentsClient) GetVipInfo(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetVipInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/virtualip", 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 + } + + var model AddressResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_getworkerpool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_getworkerpool.go new file mode 100644 index 00000000000..f18c4334f8a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_getworkerpool.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +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 GetWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetWorkerPool ... +func (c AppServiceEnvironmentsClient) GetWorkerPool(ctx context.Context, id WorkerPoolId) (result GetWorkerPoolOperationResponse, 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 + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_list.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_list.go new file mode 100644 index 00000000000..b29d1ea041b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_list.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 *[]AppServiceEnvironmentResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServiceEnvironmentsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", 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 *[]AppServiceEnvironmentResource `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 AppServiceEnvironmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/appserviceenvironments/method_listappserviceplans.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listappserviceplans.go new file mode 100644 index 00000000000..26d1f005a45 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listappserviceplans.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListAppServicePlansOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListAppServicePlansCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListAppServicePlansCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAppServicePlansCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAppServicePlans ... +func (c AppServiceEnvironmentsClient) ListAppServicePlans(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListAppServicePlansOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAppServicePlansCustomPager{}, + Path: fmt.Sprintf("%s/serverFarms", 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 *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServicePlansComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListAppServicePlansComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListAppServicePlansCompleteResult, error) { + return c.ListAppServicePlansCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListAppServicePlansCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListAppServicePlansCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate AppServicePlanOperationPredicate) (result ListAppServicePlansCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListAppServicePlans(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListAppServicePlansCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3d45ec03742 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServiceEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", 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 *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listcapacities.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listcapacities.go new file mode 100644 index 00000000000..b524c9ea8d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listcapacities.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListCapacitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StampCapacity +} + +type ListCapacitiesCompleteResult struct { + LatestHttpResponse *http.Response + Items []StampCapacity +} + +type ListCapacitiesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCapacitiesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCapacities ... +func (c AppServiceEnvironmentsClient) ListCapacities(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListCapacitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCapacitiesCustomPager{}, + Path: fmt.Sprintf("%s/capacities/compute", 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 *[]StampCapacity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCapacitiesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListCapacitiesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListCapacitiesCompleteResult, error) { + return c.ListCapacitiesCompleteMatchingPredicate(ctx, id, StampCapacityOperationPredicate{}) +} + +// ListCapacitiesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCapacitiesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate StampCapacityOperationPredicate) (result ListCapacitiesCompleteResult, err error) { + items := make([]StampCapacity, 0) + + resp, err := c.ListCapacities(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListCapacitiesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listdiagnostics.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listdiagnostics.go new file mode 100644 index 00000000000..0b07c6c4a90 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listdiagnostics.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 ListDiagnosticsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostingEnvironmentDiagnostics +} + +// ListDiagnostics ... +func (c AppServiceEnvironmentsClient) ListDiagnostics(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListDiagnosticsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", 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 + } + + var model []HostingEnvironmentDiagnostics + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolemetricdefinitions.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolemetricdefinitions.go new file mode 100644 index 00000000000..703092408d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolemetricdefinitions.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListMultiRoleMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRoleMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRoleMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitions(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRoleMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleMetricDefinitionsCompleteResult, error) { + return c.ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRoleMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRoleMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRoleMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListMultiRoleMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..b0c259db50e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRolePoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolInstanceMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolInstanceMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx context.Context, id DefaultInstanceId) (ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id DefaultInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRolePoolInstanceMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListMultiRolePoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepools.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepools.go new file mode 100644 index 00000000000..2fff5186ba4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepools.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListMultiRolePoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListMultiRolePoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +type ListMultiRolePoolsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePools ... +func (c AppServiceEnvironmentsClient) ListMultiRolePools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolsCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools", 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 *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolsCompleteResult, error) { + return c.ListMultiRolePoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListMultiRolePoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListMultiRolePoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListMultiRolePools(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListMultiRolePoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolskus.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolskus.go new file mode 100644 index 00000000000..68df6ce4b5d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultirolepoolskus.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListMultiRolePoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListMultiRolePoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +type ListMultiRolePoolSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePoolSkus ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkus(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolSkusCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/skus", 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 *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolSkusCompleteResult, error) { + return c.ListMultiRolePoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListMultiRolePoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate SkuInfoOperationPredicate) (result ListMultiRolePoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListMultiRolePoolSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListMultiRolePoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultiroleusages.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultiroleusages.go new file mode 100644 index 00000000000..a835e6f4109 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listmultiroleusages.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListMultiRoleUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListMultiRoleUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListMultiRoleUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRoleUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRoleUsages ... +func (c AppServiceEnvironmentsClient) ListMultiRoleUsages(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRoleUsagesCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleUsagesCompleteResult, error) { + return c.ListMultiRoleUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListMultiRoleUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate UsageOperationPredicate) (result ListMultiRoleUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListMultiRoleUsages(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListMultiRoleUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listoperations.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listoperations.go new file mode 100644 index 00000000000..cc96adc214e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listoperations.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +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 ListOperationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Operation +} + +// ListOperations ... +func (c AppServiceEnvironmentsClient) ListOperations(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListOperationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", 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 + } + + var model []Operation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listusages.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listusages.go new file mode 100644 index 00000000000..2fdba17a92e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listusages.go @@ -0,0 +1,135 @@ +package appserviceenvironments + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c AppServiceEnvironmentsClient) ListUsages(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebapps.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebapps.go new file mode 100644 index 00000000000..2c63e81b80b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebapps.go @@ -0,0 +1,135 @@ +package appserviceenvironments + +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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + PropertiesToInclude *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.PropertiesToInclude != nil { + out.Append("propertiesToInclude", fmt.Sprintf("%v", *o.PropertiesToInclude)) + } + return &out +} + +type ListWebAppsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebApps ... +func (c AppServiceEnvironmentsClient) ListWebApps(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListWebAppsCustomPager{}, + Path: fmt.Sprintf("%s/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkermetricdefinitions.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkermetricdefinitions.go new file mode 100644 index 00000000000..0d83ccdd738 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkermetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWebWorkerMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebWorkerMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebWorkerMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebWorkerMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerMetricDefinitionsCompleteResult, error) { + return c.ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWebWorkerMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWebWorkerMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWebWorkerMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebWorkerMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkerusages.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkerusages.go new file mode 100644 index 00000000000..380989d1a8d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listwebworkerusages.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWebWorkerUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListWebWorkerUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListWebWorkerUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebWorkerUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebWorkerUsages ... +func (c AppServiceEnvironmentsClient) ListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (result ListWebWorkerUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebWorkerUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerUsagesCompleteResult, error) { + return c.ListWebWorkerUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListWebWorkerUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate UsageOperationPredicate) (result ListWebWorkerUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListWebWorkerUsages(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebWorkerUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..283907aee09 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWorkerPoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolInstanceMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolInstanceMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsComplete(ctx context.Context, id WorkerPoolInstanceId) (ListWorkerPoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWorkerPoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWorkerPoolInstanceMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWorkerPoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpools.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpools.go new file mode 100644 index 00000000000..ec25afdb033 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpools.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +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 ListWorkerPoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListWorkerPoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +type ListWorkerPoolsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPools ... +func (c AppServiceEnvironmentsClient) ListWorkerPools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListWorkerPoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolsCustomPager{}, + Path: fmt.Sprintf("%s/workerPools", 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 *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListWorkerPoolsCompleteResult, error) { + return c.ListWorkerPoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListWorkerPoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListWorkerPoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListWorkerPools(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWorkerPoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolskus.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolskus.go new file mode 100644 index 00000000000..74192d0c7ec --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_listworkerpoolskus.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWorkerPoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListWorkerPoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +type ListWorkerPoolSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPoolSkus ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (result ListWorkerPoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolSkusCustomPager{}, + Path: fmt.Sprintf("%s/skus", 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 *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusComplete(ctx context.Context, id WorkerPoolId) (ListWorkerPoolSkusCompleteResult, error) { + return c.ListWorkerPoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListWorkerPoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate SkuInfoOperationPredicate) (result ListWorkerPoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListWorkerPoolSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWorkerPoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_reboot.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_reboot.go new file mode 100644 index 00000000000..da6ac719365 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_reboot.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +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 RebootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reboot ... +func (c AppServiceEnvironmentsClient) Reboot(ctx context.Context, id commonids.AppServiceEnvironmentId) (result RebootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_resume.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_resume.go new file mode 100644 index 00000000000..9cafc62c013 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_resume.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +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 ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ResumeCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ResumeCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ResumeCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Resume ... +func (c AppServiceEnvironmentsClient) Resume(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ResumeCustomPager{}, + Path: fmt.Sprintf("%s/resume", 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 +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c AppServiceEnvironmentsClient) ResumeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Resume(ctx, id) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_suspend.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_suspend.go new file mode 100644 index 00000000000..e6c388ed071 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_suspend.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +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 SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type SuspendCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type SuspendCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *SuspendCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Suspend ... +func (c AppServiceEnvironmentsClient) Suspend(ctx context.Context, id commonids.AppServiceEnvironmentId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &SuspendCustomPager{}, + Path: fmt.Sprintf("%s/suspend", 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 +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c AppServiceEnvironmentsClient) SuspendThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_testupgradeavailablenotification.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_testupgradeavailablenotification.go new file mode 100644 index 00000000000..3c1081f9144 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_testupgradeavailablenotification.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +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 TestUpgradeAvailableNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TestUpgradeAvailableNotification ... +func (c AppServiceEnvironmentsClient) TestUpgradeAvailableNotification(ctx context.Context, id commonids.AppServiceEnvironmentId) (result TestUpgradeAvailableNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testUpgradeAvailableNotification", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_update.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_update.go new file mode 100644 index 00000000000..eeba2343384 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_update.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Update ... +func (c AppServiceEnvironmentsClient) Update(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 + } + + var model AppServiceEnvironmentResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..84b44271ed7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go @@ -0,0 +1,59 @@ +package appserviceenvironments + +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 UpdateAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// UpdateAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input CustomDnsSuffixConfiguration) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasenetworkingconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasenetworkingconfiguration.go new file mode 100644 index 00000000000..d215f8021fa --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateasenetworkingconfiguration.go @@ -0,0 +1,59 @@ +package appserviceenvironments + +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 UpdateAseNetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// UpdateAseNetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseNetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input AseV3NetworkingConfiguration) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/networking", 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 + } + + var model AseV3NetworkingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_updatemultirolepool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_updatemultirolepool.go new file mode 100644 index 00000000000..22ee8b00991 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_updatemultirolepool.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +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 UpdateMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) UpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result UpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/multiRolePools/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 + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_updateworkerpool.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateworkerpool.go new file mode 100644 index 00000000000..42b61ccc4f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_updateworkerpool.go @@ -0,0 +1,58 @@ +package appserviceenvironments + +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 UpdateWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) UpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result UpdateWorkerPoolOperationResponse, 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 + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/method_upgrade.go b/resource-manager/web/2024-04-01/appserviceenvironments/method_upgrade.go new file mode 100644 index 00000000000..36584682ac1 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/method_upgrade.go @@ -0,0 +1,70 @@ +package appserviceenvironments + +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 UpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Upgrade ... +func (c AppServiceEnvironmentsClient) Upgrade(ctx context.Context, id commonids.AppServiceEnvironmentId) (result UpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", 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 +} + +// UpgradeThenPoll performs Upgrade then polls until it's completed +func (c AppServiceEnvironmentsClient) UpgradeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Upgrade(ctx, id) + if err != nil { + return fmt.Errorf("performing Upgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Upgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponse.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponse.go new file mode 100644 index 00000000000..5949ada3aeb --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponse.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AddressResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponseproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponseproperties.go new file mode 100644 index 00000000000..22241e69975 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_addressresponseproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponseProperties struct { + InternalIPAddress *string `json:"internalIpAddress,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ServiceIPAddress *string `json:"serviceIpAddress,omitempty"` + VipMappings *[]VirtualIPMapping `json:"vipMappings,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_apidefinitioninfo.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_apidefinitioninfo.go new file mode 100644 index 00000000000..b29b3fb28ec --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_apimanagementconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_apimanagementconfig.go new file mode 100644 index 00000000000..eca6e5d45b9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironment.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironment.go new file mode 100644 index 00000000000..7e868462756 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go new file mode 100644 index 00000000000..594e57510dd --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentresource.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentresource.go new file mode 100644 index 00000000000..31263ba6394 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceenvironmentresource.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplan.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplan.go new file mode 100644 index 00000000000..499328be215 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplanproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplanproperties.go new file mode 100644 index 00000000000..df541821251 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_appserviceplanproperties.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +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 AppServicePlanProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_armidwrapper.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_armidwrapper.go new file mode 100644 index 00000000000..23291cc1624 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_armidwrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..dd9c6b64a48 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..82c8e80d94e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealactions.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealactions.go new file mode 100644 index 00000000000..a53db3433d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealcustomaction.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealcustomaction.go new file mode 100644 index 00000000000..b4979e90b7a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealrules.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealrules.go new file mode 100644 index 00000000000..cd835879fe2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealtriggers.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealtriggers.go new file mode 100644 index 00000000000..2d6842a3f7d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_azurestorageinfovalue.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..57e32f54dc0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_capability.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_capability.go new file mode 100644 index 00000000000..6b07c220bef --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_capability.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_cloninginfo.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_cloninginfo.go new file mode 100644 index 00000000000..f9505ee3c37 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_connstringinfo.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_connstringinfo.go new file mode 100644 index 00000000000..a4172f89872 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_corssettings.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_corssettings.go new file mode 100644 index 00000000000..24390a28726 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_csmusagequota.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_csmusagequota.go new file mode 100644 index 00000000000..0ba4a1dd059 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceenvironments + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfiguration.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..ed5fdcd1b9a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..54d57c9d118 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateURL *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_daprconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_daprconfig.go new file mode 100644 index 00000000000..9268fd62dc0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdependency.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdependency.go new file mode 100644 index 00000000000..9840103ce20 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdependency.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdetail.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdetail.go new file mode 100644 index 00000000000..d738ebeb260 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_endpointdetail.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + IPAddress *string `json:"ipAddress,omitempty"` + IsAccessible *bool `json:"isAccessible,omitempty"` + Latency *float64 `json:"latency,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_errorentity.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_errorentity.go new file mode 100644 index 00000000000..8125008a5d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_errorentity.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_experiments.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_experiments.go new file mode 100644 index 00000000000..9bd9653d59f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_extendedlocation.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..b24df8493f9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// 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 *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionappconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionappconfig.go new file mode 100644 index 00000000000..e3733b6a7c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..7034ed11de4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeployment.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeployment.go new file mode 100644 index 00000000000..4b819404793 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorage.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..de4f6231617 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..deebac5deb3 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsruntime.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsruntime.go new file mode 100644 index 00000000000..b0fc099b28b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..98d876cc3d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..28d4106d6fb --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..06c763b2e79 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_handlermapping.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_handlermapping.go new file mode 100644 index 00000000000..add89600372 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go new file mode 100644 index 00000000000..1d298e705f6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDiagnostics struct { + DiagnosticsOutput *string `json:"diagnosticsOutput,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentprofile.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e67fbad99e5 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_hostnamesslstate.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostnamesslstate.go new file mode 100644 index 00000000000..b60ed2b41ef --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_inboundenvironmentendpoint.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_inboundenvironmentendpoint.go new file mode 100644 index 00000000000..83dea79b75b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_inboundenvironmentendpoint.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundEnvironmentEndpoint struct { + Description *string `json:"description,omitempty"` + Endpoints *[]string `json:"endpoints,omitempty"` + Ports *[]string `json:"ports,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_ipsecurityrestriction.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..cce3b7521d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_kubeenvironmentprofile.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..1ad013915fa --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_localizablestring.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_localizablestring.go new file mode 100644 index 00000000000..5974acdfb1a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_namevaluepair.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_namevaluepair.go new file mode 100644 index 00000000000..ac9cb553c36 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_operation.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_operation.go new file mode 100644 index 00000000000..e226cf16987 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_operation.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +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 Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_outboundenvironmentendpoint.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..04928bef582 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkconnectionstate.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..86ca1b14e24 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresource.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresource.go new file mode 100644 index 00000000000..1b58321d272 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..ecd58509b6f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..40cc8c0e8b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettings.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettings.go new file mode 100644 index 00000000000..addca78ae4d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettingsproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettingsproperties.go new file mode 100644 index 00000000000..6c80542248a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_rampuprule.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_rampuprule.go new file mode 100644 index 00000000000..0db6bb0db58 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..314760728b6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..a96786cf386 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_requestsbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..57351c32612 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_resourceconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourceconfig.go new file mode 100644 index 00000000000..d6f6c721d3c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricavailability.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricavailability.go new file mode 100644 index 00000000000..2688445beaa --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricavailability.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricAvailability struct { + Retention *string `json:"retention,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinition.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinition.go new file mode 100644 index 00000000000..8645bb913f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinition.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceMetricDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go new file mode 100644 index 00000000000..d1d6856879a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinitionProperties struct { + MetricAvailabilities *[]ResourceMetricAvailability `json:"metricAvailabilities,omitempty"` + PrimaryAggregationType *string `json:"primaryAggregationType,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_site.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_site.go new file mode 100644 index 00000000000..a09cdcffac4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_site.go @@ -0,0 +1,20 @@ +package appserviceenvironments + +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 Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_siteconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_siteconfig.go new file mode 100644 index 00000000000..df4daa18008 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_siteconfig.go @@ -0,0 +1,97 @@ +package appserviceenvironments + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_sitednsconfig.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitednsconfig.go new file mode 100644 index 00000000000..4b4479a9c71 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_sitelimits.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitelimits.go new file mode 100644 index 00000000000..b3130e580f6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_sitemachinekey.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitemachinekey.go new file mode 100644 index 00000000000..267ce523b14 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_siteproperties.go new file mode 100644 index 00000000000..1135dfbdc3e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_siteproperties.go @@ -0,0 +1,93 @@ +package appserviceenvironments + +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 SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_skucapacity.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_skucapacity.go new file mode 100644 index 00000000000..2e04c5df978 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_skudescription.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_skudescription.go new file mode 100644 index 00000000000..47f1a308d34 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_skuinfo.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_skuinfo.go new file mode 100644 index 00000000000..9faba036b8a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_skuinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfo struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_slotswapstatus.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_slotswapstatus.go new file mode 100644 index 00000000000..ae1901b782c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceenvironments + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..ef74f6f556b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_stampcapacity.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_stampcapacity.go new file mode 100644 index 00000000000..138ebe09348 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_stampcapacity.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StampCapacity struct { + AvailableCapacity *int64 `json:"availableCapacity,omitempty"` + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + ExcludeFromCapacityAllocation *bool `json:"excludeFromCapacityAllocation,omitempty"` + IsApplicableForAllComputeModes *bool `json:"isApplicableForAllComputeModes,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` + Name *string `json:"name,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + TotalCapacity *int64 `json:"totalCapacity,omitempty"` + Unit *string `json:"unit,omitempty"` + WorkerSize *WorkerSizeOptions `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..633cfec8a5e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..ccbeced17af --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_usage.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_usage.go new file mode 100644 index 00000000000..7e9e07f4502 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_usage.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UsageProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_usageproperties.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_usageproperties.go new file mode 100644 index 00000000000..8b0f3272bdf --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_usageproperties.go @@ -0,0 +1,33 @@ +package appserviceenvironments + +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 UsageProperties struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + CurrentValue *int64 `json:"currentValue,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Limit *int64 `json:"limit,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *UsageProperties) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsageProperties) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualapplication.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualapplication.go new file mode 100644 index 00000000000..bdac22a3474 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualdirectory.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualdirectory.go new file mode 100644 index 00000000000..f4c38830a4c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualipmapping.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualipmapping.go new file mode 100644 index 00000000000..dc88e33ecba --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualipmapping.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualIPMapping struct { + InUse *bool `json:"inUse,omitempty"` + InternalHTTPPort *int64 `json:"internalHttpPort,omitempty"` + InternalHTTPSPort *int64 `json:"internalHttpsPort,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualnetworkprofile.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..d01868e107b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpool.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpool.go new file mode 100644 index 00000000000..fbb7707c437 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpool.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPool struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + InstanceNames *[]string `json:"instanceNames,omitempty"` + WorkerCount *int64 `json:"workerCount,omitempty"` + WorkerSize *string `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpoolresource.go b/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpoolresource.go new file mode 100644 index 00000000000..6a4150ac46d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/model_workerpoolresource.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPoolResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkerPool `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceenvironments/predicates.go b/resource-manager/web/2024-04-01/appserviceenvironments/predicates.go new file mode 100644 index 00000000000..96a5324bde9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/predicates.go @@ -0,0 +1,335 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceEnvironmentResourceOperationPredicate) Matches(input AppServiceEnvironmentResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type InboundEnvironmentEndpointOperationPredicate struct { + Description *string +} + +func (p InboundEnvironmentEndpointOperationPredicate) Matches(input InboundEnvironmentEndpoint) bool { + + if p.Description != nil && (input.Description == nil || *p.Description != *input.Description) { + return false + } + + return true +} + +type OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ResourceMetricDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceMetricDefinitionOperationPredicate) Matches(input ResourceMetricDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SkuInfoOperationPredicate struct { + ResourceType *string +} + +func (p SkuInfoOperationPredicate) Matches(input SkuInfo) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} + +type StampCapacityOperationPredicate struct { + AvailableCapacity *int64 + ExcludeFromCapacityAllocation *bool + IsApplicableForAllComputeModes *bool + IsLinux *bool + Name *string + SiteMode *string + TotalCapacity *int64 + Unit *string + WorkerSizeId *int64 +} + +func (p StampCapacityOperationPredicate) Matches(input StampCapacity) bool { + + if p.AvailableCapacity != nil && (input.AvailableCapacity == nil || *p.AvailableCapacity != *input.AvailableCapacity) { + return false + } + + if p.ExcludeFromCapacityAllocation != nil && (input.ExcludeFromCapacityAllocation == nil || *p.ExcludeFromCapacityAllocation != *input.ExcludeFromCapacityAllocation) { + return false + } + + if p.IsApplicableForAllComputeModes != nil && (input.IsApplicableForAllComputeModes == nil || *p.IsApplicableForAllComputeModes != *input.IsApplicableForAllComputeModes) { + return false + } + + if p.IsLinux != nil && (input.IsLinux == nil || *p.IsLinux != *input.IsLinux) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.SiteMode != nil && (input.SiteMode == nil || *p.SiteMode != *input.SiteMode) { + return false + } + + if p.TotalCapacity != nil && (input.TotalCapacity == nil || *p.TotalCapacity != *input.TotalCapacity) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + if p.WorkerSizeId != nil && (input.WorkerSizeId == nil || *p.WorkerSizeId != *input.WorkerSizeId) { + return false + } + + return true +} + +type UsageOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WorkerPoolResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WorkerPoolResourceOperationPredicate) Matches(input WorkerPoolResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/appserviceenvironments/version.go b/resource-manager/web/2024-04-01/appserviceenvironments/version.go new file mode 100644 index 00000000000..0f243c103ff --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceenvironments/version.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appserviceenvironments/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/README.md b/resource-manager/web/2024-04-01/appserviceplans/README.md new file mode 100644 index 00000000000..c6fb610fb6d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/README.md @@ -0,0 +1,480 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceplans` Documentation + +The `appserviceplans` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceplans" +``` + + +### Client Initialization + +```go +client := appserviceplans.NewAppServicePlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +payload := appserviceplans.AppServicePlan{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.CreateOrUpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +read, err := client.DeleteVnetRoute(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +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: `AppServicePlansClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetHybridConnectionPlanLimit` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.GetHybridConnectionPlanLimit(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetRouteForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +read, err := client.GetRouteForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetServerFarmSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.GetServerFarmSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetFromServerFarm` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + +read, err := client.GetVnetFromServerFarm(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, appserviceplans.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, appserviceplans.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListCapabilities` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.ListCapabilities(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnectionKeys` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.ListHybridConnectionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListHybridConnections(ctx, id)` can be used to do batched pagination +items, err := client.ListHybridConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListRoutesForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + +read, err := client.ListRoutesForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListUsages(ctx, id, appserviceplans.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceplans.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListVnets` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.ListVnets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListWebApps(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebAppsByHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +// alternatively `client.ListWebAppsByHybridConnection(ctx, id)` can be used to do batched pagination +items, err := client.ListWebAppsByHybridConnectionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.RebootWorker` + +```go +ctx := context.TODO() +id := appserviceplans.NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName") + +read, err := client.RebootWorker(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.RestartWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.RestartWebApps(ctx, id, appserviceplans.DefaultRestartWebAppsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +payload := appserviceplans.AppServicePlanPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + +payload := appserviceplans.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.UpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/appserviceplans/client.go b/resource-manager/web/2024-04-01/appserviceplans/client.go new file mode 100644 index 00000000000..9afc7d23899 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/client.go @@ -0,0 +1,26 @@ +package appserviceplans + +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 AppServicePlansClient struct { + Client *resourcemanager.Client +} + +func NewAppServicePlansClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServicePlansClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appserviceplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServicePlansClient: %+v", err) + } + + return &AppServicePlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/constants.go b/resource-manager/web/2024-04-01/appserviceplans/constants.go new file mode 100644 index 00000000000..2a92bf77d55 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/constants.go @@ -0,0 +1,1365 @@ +package appserviceplans + +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 AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay.go b/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..31cf0010bc4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionNamespaceRelayId{} + +// HybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Hybrid Connection Namespace Relay +type HybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewHybridConnectionNamespaceRelayID returns a new HybridConnectionNamespaceRelayId struct +func NewHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, serverFarmName string, hybridConnectionNamespaceName string, relayName string) HybridConnectionNamespaceRelayId { + return HybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseHybridConnectionNamespaceRelayID parses 'input' into a HybridConnectionNamespaceRelayId +func ParseHybridConnectionNamespaceRelayID(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a HybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionNamespaceRelayIDInsensitively(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionNamespaceRelayId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Hybrid Connection Namespace Relay ID +func ValidateHybridConnectionNamespaceRelayID(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 := ParseHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go b/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..ca8a17b9536 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &HybridConnectionNamespaceRelayId{} + +func TestNewHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + + 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.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayID(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayIDInsensitively(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForHybridConnectionNamespaceRelayId(t *testing.T) { + segments := HybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionNamespaceRelayId 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/web/2024-04-01/appserviceplans/id_route.go b/resource-manager/web/2024-04-01/appserviceplans/id_route.go new file mode 100644 index 00000000000..4368f47c094 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_route.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RouteId{}) +} + +var _ resourceids.ResourceId = &RouteId{} + +// RouteId is a struct representing the Resource ID for a Route +type RouteId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + RouteName string +} + +// NewRouteID returns a new RouteId struct +func NewRouteID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, routeName string) RouteId { + return RouteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + RouteName: routeName, + } +} + +// ParseRouteID parses 'input' into a RouteId +func ParseRouteID(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteIDInsensitively parses 'input' case-insensitively into a RouteId +// note: this method should only be used for API response data and not user input +func ParseRouteIDInsensitively(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.RouteName, ok = input.Parsed["routeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeName", input) + } + + return nil +} + +// ValidateRouteID checks that 'input' can be parsed as a Route ID +func ValidateRouteID(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 := ParseRouteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route ID +func (id RouteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/routes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.RouteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route ID +func (id RouteId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticRoutes", "routes", "routes"), + resourceids.UserSpecifiedSegment("routeName", "routeName"), + } +} + +// String returns a human-readable description of this Route ID +func (id RouteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Route Name: %q", id.RouteName), + } + return fmt.Sprintf("Route (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_route_test.go b/resource-manager/web/2024-04-01/appserviceplans/id_route_test.go new file mode 100644 index 00000000000..ec524514b68 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_route_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &RouteId{} + +func TestNewRouteID(t *testing.T) { + id := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + + 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.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.RouteName != "routeName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteName'", id.RouteName, "routeName") + } +} + +func TestFormatRouteID(t *testing.T) { + actual := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteID(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestParseRouteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS/rOuTeNaMe", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + RouteName: "rOuTeNaMe", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS/rOuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteIDInsensitively(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestSegmentsForRouteId(t *testing.T) { + segments := RouteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteId 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/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go b/resource-manager/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go new file mode 100644 index 00000000000..5d43668ff23 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ServerFarmVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &ServerFarmVirtualNetworkConnectionId{} + +// ServerFarmVirtualNetworkConnectionId is a struct representing the Resource ID for a Server Farm Virtual Network Connection +type ServerFarmVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string +} + +// NewServerFarmVirtualNetworkConnectionID returns a new ServerFarmVirtualNetworkConnectionId struct +func NewServerFarmVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string) ServerFarmVirtualNetworkConnectionId { + return ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseServerFarmVirtualNetworkConnectionID parses 'input' into a ServerFarmVirtualNetworkConnectionId +func ParseServerFarmVirtualNetworkConnectionID(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServerFarmVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a ServerFarmVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseServerFarmVirtualNetworkConnectionIDInsensitively(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServerFarmVirtualNetworkConnectionId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateServerFarmVirtualNetworkConnectionID checks that 'input' can be parsed as a Server Farm Virtual Network Connection ID +func ValidateServerFarmVirtualNetworkConnectionID(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 := ParseServerFarmVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Server Farm Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go b/resource-manager/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..5601db88695 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +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 = &ServerFarmVirtualNetworkConnectionId{} + +func TestNewServerFarmVirtualNetworkConnectionID(t *testing.T) { + id := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + + 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.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatServerFarmVirtualNetworkConnectionID(t *testing.T) { + actual := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServerFarmVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionID(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseServerFarmVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionIDInsensitively(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForServerFarmVirtualNetworkConnectionId(t *testing.T) { + segments := ServerFarmVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServerFarmVirtualNetworkConnectionId 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/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway.go b/resource-manager/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..4ccedb2d7ce --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionGatewayId{} + +// VirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Virtual Network Connection Gateway +type VirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewVirtualNetworkConnectionGatewayID returns a new VirtualNetworkConnectionGatewayId struct +func NewVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, gatewayName string) VirtualNetworkConnectionGatewayId { + return VirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseVirtualNetworkConnectionGatewayID parses 'input' into a VirtualNetworkConnectionGatewayId +func ParseVirtualNetworkConnectionGatewayID(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionGatewayIDInsensitively(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionGatewayId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Virtual Network Connection Gateway ID +func ValidateVirtualNetworkConnectionGatewayID(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 := ParseVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go b/resource-manager/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..d542242e414 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &VirtualNetworkConnectionGatewayId{} + +func TestNewVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + + 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.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayID(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayIDInsensitively(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := VirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionGatewayId 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/web/2024-04-01/appserviceplans/id_worker.go b/resource-manager/web/2024-04-01/appserviceplans/id_worker.go new file mode 100644 index 00000000000..31d71dbd008 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_worker.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkerId{}) +} + +var _ resourceids.ResourceId = &WorkerId{} + +// WorkerId is a struct representing the Resource ID for a Worker +type WorkerId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + WorkerName string +} + +// NewWorkerID returns a new WorkerId struct +func NewWorkerID(subscriptionId string, resourceGroupName string, serverFarmName string, workerName string) WorkerId { + return WorkerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + WorkerName: workerName, + } +} + +// ParseWorkerID parses 'input' into a WorkerId +func ParseWorkerID(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerIDInsensitively parses 'input' case-insensitively into a WorkerId +// note: this method should only be used for API response data and not user input +func ParseWorkerIDInsensitively(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.WorkerName, ok = input.Parsed["workerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerName", input) + } + + return nil +} + +// ValidateWorkerID checks that 'input' can be parsed as a Worker ID +func ValidateWorkerID(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 := ParseWorkerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker ID +func (id WorkerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/workers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.WorkerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker ID +func (id WorkerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticWorkers", "workers", "workers"), + resourceids.UserSpecifiedSegment("workerName", "workerName"), + } +} + +// String returns a human-readable description of this Worker ID +func (id WorkerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Worker Name: %q", id.WorkerName), + } + return fmt.Sprintf("Worker (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/id_worker_test.go b/resource-manager/web/2024-04-01/appserviceplans/id_worker_test.go new file mode 100644 index 00000000000..9113edebceb --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/id_worker_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +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 = &WorkerId{} + +func TestNewWorkerID(t *testing.T) { + id := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName") + + 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.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.WorkerName != "workerName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerName'", id.WorkerName, "workerName") + } +} + +func TestFormatWorkerID(t *testing.T) { + actual := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + WorkerName: "workerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerID(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestParseWorkerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + WorkerName: "workerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs/wOrKeRnAmE", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + WorkerName: "wOrKeRnAmE", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs/wOrKeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerIDInsensitively(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.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestSegmentsForWorkerId(t *testing.T) { + segments := WorkerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerId 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/web/2024-04-01/appserviceplans/method_createorupdate.go b/resource-manager/web/2024-04-01/appserviceplans/method_createorupdate.go new file mode 100644 index 00000000000..130e220ffb1 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_createorupdate.go @@ -0,0 +1,76 @@ +package appserviceplans + +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 + Model *AppServicePlan +} + +// CreateOrUpdate ... +func (c AppServicePlansClient) CreateOrUpdate(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 AppServicePlansClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) 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/web/2024-04-01/appserviceplans/method_createorupdatevnetroute.go b/resource-manager/web/2024-04-01/appserviceplans/method_createorupdatevnetroute.go new file mode 100644 index 00000000000..a25c348ca80 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_createorupdatevnetroute.go @@ -0,0 +1,57 @@ +package appserviceplans + +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 CreateOrUpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// CreateOrUpdateVnetRoute ... +func (c AppServicePlansClient) CreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result CreateOrUpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_delete.go b/resource-manager/web/2024-04-01/appserviceplans/method_delete.go new file mode 100644 index 00000000000..4d95de15002 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_delete.go @@ -0,0 +1,48 @@ +package appserviceplans + +import ( + "context" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServicePlansClient) Delete(ctx context.Context, id commonids.AppServicePlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_deletehybridconnection.go b/resource-manager/web/2024-04-01/appserviceplans/method_deletehybridconnection.go new file mode 100644 index 00000000000..e886d4067bc --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_deletehybridconnection.go @@ -0,0 +1,47 @@ +package appserviceplans + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c AppServicePlansClient) DeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_deletevnetroute.go b/resource-manager/web/2024-04-01/appserviceplans/method_deletevnetroute.go new file mode 100644 index 00000000000..ad025ea00a2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_deletevnetroute.go @@ -0,0 +1,46 @@ +package appserviceplans + +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 DeleteVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetRoute ... +func (c AppServicePlansClient) DeleteVnetRoute(ctx context.Context, id RouteId) (result DeleteVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_get.go b/resource-manager/web/2024-04-01/appserviceplans/method_get.go new file mode 100644 index 00000000000..e8c9fc7e49c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_get.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "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 *AppServicePlan +} + +// Get ... +func (c AppServicePlansClient) Get(ctx context.Context, id commonids.AppServicePlanId) (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 + } + + var model AppServicePlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnection.go b/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnection.go new file mode 100644 index 00000000000..76d08712a13 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnection.go @@ -0,0 +1,53 @@ +package appserviceplans + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c AppServicePlansClient) GetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result GetHybridConnectionOperationResponse, 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnectionplanlimit.go b/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnectionplanlimit.go new file mode 100644 index 00000000000..5fdd323b80c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_gethybridconnectionplanlimit.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 GetHybridConnectionPlanLimitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionLimits +} + +// GetHybridConnectionPlanLimit ... +func (c AppServicePlansClient) GetHybridConnectionPlanLimit(ctx context.Context, id commonids.AppServicePlanId) (result GetHybridConnectionPlanLimitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionPlanLimits/limit", 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 + } + + var model HybridConnectionLimits + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_getrouteforvnet.go b/resource-manager/web/2024-04-01/appserviceplans/method_getrouteforvnet.go new file mode 100644 index 00000000000..43c608e9890 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_getrouteforvnet.go @@ -0,0 +1,53 @@ +package appserviceplans + +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 GetRouteForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// GetRouteForVnet ... +func (c AppServicePlansClient) GetRouteForVnet(ctx context.Context, id RouteId) (result GetRouteForVnetOperationResponse, 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 + } + + var model []VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_getserverfarmskus.go b/resource-manager/web/2024-04-01/appserviceplans/method_getserverfarmskus.go new file mode 100644 index 00000000000..bbd1499852a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_getserverfarmskus.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 GetServerFarmSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetServerFarmSkus ... +func (c AppServicePlansClient) GetServerFarmSkus(ctx context.Context, id commonids.AppServicePlanId) (result GetServerFarmSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_getvnetfromserverfarm.go b/resource-manager/web/2024-04-01/appserviceplans/method_getvnetfromserverfarm.go new file mode 100644 index 00000000000..650f8a3926f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_getvnetfromserverfarm.go @@ -0,0 +1,53 @@ +package appserviceplans + +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 GetVnetFromServerFarmOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetFromServerFarm ... +func (c AppServicePlansClient) GetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result GetVnetFromServerFarmOperationResponse, 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_getvnetgateway.go b/resource-manager/web/2024-04-01/appserviceplans/method_getvnetgateway.go new file mode 100644 index 00000000000..f1892454285 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_getvnetgateway.go @@ -0,0 +1,53 @@ +package appserviceplans + +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 GetVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetGateway ... +func (c AppServicePlansClient) GetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (result GetVnetGatewayOperationResponse, 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_list.go b/resource-manager/web/2024-04-01/appserviceplans/method_list.go new file mode 100644 index 00000000000..6487ac4dcb4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_list.go @@ -0,0 +1,135 @@ +package appserviceplans + +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 *[]AppServicePlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListOperationOptions struct { + Detailed *bool +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Detailed != nil { + out.Append("detailed", fmt.Sprintf("%v", *o.Detailed)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServicePlansClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", 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 *[]AppServicePlan `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 AppServicePlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AppServicePlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AppServicePlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/appserviceplans/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/appserviceplans/method_listbyresourcegroup.go new file mode 100644 index 00000000000..8a92a8bb9a4 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appserviceplans + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServicePlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", 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 *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServicePlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listcapabilities.go b/resource-manager/web/2024-04-01/appserviceplans/method_listcapabilities.go new file mode 100644 index 00000000000..2c65ef4aae9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listcapabilities.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 ListCapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Capability +} + +// ListCapabilities ... +func (c AppServicePlansClient) ListCapabilities(ctx context.Context, id commonids.AppServicePlanId) (result ListCapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", 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 + } + + var model []Capability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnectionkeys.go b/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnectionkeys.go new file mode 100644 index 00000000000..78f4e16f7b6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnectionkeys.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListHybridConnectionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionKey +} + +// ListHybridConnectionKeys ... +func (c AppServicePlansClient) ListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListHybridConnectionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 + } + + var model HybridConnectionKey + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnections.go b/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnections.go new file mode 100644 index 00000000000..397cbb6929c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listhybridconnections.go @@ -0,0 +1,106 @@ +package appserviceplans + +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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListHybridConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HybridConnection +} + +type ListHybridConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHybridConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHybridConnections ... +func (c AppServicePlansClient) ListHybridConnections(ctx context.Context, id commonids.AppServicePlanId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHybridConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHybridConnectionsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListHybridConnectionsComplete(ctx context.Context, id commonids.AppServicePlanId) (ListHybridConnectionsCompleteResult, error) { + return c.ListHybridConnectionsCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListHybridConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListHybridConnectionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, predicate HybridConnectionOperationPredicate) (result ListHybridConnectionsCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListHybridConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHybridConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listroutesforvnet.go b/resource-manager/web/2024-04-01/appserviceplans/method_listroutesforvnet.go new file mode 100644 index 00000000000..cea1ee3b594 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listroutesforvnet.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListRoutesForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// ListRoutesForVnet ... +func (c AppServicePlansClient) ListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result ListRoutesForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routes", 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 + } + + var model []VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listusages.go b/resource-manager/web/2024-04-01/appserviceplans/method_listusages.go new file mode 100644 index 00000000000..11927a25518 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listusages.go @@ -0,0 +1,135 @@ +package appserviceplans + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c AppServicePlansClient) ListUsages(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListUsagesComplete(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listvnets.go b/resource-manager/web/2024-04-01/appserviceplans/method_listvnets.go new file mode 100644 index 00000000000..1779fca1033 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listvnets.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 ListVnetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnets ... +func (c AppServicePlansClient) ListVnets(ctx context.Context, id commonids.AppServicePlanId) (result ListVnetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listwebapps.go b/resource-manager/web/2024-04-01/appserviceplans/method_listwebapps.go new file mode 100644 index 00000000000..112b9dd14f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listwebapps.go @@ -0,0 +1,139 @@ +package appserviceplans + +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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + Filter *string + Top *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListWebAppsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebApps ... +func (c AppServicePlansClient) ListWebApps(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListWebAppsCustomPager{}, + Path: fmt.Sprintf("%s/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_listwebappsbyhybridconnection.go b/resource-manager/web/2024-04-01/appserviceplans/method_listwebappsbyhybridconnection.go new file mode 100644 index 00000000000..84d13849999 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_listwebappsbyhybridconnection.go @@ -0,0 +1,98 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListWebAppsByHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type ListWebAppsByHybridConnectionCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type ListWebAppsByHybridConnectionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsByHybridConnectionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebAppsByHybridConnection ... +func (c AppServicePlansClient) ListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebAppsByHybridConnectionCustomPager{}, + Path: fmt.Sprintf("%s/sites", 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsByHybridConnectionComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsByHybridConnectionComplete(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.ListWebAppsByHybridConnection(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListWebAppsByHybridConnectionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_rebootworker.go b/resource-manager/web/2024-04-01/appserviceplans/method_rebootworker.go new file mode 100644 index 00000000000..b1e54e3cffe --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_rebootworker.go @@ -0,0 +1,47 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 RebootWorkerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RebootWorker ... +func (c AppServicePlansClient) RebootWorker(ctx context.Context, id WorkerId) (result RebootWorkerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_restartwebapps.go b/resource-manager/web/2024-04-01/appserviceplans/method_restartwebapps.go new file mode 100644 index 00000000000..e6b604d940c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_restartwebapps.go @@ -0,0 +1,77 @@ +package appserviceplans + +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 RestartWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartWebAppsOperationOptions struct { + SoftRestart *bool +} + +func DefaultRestartWebAppsOperationOptions() RestartWebAppsOperationOptions { + return RestartWebAppsOperationOptions{} +} + +func (o RestartWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + return &out +} + +// RestartWebApps ... +func (c AppServicePlansClient) RestartWebApps(ctx context.Context, id commonids.AppServicePlanId, options RestartWebAppsOperationOptions) (result RestartWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/restartSites", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_update.go b/resource-manager/web/2024-04-01/appserviceplans/method_update.go new file mode 100644 index 00000000000..cc2bebbb8cc --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_update.go @@ -0,0 +1,59 @@ +package appserviceplans + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Update ... +func (c AppServicePlansClient) Update(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlanPatchResource) (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 + } + + var model AppServicePlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetgateway.go b/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetgateway.go new file mode 100644 index 00000000000..084885def91 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetgateway.go @@ -0,0 +1,57 @@ +package appserviceplans + +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 UpdateVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetGateway ... +func (c AppServicePlansClient) UpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetroute.go b/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetroute.go new file mode 100644 index 00000000000..0d8db289b93 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/method_updatevnetroute.go @@ -0,0 +1,57 @@ +package appserviceplans + +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 UpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// UpdateVnetRoute ... +func (c AppServicePlansClient) UpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result UpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_apidefinitioninfo.go b/resource-manager/web/2024-04-01/appserviceplans/model_apidefinitioninfo.go new file mode 100644 index 00000000000..2ac5fa81cba --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_apimanagementconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_apimanagementconfig.go new file mode 100644 index 00000000000..dab0ea80e65 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplan.go b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplan.go new file mode 100644 index 00000000000..939499f257a --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresource.go b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresource.go new file mode 100644 index 00000000000..e2e21fc04a7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresourceproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresourceproperties.go new file mode 100644 index 00000000000..efdb53cdcff --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanpatchresourceproperties.go @@ -0,0 +1,60 @@ +package appserviceplans + +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 AppServicePlanPatchResourceProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanPatchResourceProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanPatchResourceProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanproperties.go new file mode 100644 index 00000000000..6fde086c9ed --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_appserviceplanproperties.go @@ -0,0 +1,60 @@ +package appserviceplans + +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 AppServicePlanProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_autohealactions.go b/resource-manager/web/2024-04-01/appserviceplans/model_autohealactions.go new file mode 100644 index 00000000000..e32290fd78e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_autohealcustomaction.go b/resource-manager/web/2024-04-01/appserviceplans/model_autohealcustomaction.go new file mode 100644 index 00000000000..2b7e2af847d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_autohealrules.go b/resource-manager/web/2024-04-01/appserviceplans/model_autohealrules.go new file mode 100644 index 00000000000..6da2d1028df --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_autohealtriggers.go b/resource-manager/web/2024-04-01/appserviceplans/model_autohealtriggers.go new file mode 100644 index 00000000000..a3c3a7fe781 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_azurestorageinfovalue.go b/resource-manager/web/2024-04-01/appserviceplans/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..0c62698b97b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_capability.go b/resource-manager/web/2024-04-01/appserviceplans/model_capability.go new file mode 100644 index 00000000000..0cfebd66ae9 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_capability.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_cloninginfo.go b/resource-manager/web/2024-04-01/appserviceplans/model_cloninginfo.go new file mode 100644 index 00000000000..5d297b188da --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_connstringinfo.go b/resource-manager/web/2024-04-01/appserviceplans/model_connstringinfo.go new file mode 100644 index 00000000000..367ae1ac201 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_corssettings.go b/resource-manager/web/2024-04-01/appserviceplans/model_corssettings.go new file mode 100644 index 00000000000..ec523b9ae12 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_csmusagequota.go b/resource-manager/web/2024-04-01/appserviceplans/model_csmusagequota.go new file mode 100644 index 00000000000..24ec9c595c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceplans + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_daprconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_daprconfig.go new file mode 100644 index 00000000000..bd07c41dcc8 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_experiments.go b/resource-manager/web/2024-04-01/appserviceplans/model_experiments.go new file mode 100644 index 00000000000..c10e0c96da0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_extendedlocation.go b/resource-manager/web/2024-04-01/appserviceplans/model_extendedlocation.go new file mode 100644 index 00000000000..9e237794a1d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceplans + +// 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 *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionappconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionappconfig.go new file mode 100644 index 00000000000..5eb3b499888 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..bfd0d3eab01 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeployment.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeployment.go new file mode 100644 index 00000000000..41f4213a7c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorage.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..49254f5989c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..e194eb9b172 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsruntime.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsruntime.go new file mode 100644 index 00000000000..d04994cdbd0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..048b6d942a7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..9a87d6ba0f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..d547bd4d367 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_handlermapping.go b/resource-manager/web/2024-04-01/appserviceplans/model_handlermapping.go new file mode 100644 index 00000000000..2b0fd51c628 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hostingenvironmentprofile.go b/resource-manager/web/2024-04-01/appserviceplans/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..3e6d1e245c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hostnamesslstate.go b/resource-manager/web/2024-04-01/appserviceplans/model_hostnamesslstate.go new file mode 100644 index 00000000000..eb49e879dbe --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnection.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnection.go new file mode 100644 index 00000000000..92deac554e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnection.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkey.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkey.go new file mode 100644 index 00000000000..95cbaf8d9c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkey.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKey struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionKeyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkeyproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkeyproperties.go new file mode 100644 index 00000000000..b9d55a5c698 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionkeyproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKeyProperties struct { + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimits.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimits.go new file mode 100644 index 00000000000..1463d5e4dbf --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimits.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimits struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionLimitsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimitsproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimitsproperties.go new file mode 100644 index 00000000000..a462d888655 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionlimitsproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimitsProperties struct { + Current *int64 `json:"current,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..93e6f70afd6 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_ipsecurityrestriction.go b/resource-manager/web/2024-04-01/appserviceplans/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..d1bf7483ffc --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_kubeenvironmentprofile.go b/resource-manager/web/2024-04-01/appserviceplans/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..a8c2c586a76 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_localizablestring.go b/resource-manager/web/2024-04-01/appserviceplans/model_localizablestring.go new file mode 100644 index 00000000000..3f1e149630e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_namevaluepair.go b/resource-manager/web/2024-04-01/appserviceplans/model_namevaluepair.go new file mode 100644 index 00000000000..8810fa8f3de --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_pushsettings.go b/resource-manager/web/2024-04-01/appserviceplans/model_pushsettings.go new file mode 100644 index 00000000000..4dc8d4fea82 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_pushsettingsproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_pushsettingsproperties.go new file mode 100644 index 00000000000..beae479c519 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_rampuprule.go b/resource-manager/web/2024-04-01/appserviceplans/model_rampuprule.go new file mode 100644 index 00000000000..424344dba00 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_requestsbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceplans/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..3858f02d387 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_resourceconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_resourceconfig.go new file mode 100644 index 00000000000..3998b6a1a11 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_site.go b/resource-manager/web/2024-04-01/appserviceplans/model_site.go new file mode 100644 index 00000000000..f0199b22e0b --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_site.go @@ -0,0 +1,20 @@ +package appserviceplans + +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 Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_siteconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_siteconfig.go new file mode 100644 index 00000000000..d0cdbe23817 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_siteconfig.go @@ -0,0 +1,97 @@ +package appserviceplans + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_sitednsconfig.go b/resource-manager/web/2024-04-01/appserviceplans/model_sitednsconfig.go new file mode 100644 index 00000000000..58beab17a2d --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_sitelimits.go b/resource-manager/web/2024-04-01/appserviceplans/model_sitelimits.go new file mode 100644 index 00000000000..1036a87d597 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_sitemachinekey.go b/resource-manager/web/2024-04-01/appserviceplans/model_sitemachinekey.go new file mode 100644 index 00000000000..17855ad5e8c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_siteproperties.go new file mode 100644 index 00000000000..8bc1369a505 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_siteproperties.go @@ -0,0 +1,93 @@ +package appserviceplans + +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 SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_skucapacity.go b/resource-manager/web/2024-04-01/appserviceplans/model_skucapacity.go new file mode 100644 index 00000000000..7bbedd7e00e --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_skudescription.go b/resource-manager/web/2024-04-01/appserviceplans/model_skudescription.go new file mode 100644 index 00000000000..290adb2a1ad --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_slotswapstatus.go b/resource-manager/web/2024-04-01/appserviceplans/model_slotswapstatus.go new file mode 100644 index 00000000000..707d5e1848f --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceplans + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceplans/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..d3f5bc55adb --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..9e615c4b53c --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..b99ecfaebd7 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_virtualapplication.go b/resource-manager/web/2024-04-01/appserviceplans/model_virtualapplication.go new file mode 100644 index 00000000000..dc79bed2982 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_virtualdirectory.go b/resource-manager/web/2024-04-01/appserviceplans/model_virtualdirectory.go new file mode 100644 index 00000000000..35b134e5664 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetgateway.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetgateway.go new file mode 100644 index 00000000000..f7474dfa9e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetgateway.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetgatewayproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..407a93e7f24 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetinfo.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetinfo.go new file mode 100644 index 00000000000..fe7cf2d0253 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetinfo.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetinforesource.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetinforesource.go new file mode 100644 index 00000000000..2a5fcabaeaa --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetroute.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetroute.go new file mode 100644 index 00000000000..ea4f24d9d78 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetroute.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/model_vnetrouteproperties.go b/resource-manager/web/2024-04-01/appserviceplans/model_vnetrouteproperties.go new file mode 100644 index 00000000000..ccedc00af71 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/appserviceplans/predicates.go b/resource-manager/web/2024-04-01/appserviceplans/predicates.go new file mode 100644 index 00000000000..31b4416ccb0 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/predicates.go @@ -0,0 +1,126 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type HybridConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HybridConnectionOperationPredicate) Matches(input HybridConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/appserviceplans/version.go b/resource-manager/web/2024-04-01/appserviceplans/version.go new file mode 100644 index 00000000000..bd5538d1083 --- /dev/null +++ b/resource-manager/web/2024-04-01/appserviceplans/version.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appserviceplans/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/README.md b/resource-manager/web/2024-04-01/certificateordersdiagnostics/README.md new file mode 100644 index 00000000000..577a7940630 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/certificateordersdiagnostics` Documentation + +The `certificateordersdiagnostics` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/certificateordersdiagnostics" +``` + + +### Client Initialization + +```go +client := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.GetAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName") + +read, err := client.GetAppServiceCertificateOrderDetectorResponse(ctx, id, certificateordersdiagnostics.DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.ListAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +// alternatively `client.ListAppServiceCertificateOrderDetectorResponse(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServiceCertificateOrderDetectorResponseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/client.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/client.go new file mode 100644 index 00000000000..710732b4d7f --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/client.go @@ -0,0 +1,26 @@ +package certificateordersdiagnostics + +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 CertificateOrdersDiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateOrdersDiagnosticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificateordersdiagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateOrdersDiagnosticsClient: %+v", err) + } + + return &CertificateOrdersDiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/constants.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/constants.go new file mode 100644 index 00000000000..5a46c7d7aeb --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/constants.go @@ -0,0 +1,214 @@ +package certificateordersdiagnostics + +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 DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder.go new file mode 100644 index 00000000000..d1a94d4718a --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder.go @@ -0,0 +1,130 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(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 := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder_test.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder_test.go new file mode 100644 index 00000000000..4b64845dc8b --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package certificateordersdiagnostics + +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 = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + + 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.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId 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/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector.go new file mode 100644 index 00000000000..cbb8826cb13 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector.go @@ -0,0 +1,139 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateOrderDetectorId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderDetectorId{} + +// CertificateOrderDetectorId is a struct representing the Resource ID for a Certificate Order Detector +type CertificateOrderDetectorId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + DetectorName string +} + +// NewCertificateOrderDetectorID returns a new CertificateOrderDetectorId struct +func NewCertificateOrderDetectorID(subscriptionId string, resourceGroupName string, certificateOrderName string, detectorName string) CertificateOrderDetectorId { + return CertificateOrderDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + DetectorName: detectorName, + } +} + +// ParseCertificateOrderDetectorID parses 'input' into a CertificateOrderDetectorId +func ParseCertificateOrderDetectorID(input string) (*CertificateOrderDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderDetectorIDInsensitively parses 'input' case-insensitively into a CertificateOrderDetectorId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderDetectorIDInsensitively(input string) (*CertificateOrderDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderDetectorId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateCertificateOrderDetectorID checks that 'input' can be parsed as a Certificate Order Detector ID +func ValidateCertificateOrderDetectorID(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 := ParseCertificateOrderDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order Detector ID +func (id CertificateOrderDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order Detector ID +func (id CertificateOrderDetectorId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Certificate Order Detector ID +func (id CertificateOrderDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Certificate Order Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector_test.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector_test.go new file mode 100644 index 00000000000..b24ca655c01 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/id_certificateorderdetector_test.go @@ -0,0 +1,327 @@ +package certificateordersdiagnostics + +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 = &CertificateOrderDetectorId{} + +func TestNewCertificateOrderDetectorID(t *testing.T) { + id := NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName") + + 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.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatCertificateOrderDetectorID(t *testing.T) { + actual := NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderDetectorId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderDetectorID(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseCertificateOrderDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderDetectorId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderDetectorIDInsensitively(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.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForCertificateOrderDetectorId(t *testing.T) { + segments := CertificateOrderDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderDetectorId 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/web/2024-04-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..c23cb352353 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go @@ -0,0 +1,91 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "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 GetAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetAppServiceCertificateOrderDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions() GetAppServiceCertificateOrderDetectorResponseOperationOptions { + return GetAppServiceCertificateOrderDetectorResponseOperationOptions{} +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) GetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderDetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..405663304fc --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go @@ -0,0 +1,105 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "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 ListAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAppServiceCertificateOrderDetectorResponseCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAppServiceCertificateOrderDetectorResponseCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServiceCertificateOrderDetectorResponseComplete retrieves all the results into a single object +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseComplete(ctx context.Context, id CertificateOrderId) (ListAppServiceCertificateOrderDetectorResponseCompleteResult, error) { + return c.ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate DetectorResponseOperationPredicate) (result ListAppServiceCertificateOrderDetectorResponseCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListAppServiceCertificateOrderDetectorResponse(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListAppServiceCertificateOrderDetectorResponseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_dataprovidermetadata.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..3ca232e10ea --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..94b13b9f1d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponseobject.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..0736e54ba5f --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorinfo.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..792b0133a14 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponse.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..8947d24dc8b --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponseproperties.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..409f708d65f --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_diagnosticdata.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..23d24043011 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..ebad30fedc1 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresult.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..6c29753e795 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresults.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..c2120a0ebfd --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_rendering.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_rendering.go new file mode 100644 index 00000000000..c488d4de11e --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_sampleutterance.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..648bd768413 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_status.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_status.go new file mode 100644 index 00000000000..87558b9b81c --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_status.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_supporttopic.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_supporttopic.go new file mode 100644 index 00000000000..cb170a8c08b --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificateordersdiagnostics/predicates.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/predicates.go new file mode 100644 index 00000000000..149b9af0e1c --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/predicates.go @@ -0,0 +1,32 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/certificateordersdiagnostics/version.go b/resource-manager/web/2024-04-01/certificateordersdiagnostics/version.go new file mode 100644 index 00000000000..c9e3d878688 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificateordersdiagnostics/version.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificateordersdiagnostics/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/certificates/README.md b/resource-manager/web/2024-04-01/certificates/README.md new file mode 100644 index 00000000000..3bf7cfbaf7c --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/certificates` Documentation + +The `certificates` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/certificates" +``` + + +### Client Initialization + +```go +client := certificates.NewCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Delete` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Get` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +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: `CertificatesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, certificates.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, certificates.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.Update` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.CertificatePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/certificates/client.go b/resource-manager/web/2024-04-01/certificates/client.go new file mode 100644 index 00000000000..f045f1b9265 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/client.go @@ -0,0 +1,26 @@ +package certificates + +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 CertificatesClient struct { + Client *resourcemanager.Client +} + +func NewCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) + } + + return &CertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/certificates/constants.go b/resource-manager/web/2024-04-01/certificates/constants.go new file mode 100644 index 00000000000..afe3445c7e6 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/constants.go @@ -0,0 +1,78 @@ +package certificates + +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 KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/certificates/id_certificate.go b/resource-manager/web/2024-04-01/certificates/id_certificate.go new file mode 100644 index 00000000000..3ef853c576d --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/id_certificate.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) 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.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(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 := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/certificates/id_certificate_test.go b/resource-manager/web/2024-04-01/certificates/id_certificate_test.go new file mode 100644 index 00000000000..b4d6ef8d3b8 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/id_certificate_test.go @@ -0,0 +1,282 @@ +package certificates + +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 = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + + 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.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(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.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // 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.wEb/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(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.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId 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/web/2024-04-01/certificates/method_createorupdate.go b/resource-manager/web/2024-04-01/certificates/method_createorupdate.go new file mode 100644 index 00000000000..ef3ac53ed39 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_createorupdate.go @@ -0,0 +1,57 @@ +package certificates + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/certificates/method_delete.go b/resource-manager/web/2024-04-01/certificates/method_delete.go new file mode 100644 index 00000000000..6f676ff9031 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/certificates/method_get.go b/resource-manager/web/2024-04-01/certificates/method_get.go new file mode 100644 index 00000000000..50817117dad --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_get.go @@ -0,0 +1,53 @@ +package certificates + +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 *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (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 + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/certificates/method_list.go b/resource-manager/web/2024-04-01/certificates/method_list.go new file mode 100644 index 00000000000..b9bba8df177 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_list.go @@ -0,0 +1,135 @@ +package certificates + +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 *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", 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 *[]Certificate `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 CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/certificates/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/certificates/method_listbyresourcegroup.go new file mode 100644 index 00000000000..94e8fdd644a --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package certificates + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", 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 *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/certificates/method_update.go b/resource-manager/web/2024-04-01/certificates/method_update.go new file mode 100644 index 00000000000..e0cf13140fe --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/method_update.go @@ -0,0 +1,57 @@ +package certificates + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/certificates/model_certificate.go b/resource-manager/web/2024-04-01/certificates/model_certificate.go new file mode 100644 index 00000000000..354c3cbb53b --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/model_certificate.go @@ -0,0 +1,14 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificates/model_certificatepatchresource.go b/resource-manager/web/2024-04-01/certificates/model_certificatepatchresource.go new file mode 100644 index 00000000000..ad7a39f39b2 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/model_certificatepatchresource.go @@ -0,0 +1,12 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificatePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificates/model_certificatepatchresourceproperties.go b/resource-manager/web/2024-04-01/certificates/model_certificatepatchresourceproperties.go new file mode 100644 index 00000000000..a3aec635456 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/model_certificatepatchresourceproperties.go @@ -0,0 +1,58 @@ +package certificates + +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 CertificatePatchResourceProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificatePatchResourceProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificatePatchResourceProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/certificates/model_certificateproperties.go b/resource-manager/web/2024-04-01/certificates/model_certificateproperties.go new file mode 100644 index 00000000000..0d950ddcd12 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/model_certificateproperties.go @@ -0,0 +1,58 @@ +package certificates + +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 CertificateProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/certificates/model_hostingenvironmentprofile.go b/resource-manager/web/2024-04-01/certificates/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..33ed6c863f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/certificates/predicates.go b/resource-manager/web/2024-04-01/certificates/predicates.go new file mode 100644 index 00000000000..6a9b6eaebc6 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/predicates.go @@ -0,0 +1,37 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/certificates/version.go b/resource-manager/web/2024-04-01/certificates/version.go new file mode 100644 index 00000000000..3a0bc3f4280 --- /dev/null +++ b/resource-manager/web/2024-04-01/certificates/version.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificates/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/client.go b/resource-manager/web/2024-04-01/client.go new file mode 100644 index 00000000000..a075fe5b146 --- /dev/null +++ b/resource-manager/web/2024-04-01/client.go @@ -0,0 +1,244 @@ +package v2024_04_01 + +// 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/web/2024-04-01/appservicecertificateorders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/appserviceplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/certificateordersdiagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/containerapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/containerappsrevisions" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/deletedwebapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/diagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/domains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/global" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/kubeenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/provider" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/recommendations" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourcehealthmetadata" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourceproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/staticsites" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/topleveldomains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/webapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowrunactions" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowruns" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflows" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowtriggerhistories" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowtriggers" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AppServiceCertificateOrders *appservicecertificateorders.AppServiceCertificateOrdersClient + AppServiceEnvironments *appserviceenvironments.AppServiceEnvironmentsClient + AppServicePlans *appserviceplans.AppServicePlansClient + CertificateOrdersDiagnostics *certificateordersdiagnostics.CertificateOrdersDiagnosticsClient + Certificates *certificates.CertificatesClient + ContainerApps *containerapps.ContainerAppsClient + ContainerAppsRevisions *containerappsrevisions.ContainerAppsRevisionsClient + DeletedWebApps *deletedwebapps.DeletedWebAppsClient + Diagnostics *diagnostics.DiagnosticsClient + Domains *domains.DomainsClient + Global *global.GlobalClient + KubeEnvironments *kubeenvironments.KubeEnvironmentsClient + Provider *provider.ProviderClient + Recommendations *recommendations.RecommendationsClient + ResourceHealthMetadata *resourcehealthmetadata.ResourceHealthMetadataClient + ResourceProviders *resourceproviders.ResourceProvidersClient + StaticSites *staticsites.StaticSitesClient + TopLevelDomains *topleveldomains.TopLevelDomainsClient + WebApps *webapps.WebAppsClient + WorkflowRunActions *workflowrunactions.WorkflowRunActionsClient + WorkflowRuns *workflowruns.WorkflowRunsClient + WorkflowTriggerHistories *workflowtriggerhistories.WorkflowTriggerHistoriesClient + WorkflowTriggers *workflowtriggers.WorkflowTriggersClient + WorkflowVersions *workflowversions.WorkflowVersionsClient + Workflows *workflows.WorkflowsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + appServiceCertificateOrdersClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceCertificateOrders client: %+v", err) + } + configureFunc(appServiceCertificateOrdersClient.Client) + + appServiceEnvironmentsClient, err := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceEnvironments client: %+v", err) + } + configureFunc(appServiceEnvironmentsClient.Client) + + appServicePlansClient, err := appserviceplans.NewAppServicePlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServicePlans client: %+v", err) + } + configureFunc(appServicePlansClient.Client) + + certificateOrdersDiagnosticsClient, err := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CertificateOrdersDiagnostics client: %+v", err) + } + configureFunc(certificateOrdersDiagnosticsClient.Client) + + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %+v", err) + } + configureFunc(certificatesClient.Client) + + containerAppsClient, err := containerapps.NewContainerAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerApps client: %+v", err) + } + configureFunc(containerAppsClient.Client) + + containerAppsRevisionsClient, err := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsRevisions client: %+v", err) + } + configureFunc(containerAppsRevisionsClient.Client) + + deletedWebAppsClient, err := deletedwebapps.NewDeletedWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DeletedWebApps client: %+v", err) + } + configureFunc(deletedWebAppsClient.Client) + + diagnosticsClient, err := diagnostics.NewDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Diagnostics client: %+v", err) + } + configureFunc(diagnosticsClient.Client) + + domainsClient, err := domains.NewDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Domains client: %+v", err) + } + configureFunc(domainsClient.Client) + + globalClient, err := global.NewGlobalClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Global client: %+v", err) + } + configureFunc(globalClient.Client) + + kubeEnvironmentsClient, err := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building KubeEnvironments client: %+v", err) + } + configureFunc(kubeEnvironmentsClient.Client) + + providerClient, err := provider.NewProviderClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) + } + configureFunc(providerClient.Client) + + recommendationsClient, err := recommendations.NewRecommendationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Recommendations client: %+v", err) + } + configureFunc(recommendationsClient.Client) + + resourceHealthMetadataClient, err := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceHealthMetadata client: %+v", err) + } + configureFunc(resourceHealthMetadataClient.Client) + + resourceProvidersClient, err := resourceproviders.NewResourceProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceProviders client: %+v", err) + } + configureFunc(resourceProvidersClient.Client) + + staticSitesClient, err := staticsites.NewStaticSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StaticSites client: %+v", err) + } + configureFunc(staticSitesClient.Client) + + topLevelDomainsClient, err := topleveldomains.NewTopLevelDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TopLevelDomains client: %+v", err) + } + configureFunc(topLevelDomainsClient.Client) + + webAppsClient, err := webapps.NewWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApps client: %+v", err) + } + configureFunc(webAppsClient.Client) + + workflowRunActionsClient, err := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRunActions client: %+v", err) + } + configureFunc(workflowRunActionsClient.Client) + + workflowRunsClient, err := workflowruns.NewWorkflowRunsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRuns client: %+v", err) + } + configureFunc(workflowRunsClient.Client) + + workflowTriggerHistoriesClient, err := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggerHistories client: %+v", err) + } + configureFunc(workflowTriggerHistoriesClient.Client) + + workflowTriggersClient, err := workflowtriggers.NewWorkflowTriggersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggers client: %+v", err) + } + configureFunc(workflowTriggersClient.Client) + + workflowVersionsClient, err := workflowversions.NewWorkflowVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowVersions client: %+v", err) + } + configureFunc(workflowVersionsClient.Client) + + workflowsClient, err := workflows.NewWorkflowsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workflows client: %+v", err) + } + configureFunc(workflowsClient.Client) + + return &Client{ + AppServiceCertificateOrders: appServiceCertificateOrdersClient, + AppServiceEnvironments: appServiceEnvironmentsClient, + AppServicePlans: appServicePlansClient, + CertificateOrdersDiagnostics: certificateOrdersDiagnosticsClient, + Certificates: certificatesClient, + ContainerApps: containerAppsClient, + ContainerAppsRevisions: containerAppsRevisionsClient, + DeletedWebApps: deletedWebAppsClient, + Diagnostics: diagnosticsClient, + Domains: domainsClient, + Global: globalClient, + KubeEnvironments: kubeEnvironmentsClient, + Provider: providerClient, + Recommendations: recommendationsClient, + ResourceHealthMetadata: resourceHealthMetadataClient, + ResourceProviders: resourceProvidersClient, + StaticSites: staticSitesClient, + TopLevelDomains: topLevelDomainsClient, + WebApps: webAppsClient, + WorkflowRunActions: workflowRunActionsClient, + WorkflowRuns: workflowRunsClient, + WorkflowTriggerHistories: workflowTriggerHistoriesClient, + WorkflowTriggers: workflowTriggersClient, + WorkflowVersions: workflowVersionsClient, + Workflows: workflowsClient, + }, nil +} diff --git a/resource-manager/web/2024-04-01/containerapps/README.md b/resource-manager/web/2024-04-01/containerapps/README.md new file mode 100644 index 00000000000..1ce44dfffb0 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/containerapps` Documentation + +The `containerapps` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/containerapps" +``` + + +### Client Initialization + +```go +client := containerapps.NewContainerAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + +payload := containerapps.ContainerApp{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Delete` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Get` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + +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: `ContainerAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListSecrets` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppName") + +read, err := client.ListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/containerapps/client.go b/resource-manager/web/2024-04-01/containerapps/client.go new file mode 100644 index 00000000000..aed3cca9efb --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/client.go @@ -0,0 +1,26 @@ +package containerapps + +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 ContainerAppsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "containerapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsClient: %+v", err) + } + + return &ContainerAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/containerapps/constants.go b/resource-manager/web/2024-04-01/containerapps/constants.go new file mode 100644 index 00000000000..f6e8265656f --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/constants.go @@ -0,0 +1,142 @@ +package containerapps + +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 ActiveRevisionsMode string + +const ( + ActiveRevisionsModeMultiple ActiveRevisionsMode = "multiple" + ActiveRevisionsModeSingle ActiveRevisionsMode = "single" +) + +func PossibleValuesForActiveRevisionsMode() []string { + return []string{ + string(ActiveRevisionsModeMultiple), + string(ActiveRevisionsModeSingle), + } +} + +func (s *ActiveRevisionsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveRevisionsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveRevisionsMode(input string) (*ActiveRevisionsMode, error) { + vals := map[string]ActiveRevisionsMode{ + "multiple": ActiveRevisionsModeMultiple, + "single": ActiveRevisionsModeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveRevisionsMode(input) + return &out, nil +} + +type ContainerAppProvisioningState string + +const ( + ContainerAppProvisioningStateCanceled ContainerAppProvisioningState = "Canceled" + ContainerAppProvisioningStateFailed ContainerAppProvisioningState = "Failed" + ContainerAppProvisioningStateInProgress ContainerAppProvisioningState = "InProgress" + ContainerAppProvisioningStateSucceeded ContainerAppProvisioningState = "Succeeded" +) + +func PossibleValuesForContainerAppProvisioningState() []string { + return []string{ + string(ContainerAppProvisioningStateCanceled), + string(ContainerAppProvisioningStateFailed), + string(ContainerAppProvisioningStateInProgress), + string(ContainerAppProvisioningStateSucceeded), + } +} + +func (s *ContainerAppProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppProvisioningState(input string) (*ContainerAppProvisioningState, error) { + vals := map[string]ContainerAppProvisioningState{ + "canceled": ContainerAppProvisioningStateCanceled, + "failed": ContainerAppProvisioningStateFailed, + "inprogress": ContainerAppProvisioningStateInProgress, + "succeeded": ContainerAppProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppProvisioningState(input) + return &out, nil +} + +type IngressTransportMethod string + +const ( + IngressTransportMethodAuto IngressTransportMethod = "auto" + IngressTransportMethodHTTP IngressTransportMethod = "http" + IngressTransportMethodHTTPTwo IngressTransportMethod = "http2" +) + +func PossibleValuesForIngressTransportMethod() []string { + return []string{ + string(IngressTransportMethodAuto), + string(IngressTransportMethodHTTP), + string(IngressTransportMethodHTTPTwo), + } +} + +func (s *IngressTransportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressTransportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressTransportMethod(input string) (*IngressTransportMethod, error) { + vals := map[string]IngressTransportMethod{ + "auto": IngressTransportMethodAuto, + "http": IngressTransportMethodHTTP, + "http2": IngressTransportMethodHTTPTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressTransportMethod(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/containerapps/id_containerapp.go b/resource-manager/web/2024-04-01/containerapps/id_containerapp.go new file mode 100644 index 00000000000..3f70ccac898 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/id_containerapp.go @@ -0,0 +1,121 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppName"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/containerapps/id_containerapp_test.go b/resource-manager/web/2024-04-01/containerapps/id_containerapp_test.go new file mode 100644 index 00000000000..7117d5e1f72 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/id_containerapp_test.go @@ -0,0 +1,237 @@ +package containerapps + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppName") + + 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.ContainerAppName != "containerAppName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppName") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "cOnTaInErApPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/web/2024-04-01/containerapps/id_providercontainerapp.go b/resource-manager/web/2024-04-01/containerapps/id_providercontainerapp.go new file mode 100644 index 00000000000..b816f39ada9 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/id_providercontainerapp.go @@ -0,0 +1,130 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderContainerAppId{}) +} + +var _ resourceids.ResourceId = &ProviderContainerAppId{} + +// ProviderContainerAppId is a struct representing the Resource ID for a Provider Container App +type ProviderContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewProviderContainerAppID returns a new ProviderContainerAppId struct +func NewProviderContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ProviderContainerAppId { + return ProviderContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseProviderContainerAppID parses 'input' into a ProviderContainerAppId +func ParseProviderContainerAppID(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderContainerAppIDInsensitively parses 'input' case-insensitively into a ProviderContainerAppId +// note: this method should only be used for API response data and not user input +func ParseProviderContainerAppIDInsensitively(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateProviderContainerAppID checks that 'input' can be parsed as a Provider Container App ID +func ValidateProviderContainerAppID(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 := ParseProviderContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Container App ID +func (id ProviderContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Container App ID +func (id ProviderContainerAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppName"), + } +} + +// String returns a human-readable description of this Provider Container App ID +func (id ProviderContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Provider Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/containerapps/id_providercontainerapp_test.go b/resource-manager/web/2024-04-01/containerapps/id_providercontainerapp_test.go new file mode 100644 index 00000000000..55188842290 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/id_providercontainerapp_test.go @@ -0,0 +1,282 @@ +package containerapps + +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 = &ProviderContainerAppId{} + +func TestNewProviderContainerAppID(t *testing.T) { + id := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + + 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.ContainerAppName != "containerAppName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppName") + } +} + +func TestFormatProviderContainerAppID(t *testing.T) { + actual := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppID(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseProviderContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPnAmE", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppIDInsensitively(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForProviderContainerAppId(t *testing.T) { + segments := ProviderContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderContainerAppId 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/web/2024-04-01/containerapps/method_createorupdate.go b/resource-manager/web/2024-04-01/containerapps/method_createorupdate.go new file mode 100644 index 00000000000..606408a054d --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_createorupdate.go @@ -0,0 +1,75 @@ +package containerapps + +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 + Model *ContainerApp +} + +// CreateOrUpdate ... +func (c ContainerAppsClient) CreateOrUpdate(ctx context.Context, id ProviderContainerAppId, input ContainerApp) (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 ContainerAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id ProviderContainerAppId, input ContainerApp) 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/web/2024-04-01/containerapps/method_delete.go b/resource-manager/web/2024-04-01/containerapps/method_delete.go new file mode 100644 index 00000000000..6cdd45058e6 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_delete.go @@ -0,0 +1,71 @@ +package containerapps + +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 ContainerAppsClient) Delete(ctx context.Context, id ProviderContainerAppId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ContainerAppsClient) DeleteThenPoll(ctx context.Context, id ProviderContainerAppId) 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/web/2024-04-01/containerapps/method_get.go b/resource-manager/web/2024-04-01/containerapps/method_get.go new file mode 100644 index 00000000000..66c664a40cb --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_get.go @@ -0,0 +1,53 @@ +package containerapps + +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 *ContainerApp +} + +// Get ... +func (c ContainerAppsClient) Get(ctx context.Context, id ProviderContainerAppId) (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 + } + + var model ContainerApp + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerapps/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/containerapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e6d795c0f7d --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package containerapps + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ContainerAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContainerAppOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/containerapps/method_listbysubscription.go b/resource-manager/web/2024-04-01/containerapps/method_listbysubscription.go new file mode 100644 index 00000000000..d1d592f103c --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_listbysubscription.go @@ -0,0 +1,106 @@ +package containerapps + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c ContainerAppsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContainerAppOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/containerapps/method_listsecrets.go b/resource-manager/web/2024-04-01/containerapps/method_listsecrets.go new file mode 100644 index 00000000000..8c35814e73f --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/method_listsecrets.go @@ -0,0 +1,54 @@ +package containerapps + +import ( + "context" + "fmt" + "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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecretsCollection +} + +// ListSecrets ... +func (c ContainerAppsClient) ListSecrets(ctx context.Context, id ContainerAppId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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 + } + + var model SecretsCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_configuration.go b/resource-manager/web/2024-04-01/containerapps/model_configuration.go new file mode 100644 index 00000000000..b4b5ca6c61f --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_configuration.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Configuration struct { + ActiveRevisionsMode *ActiveRevisionsMode `json:"activeRevisionsMode,omitempty"` + Ingress *Ingress `json:"ingress,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_container.go b/resource-manager/web/2024-04-01/containerapps/model_container.go new file mode 100644 index 00000000000..c0f124d72bb --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_container.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_containerapp.go b/resource-manager/web/2024-04-01/containerapps/model_containerapp.go new file mode 100644 index 00000000000..51cd1800cce --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_containerapp.go @@ -0,0 +1,14 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerApp struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ContainerAppProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_containerappproperties.go b/resource-manager/web/2024-04-01/containerapps/model_containerappproperties.go new file mode 100644 index 00000000000..e0a892de046 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_containerappproperties.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProperties struct { + Configuration *Configuration `json:"configuration,omitempty"` + KubeEnvironmentId *string `json:"kubeEnvironmentId,omitempty"` + LatestRevisionFqdn *string `json:"latestRevisionFqdn,omitempty"` + LatestRevisionName *string `json:"latestRevisionName,omitempty"` + ProvisioningState *ContainerAppProvisioningState `json:"provisioningState,omitempty"` + Template *Template `json:"template,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_containerappsecret.go b/resource-manager/web/2024-04-01/containerapps/model_containerappsecret.go new file mode 100644 index 00000000000..a2ca83f001b --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_containerappsecret.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppSecret struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_containerresources.go b/resource-manager/web/2024-04-01/containerapps/model_containerresources.go new file mode 100644 index 00000000000..5ce6649a3f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_containerresources.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_customscalerule.go b/resource-manager/web/2024-04-01/containerapps/model_customscalerule.go new file mode 100644 index 00000000000..6b51d48a3e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_dapr.go b/resource-manager/web/2024-04-01/containerapps/model_dapr.go new file mode 100644 index 00000000000..f00ddc94ea1 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_dapr.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + Components *[]DaprComponent `json:"components,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_daprcomponent.go b/resource-manager/web/2024-04-01/containerapps/model_daprcomponent.go new file mode 100644 index 00000000000..fafbbaa3a5c --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_daprcomponent.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponent struct { + Metadata *[]DaprMetadata `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_daprmetadata.go b/resource-manager/web/2024-04-01/containerapps/model_daprmetadata.go new file mode 100644 index 00000000000..9e86a8f6bf3 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_daprmetadata.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprMetadata struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_environmentvar.go b/resource-manager/web/2024-04-01/containerapps/model_environmentvar.go new file mode 100644 index 00000000000..e25ec6c8bc8 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_httpscalerule.go b/resource-manager/web/2024-04-01/containerapps/model_httpscalerule.go new file mode 100644 index 00000000000..429b7ee2303 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_ingress.go b/resource-manager/web/2024-04-01/containerapps/model_ingress.go new file mode 100644 index 00000000000..a36b7a2cb83 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_ingress.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ingress struct { + AllowInsecure *bool `json:"allowInsecure,omitempty"` + External *bool `json:"external,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + TargetPort *int64 `json:"targetPort,omitempty"` + Traffic *[]TrafficWeight `json:"traffic,omitempty"` + Transport *IngressTransportMethod `json:"transport,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_queuescalerule.go b/resource-manager/web/2024-04-01/containerapps/model_queuescalerule.go new file mode 100644 index 00000000000..b8cbc96d3a0 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_registrycredentials.go b/resource-manager/web/2024-04-01/containerapps/model_registrycredentials.go new file mode 100644 index 00000000000..1931c41d6e5 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_registrycredentials.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCredentials struct { + PasswordSecretRef *string `json:"passwordSecretRef,omitempty"` + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_scale.go b/resource-manager/web/2024-04-01/containerapps/model_scale.go new file mode 100644 index 00000000000..a8f54d89b3f --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_scale.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_scalerule.go b/resource-manager/web/2024-04-01/containerapps/model_scalerule.go new file mode 100644 index 00000000000..4fc43100461 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_scalerule.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_scaleruleauth.go b/resource-manager/web/2024-04-01/containerapps/model_scaleruleauth.go new file mode 100644 index 00000000000..46e5a92ad03 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_secret.go b/resource-manager/web/2024-04-01/containerapps/model_secret.go new file mode 100644 index 00000000000..172aa1e71e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_secret.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_secretscollection.go b/resource-manager/web/2024-04-01/containerapps/model_secretscollection.go new file mode 100644 index 00000000000..5244f0aabe7 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_secretscollection.go @@ -0,0 +1,8 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretsCollection struct { + Value []ContainerAppSecret `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_template.go b/resource-manager/web/2024-04-01/containerapps/model_template.go new file mode 100644 index 00000000000..e9bb1c65c4b --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_template.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/model_trafficweight.go b/resource-manager/web/2024-04-01/containerapps/model_trafficweight.go new file mode 100644 index 00000000000..ffefd180a54 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/model_trafficweight.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficWeight struct { + LatestRevision *bool `json:"latestRevision,omitempty"` + RevisionName *string `json:"revisionName,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerapps/predicates.go b/resource-manager/web/2024-04-01/containerapps/predicates.go new file mode 100644 index 00000000000..21173ca2726 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/predicates.go @@ -0,0 +1,37 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ContainerAppOperationPredicate) Matches(input ContainerApp) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/containerapps/version.go b/resource-manager/web/2024-04-01/containerapps/version.go new file mode 100644 index 00000000000..8b80e177c33 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerapps/version.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/containerapps/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/README.md b/resource-manager/web/2024-04-01/containerappsrevisions/README.md new file mode 100644 index 00000000000..3af96867f4d --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/containerappsrevisions` Documentation + +The `containerappsrevisions` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/containerappsrevisions" +``` + + +### Client Initialization + +```go +client := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ActivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName") + +read, err := client.ActivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.DeactivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName") + +read, err := client.DeactivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.GetRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName") + +read, err := client.GetRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ListRevisions` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + +// alternatively `client.ListRevisions(ctx, id)` can be used to do batched pagination +items, err := client.ListRevisionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.RestartRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName") + +read, err := client.RestartRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/client.go b/resource-manager/web/2024-04-01/containerappsrevisions/client.go new file mode 100644 index 00000000000..16764223cb1 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/client.go @@ -0,0 +1,26 @@ +package containerappsrevisions + +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 ContainerAppsRevisionsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsRevisionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsRevisionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "containerappsrevisions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsRevisionsClient: %+v", err) + } + + return &ContainerAppsRevisionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/constants.go b/resource-manager/web/2024-04-01/containerappsrevisions/constants.go new file mode 100644 index 00000000000..0405b958db3 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/constants.go @@ -0,0 +1,104 @@ +package containerappsrevisions + +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 RevisionHealthState string + +const ( + RevisionHealthStateHealthy RevisionHealthState = "Healthy" + RevisionHealthStateNone RevisionHealthState = "None" + RevisionHealthStateUnhealthy RevisionHealthState = "Unhealthy" +) + +func PossibleValuesForRevisionHealthState() []string { + return []string{ + string(RevisionHealthStateHealthy), + string(RevisionHealthStateNone), + string(RevisionHealthStateUnhealthy), + } +} + +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionHealthState(input string) (*RevisionHealthState, error) { + vals := map[string]RevisionHealthState{ + "healthy": RevisionHealthStateHealthy, + "none": RevisionHealthStateNone, + "unhealthy": RevisionHealthStateUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionHealthState(input) + return &out, nil +} + +type RevisionProvisioningState string + +const ( + RevisionProvisioningStateDeprovisioned RevisionProvisioningState = "Deprovisioned" + RevisionProvisioningStateDeprovisioning RevisionProvisioningState = "Deprovisioning" + RevisionProvisioningStateFailed RevisionProvisioningState = "Failed" + RevisionProvisioningStateProvisioned RevisionProvisioningState = "Provisioned" + RevisionProvisioningStateProvisioning RevisionProvisioningState = "Provisioning" +) + +func PossibleValuesForRevisionProvisioningState() []string { + return []string{ + string(RevisionProvisioningStateDeprovisioned), + string(RevisionProvisioningStateDeprovisioning), + string(RevisionProvisioningStateFailed), + string(RevisionProvisioningStateProvisioned), + string(RevisionProvisioningStateProvisioning), + } +} + +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { + vals := map[string]RevisionProvisioningState{ + "deprovisioned": RevisionProvisioningStateDeprovisioned, + "deprovisioning": RevisionProvisioningStateDeprovisioning, + "failed": RevisionProvisioningStateFailed, + "provisioned": RevisionProvisioningStateProvisioned, + "provisioning": RevisionProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp.go b/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp.go new file mode 100644 index 00000000000..b9383d30fbd --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp.go @@ -0,0 +1,130 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderContainerAppId{}) +} + +var _ resourceids.ResourceId = &ProviderContainerAppId{} + +// ProviderContainerAppId is a struct representing the Resource ID for a Provider Container App +type ProviderContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewProviderContainerAppID returns a new ProviderContainerAppId struct +func NewProviderContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ProviderContainerAppId { + return ProviderContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseProviderContainerAppID parses 'input' into a ProviderContainerAppId +func ParseProviderContainerAppID(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderContainerAppIDInsensitively parses 'input' case-insensitively into a ProviderContainerAppId +// note: this method should only be used for API response data and not user input +func ParseProviderContainerAppIDInsensitively(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateProviderContainerAppID checks that 'input' can be parsed as a Provider Container App ID +func ValidateProviderContainerAppID(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 := ParseProviderContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Container App ID +func (id ProviderContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Container App ID +func (id ProviderContainerAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppName"), + } +} + +// String returns a human-readable description of this Provider Container App ID +func (id ProviderContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Provider Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp_test.go b/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp_test.go new file mode 100644 index 00000000000..1ab5644f109 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/id_providercontainerapp_test.go @@ -0,0 +1,282 @@ +package containerappsrevisions + +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 = &ProviderContainerAppId{} + +func TestNewProviderContainerAppID(t *testing.T) { + id := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName") + + 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.ContainerAppName != "containerAppName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppName") + } +} + +func TestFormatProviderContainerAppID(t *testing.T) { + actual := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppID(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseProviderContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPnAmE", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppIDInsensitively(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForProviderContainerAppId(t *testing.T) { + segments := ProviderContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderContainerAppId 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/web/2024-04-01/containerappsrevisions/id_revision.go b/resource-manager/web/2024-04-01/containerappsrevisions/id_revision.go new file mode 100644 index 00000000000..eee8b68dfe6 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/id_revision.go @@ -0,0 +1,139 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionId{} + +// RevisionId is a struct representing the Resource ID for a Revision +type RevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionID returns a new RevisionId struct +func NewRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionId { + return RevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionID parses 'input' into a RevisionId +func ParseRevisionID(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionIDInsensitively parses 'input' case-insensitively into a RevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionIDInsensitively(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionID checks that 'input' can be parsed as a Revision ID +func ValidateRevisionID(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 := ParseRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revision ID +func (id RevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revision ID +func (id RevisionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppName"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionName"), + } +} + +// String returns a human-readable description of this Revision ID +func (id RevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/id_revision_test.go b/resource-manager/web/2024-04-01/containerappsrevisions/id_revision_test.go new file mode 100644 index 00000000000..224a34a6a98 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/id_revision_test.go @@ -0,0 +1,327 @@ +package containerappsrevisions + +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 = &RevisionId{} + +func TestNewRevisionID(t *testing.T) { + id := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName") + + 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.ContainerAppName != "containerAppName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppName") + } + + if id.RevisionName != "revisionName" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionName") + } +} + +func TestFormatRevisionID(t *testing.T) { + actual := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppName", "revisionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions/revisionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions/revisionName", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + RevisionName: "revisionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions/revisionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionID(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions/revisionName", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppName", + RevisionName: "revisionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppName/revisions/revisionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/rEvIsIoNs/rEvIsIoNnAmE", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPnAmE", + RevisionName: "rEvIsIoNnAmE", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPnAmE/rEvIsIoNs/rEvIsIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionIDInsensitively(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.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionId(t *testing.T) { + segments := RevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionId 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/web/2024-04-01/containerappsrevisions/method_activaterevision.go b/resource-manager/web/2024-04-01/containerappsrevisions/method_activaterevision.go new file mode 100644 index 00000000000..1745777ac96 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/method_activaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 ActivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ActivateRevision ... +func (c ContainerAppsRevisionsClient) ActivateRevision(ctx context.Context, id RevisionId) (result ActivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/activate", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/method_deactivaterevision.go b/resource-manager/web/2024-04-01/containerappsrevisions/method_deactivaterevision.go new file mode 100644 index 00000000000..46be1cffefd --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/method_deactivaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 DeactivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeactivateRevision ... +func (c ContainerAppsRevisionsClient) DeactivateRevision(ctx context.Context, id RevisionId) (result DeactivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deactivate", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/method_getrevision.go b/resource-manager/web/2024-04-01/containerappsrevisions/method_getrevision.go new file mode 100644 index 00000000000..5f54d0c3df2 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/method_getrevision.go @@ -0,0 +1,53 @@ +package containerappsrevisions + +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 GetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// GetRevision ... +func (c ContainerAppsRevisionsClient) GetRevision(ctx context.Context, id RevisionId) (result GetRevisionOperationResponse, 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 + } + + var model Revision + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/method_listrevisions.go b/resource-manager/web/2024-04-01/containerappsrevisions/method_listrevisions.go new file mode 100644 index 00000000000..0248f10075a --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/method_listrevisions.go @@ -0,0 +1,105 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 ListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type ListRevisionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Revision +} + +type ListRevisionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRevisionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRevisions ... +func (c ContainerAppsRevisionsClient) ListRevisions(ctx context.Context, id ProviderContainerAppId) (result ListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListRevisionsCustomPager{}, + Path: fmt.Sprintf("%s/revisions", 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 *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRevisionsComplete retrieves all the results into a single object +func (c ContainerAppsRevisionsClient) ListRevisionsComplete(ctx context.Context, id ProviderContainerAppId) (ListRevisionsCompleteResult, error) { + return c.ListRevisionsCompleteMatchingPredicate(ctx, id, RevisionOperationPredicate{}) +} + +// ListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsRevisionsClient) ListRevisionsCompleteMatchingPredicate(ctx context.Context, id ProviderContainerAppId, predicate RevisionOperationPredicate) (result ListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.ListRevisions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListRevisionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/method_restartrevision.go b/resource-manager/web/2024-04-01/containerappsrevisions/method_restartrevision.go new file mode 100644 index 00000000000..e228b363490 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/method_restartrevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 RestartRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RestartRevision ... +func (c ContainerAppsRevisionsClient) RestartRevision(ctx context.Context, id RevisionId) (result RestartRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_container.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_container.go new file mode 100644 index 00000000000..862350bdd50 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_container.go @@ -0,0 +1,13 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_containerresources.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_containerresources.go new file mode 100644 index 00000000000..a62495954a4 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_containerresources.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_customscalerule.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_customscalerule.go new file mode 100644 index 00000000000..601fb82b559 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_dapr.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_dapr.go new file mode 100644 index 00000000000..bf56c0864ed --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_dapr.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + Components *[]DaprComponent `json:"components,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_daprcomponent.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_daprcomponent.go new file mode 100644 index 00000000000..84f86e5b325 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_daprcomponent.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponent struct { + Metadata *[]DaprMetadata `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_daprmetadata.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_daprmetadata.go new file mode 100644 index 00000000000..35d8790d331 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_daprmetadata.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprMetadata struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_environmentvar.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_environmentvar.go new file mode 100644 index 00000000000..1b4d78fc7ed --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_httpscalerule.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_httpscalerule.go new file mode 100644 index 00000000000..17656fa5908 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_queuescalerule.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_queuescalerule.go new file mode 100644 index 00000000000..016cc178897 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_revision.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_revision.go new file mode 100644 index 00000000000..21661910d51 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_revision.go @@ -0,0 +1,14 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revision struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *RevisionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_revisionproperties.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_revisionproperties.go new file mode 100644 index 00000000000..60753fcac96 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_revisionproperties.go @@ -0,0 +1,34 @@ +package containerappsrevisions + +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 RevisionProperties struct { + Active *bool `json:"active,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HealthState *RevisionHealthState `json:"healthState,omitempty"` + ProvisioningError *string `json:"provisioningError,omitempty"` + ProvisioningState *RevisionProvisioningState `json:"provisioningState,omitempty"` + Replicas *int64 `json:"replicas,omitempty"` + Template *Template `json:"template,omitempty"` + TrafficWeight *int64 `json:"trafficWeight,omitempty"` +} + +func (o *RevisionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_scale.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_scale.go new file mode 100644 index 00000000000..f6e99c4b779 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_scale.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_scalerule.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_scalerule.go new file mode 100644 index 00000000000..4bcd2c4a29e --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_scalerule.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_scaleruleauth.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_scaleruleauth.go new file mode 100644 index 00000000000..2135985725a --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/model_template.go b/resource-manager/web/2024-04-01/containerappsrevisions/model_template.go new file mode 100644 index 00000000000..fa5011317db --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/model_template.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/containerappsrevisions/predicates.go b/resource-manager/web/2024-04-01/containerappsrevisions/predicates.go new file mode 100644 index 00000000000..863ff2fcae7 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/predicates.go @@ -0,0 +1,37 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevisionOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p RevisionOperationPredicate) Matches(input Revision) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/containerappsrevisions/version.go b/resource-manager/web/2024-04-01/containerappsrevisions/version.go new file mode 100644 index 00000000000..dbd46fe4720 --- /dev/null +++ b/resource-manager/web/2024-04-01/containerappsrevisions/version.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/containerappsrevisions/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/README.md b/resource-manager/web/2024-04-01/deletedwebapps/README.md new file mode 100644 index 00000000000..9fbdbd74f70 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/deletedwebapps` Documentation + +The `deletedwebapps` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/deletedwebapps" +``` + + +### Client Initialization + +```go +client := deletedwebapps.NewDeletedWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DeletedWebAppsClient.GetDeletedWebAppByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId") + +read, err := client.GetDeletedWebAppByLocation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DeletedWebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `DeletedWebAppsClient.ListByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/deletedwebapps/client.go b/resource-manager/web/2024-04-01/deletedwebapps/client.go new file mode 100644 index 00000000000..75d69e08194 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/client.go @@ -0,0 +1,26 @@ +package deletedwebapps + +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 DeletedWebAppsClient struct { + Client *resourcemanager.Client +} + +func NewDeletedWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*DeletedWebAppsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "deletedwebapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedWebAppsClient: %+v", err) + } + + return &DeletedWebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite.go b/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite.go new file mode 100644 index 00000000000..28780740879 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite.go @@ -0,0 +1,130 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationDeletedSiteId{}) +} + +var _ resourceids.ResourceId = &LocationDeletedSiteId{} + +// LocationDeletedSiteId is a struct representing the Resource ID for a Location Deleted Site +type LocationDeletedSiteId struct { + SubscriptionId string + LocationName string + DeletedSiteId string +} + +// NewLocationDeletedSiteID returns a new LocationDeletedSiteId struct +func NewLocationDeletedSiteID(subscriptionId string, locationName string, deletedSiteId string) LocationDeletedSiteId { + return LocationDeletedSiteId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DeletedSiteId: deletedSiteId, + } +} + +// ParseLocationDeletedSiteID parses 'input' into a LocationDeletedSiteId +func ParseLocationDeletedSiteID(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationDeletedSiteIDInsensitively parses 'input' case-insensitively into a LocationDeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseLocationDeletedSiteIDInsensitively(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationDeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateLocationDeletedSiteID checks that 'input' can be parsed as a Location Deleted Site ID +func ValidateLocationDeletedSiteID(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 := ParseLocationDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location Deleted Site ID +func (id LocationDeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location Deleted Site ID +func (id LocationDeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteId"), + } +} + +// String returns a human-readable description of this Location Deleted Site ID +func (id LocationDeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Location Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite_test.go b/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite_test.go new file mode 100644 index 00000000000..b406ec22fa2 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/id_locationdeletedsite_test.go @@ -0,0 +1,282 @@ +package deletedwebapps + +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 = &LocationDeletedSiteId{} + +func TestNewLocationDeletedSiteID(t *testing.T) { + id := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.DeletedSiteId != "deletedSiteId" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteId") + } +} + +func TestFormatLocationDeletedSiteID(t *testing.T) { + actual := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseLocationDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS/dElEtEdSiTeId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + DeletedSiteId: "dElEtEdSiTeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS/dElEtEdSiTeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForLocationDeletedSiteId(t *testing.T) { + segments := LocationDeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationDeletedSiteId 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/web/2024-04-01/deletedwebapps/id_providerlocation.go b/resource-manager/web/2024-04-01/deletedwebapps/id_providerlocation.go new file mode 100644 index 00000000000..ba6b4940392 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/id_providerlocation.go @@ -0,0 +1,121 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(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 := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/id_providerlocation_test.go b/resource-manager/web/2024-04-01/deletedwebapps/id_providerlocation_test.go new file mode 100644 index 00000000000..fb713255a98 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package deletedwebapps + +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 = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId 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/web/2024-04-01/deletedwebapps/method_getdeletedwebappbylocation.go b/resource-manager/web/2024-04-01/deletedwebapps/method_getdeletedwebappbylocation.go new file mode 100644 index 00000000000..c60231dbc7b --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/method_getdeletedwebappbylocation.go @@ -0,0 +1,53 @@ +package deletedwebapps + +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 GetDeletedWebAppByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebAppByLocation ... +func (c DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (result GetDeletedWebAppByLocationOperationResponse, 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 + } + + var model DeletedSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/method_list.go b/resource-manager/web/2024-04-01/deletedwebapps/method_list.go new file mode 100644 index 00000000000..9727a056e86 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/method_list.go @@ -0,0 +1,106 @@ +package deletedwebapps + +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 *[]DeletedSite +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DeletedWebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deletedSites", 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 *[]DeletedSite `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 DeletedWebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedSiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/deletedwebapps/method_listbylocation.go b/resource-manager/web/2024-04-01/deletedwebapps/method_listbylocation.go new file mode 100644 index 00000000000..09bdd361949 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/method_listbylocation.go @@ -0,0 +1,105 @@ +package deletedwebapps + +import ( + "context" + "fmt" + "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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c DeletedWebAppsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/deletedSites", 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 *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate DeletedSiteOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsite.go b/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsite.go new file mode 100644 index 00000000000..680051fe469 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsite.go @@ -0,0 +1,12 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsiteproperties.go b/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsiteproperties.go new file mode 100644 index 00000000000..0afbf334a61 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/deletedwebapps/predicates.go b/resource-manager/web/2024-04-01/deletedwebapps/predicates.go new file mode 100644 index 00000000000..5db9392a06f --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/predicates.go @@ -0,0 +1,32 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeletedSiteOperationPredicate) Matches(input DeletedSite) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/deletedwebapps/version.go b/resource-manager/web/2024-04-01/deletedwebapps/version.go new file mode 100644 index 00000000000..714731458c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/deletedwebapps/version.go @@ -0,0 +1,10 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/deletedwebapps/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/diagnostics/README.md b/resource-manager/web/2024-04-01/diagnostics/README.md new file mode 100644 index 00000000000..17e591a2088 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/README.md @@ -0,0 +1,382 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/diagnostics` Documentation + +The `diagnostics` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/diagnostics" +``` + + +### Client Initialization + +```go +client := diagnostics.NewDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + +read, err := client.ExecuteSiteAnalysis(ctx, id, diagnostics.DefaultExecuteSiteAnalysisOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + +read, err := client.ExecuteSiteAnalysisSlot(ctx, id, diagnostics.DefaultExecuteSiteAnalysisSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + +read, err := client.ExecuteSiteDetector(ctx, id, diagnostics.DefaultExecuteSiteDetectorOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + +read, err := client.ExecuteSiteDetectorSlot(ctx, id, diagnostics.DefaultExecuteSiteDetectorSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetHostingEnvironmentDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName") + +read, err := client.GetHostingEnvironmentDetectorResponse(ctx, id, diagnostics.DefaultGetHostingEnvironmentDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + +read, err := client.GetSiteAnalysis(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + +read, err := client.GetSiteAnalysisSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + +read, err := client.GetSiteDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName") + +read, err := client.GetSiteDetectorResponse(ctx, id, diagnostics.DefaultGetSiteDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponseSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName") + +read, err := client.GetSiteDetectorResponseSlot(ctx, id, diagnostics.DefaultGetSiteDetectorResponseSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + +read, err := client.GetSiteDetectorSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategory` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +read, err := client.GetSiteDiagnosticCategory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategorySlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +read, err := client.GetSiteDiagnosticCategorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ListHostingEnvironmentDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListHostingEnvironmentDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListHostingEnvironmentDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalyses` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +// alternatively `client.ListSiteAnalyses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalysesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +// alternatively `client.ListSiteAnalysesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponsesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteDetectorResponsesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +// alternatively `client.ListSiteDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorsSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +// alternatively `client.ListSiteDetectorsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategories` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteDiagnosticCategories(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategoriesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteDiagnosticCategoriesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/diagnostics/client.go b/resource-manager/web/2024-04-01/diagnostics/client.go new file mode 100644 index 00000000000..4b218f34ee2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/client.go @@ -0,0 +1,26 @@ +package diagnostics + +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 DiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiagnosticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "diagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsClient: %+v", err) + } + + return &DiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/diagnostics/constants.go b/resource-manager/web/2024-04-01/diagnostics/constants.go new file mode 100644 index 00000000000..47006b35190 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/constants.go @@ -0,0 +1,317 @@ +package diagnostics + +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 DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type IssueType string + +const ( + IssueTypeAppCrash IssueType = "AppCrash" + IssueTypeAppDeployment IssueType = "AppDeployment" + IssueTypeAseDeployment IssueType = "AseDeployment" + IssueTypeOther IssueType = "Other" + IssueTypePlatformIssue IssueType = "PlatformIssue" + IssueTypeRuntimeIssueDetected IssueType = "RuntimeIssueDetected" + IssueTypeServiceIncident IssueType = "ServiceIncident" + IssueTypeUserIssue IssueType = "UserIssue" +) + +func PossibleValuesForIssueType() []string { + return []string{ + string(IssueTypeAppCrash), + string(IssueTypeAppDeployment), + string(IssueTypeAseDeployment), + string(IssueTypeOther), + string(IssueTypePlatformIssue), + string(IssueTypeRuntimeIssueDetected), + string(IssueTypeServiceIncident), + string(IssueTypeUserIssue), + } +} + +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIssueType(input string) (*IssueType, error) { + vals := map[string]IssueType{ + "appcrash": IssueTypeAppCrash, + "appdeployment": IssueTypeAppDeployment, + "asedeployment": IssueTypeAseDeployment, + "other": IssueTypeOther, + "platformissue": IssueTypePlatformIssue, + "runtimeissuedetected": IssueTypeRuntimeIssueDetected, + "serviceincident": IssueTypeServiceIncident, + "userissue": IssueTypeUserIssue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IssueType(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} + +type SolutionType string + +const ( + SolutionTypeBestPractices SolutionType = "BestPractices" + SolutionTypeDeepInvestigation SolutionType = "DeepInvestigation" + SolutionTypeQuickSolution SolutionType = "QuickSolution" +) + +func PossibleValuesForSolutionType() []string { + return []string{ + string(SolutionTypeBestPractices), + string(SolutionTypeDeepInvestigation), + string(SolutionTypeQuickSolution), + } +} + +func (s *SolutionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSolutionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSolutionType(input string) (*SolutionType, error) { + vals := map[string]SolutionType{ + "bestpractices": SolutionTypeBestPractices, + "deepinvestigation": SolutionTypeDeepInvestigation, + "quicksolution": SolutionTypeQuickSolution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SolutionType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_analysis.go b/resource-manager/web/2024-04-01/diagnostics/id_analysis.go new file mode 100644 index 00000000000..4ad7593663b --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_analysis.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AnalysisId{}) +} + +var _ resourceids.ResourceId = &AnalysisId{} + +// AnalysisId is a struct representing the Resource ID for a Analysis +type AnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + AnalysisName string +} + +// NewAnalysisID returns a new AnalysisId struct +func NewAnalysisID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, analysisName string) AnalysisId { + return AnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseAnalysisID parses 'input' into a AnalysisId +func ParseAnalysisID(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAnalysisIDInsensitively parses 'input' case-insensitively into a AnalysisId +// note: this method should only be used for API response data and not user input +func ParseAnalysisIDInsensitively(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AnalysisId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateAnalysisID checks that 'input' can be parsed as a Analysis ID +func ValidateAnalysisID(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 := ParseAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Analysis ID +func (id AnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Analysis ID +func (id AnalysisId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisName"), + } +} + +// String returns a human-readable description of this Analysis ID +func (id AnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_analysis_test.go b/resource-manager/web/2024-04-01/diagnostics/id_analysis_test.go new file mode 100644 index 00000000000..b5a41dcb6b7 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_analysis_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &AnalysisId{} + +func TestNewAnalysisID(t *testing.T) { + id := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.AnalysisName != "analysisName" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisName") + } +} + +func TestFormatAnalysisID(t *testing.T) { + actual := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + AnalysisName: "aNaLySiSnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForAnalysisId(t *testing.T) { + segments := AnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AnalysisId 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/web/2024-04-01/diagnostics/id_detector.go b/resource-manager/web/2024-04-01/diagnostics/id_detector.go new file mode 100644 index 00000000000..5fbc7237434 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_detector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, siteName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(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 := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_detector_test.go b/resource-manager/web/2024-04-01/diagnostics/id_detector_test.go new file mode 100644 index 00000000000..fd49dc7f61d --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_detector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId 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/web/2024-04-01/diagnostics/id_diagnostic.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnostic.go new file mode 100644 index 00000000000..d8f916e4863 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnostic.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DiagnosticId{}) +} + +var _ resourceids.ResourceId = &DiagnosticId{} + +// DiagnosticId is a struct representing the Resource ID for a Diagnostic +type DiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string +} + +// NewDiagnosticID returns a new DiagnosticId struct +func NewDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string) DiagnosticId { + return DiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + } +} + +// ParseDiagnosticID parses 'input' into a DiagnosticId +func ParseDiagnosticID(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticIDInsensitively parses 'input' case-insensitively into a DiagnosticId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticIDInsensitively(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateDiagnosticID checks that 'input' can be parsed as a Diagnostic ID +func ValidateDiagnosticID(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 := ParseDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic ID +func (id DiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic ID +func (id DiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Diagnostic ID +func (id DiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_diagnostic_test.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnostic_test.go new file mode 100644 index 00000000000..f75e156e5bb --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnostic_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DiagnosticId{} + +func TestNewDiagnosticID(t *testing.T) { + id := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatDiagnosticID(t *testing.T) { + actual := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForDiagnosticId(t *testing.T) { + segments := DiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticId 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/web/2024-04-01/diagnostics/id_diagnosticanalysis.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticanalysis.go new file mode 100644 index 00000000000..c2a851a5780 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticanalysis.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DiagnosticAnalysisId{}) +} + +var _ resourceids.ResourceId = &DiagnosticAnalysisId{} + +// DiagnosticAnalysisId is a struct representing the Resource ID for a Diagnostic Analysis +type DiagnosticAnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + AnalysisName string +} + +// NewDiagnosticAnalysisID returns a new DiagnosticAnalysisId struct +func NewDiagnosticAnalysisID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, analysisName string) DiagnosticAnalysisId { + return DiagnosticAnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseDiagnosticAnalysisID parses 'input' into a DiagnosticAnalysisId +func ParseDiagnosticAnalysisID(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticAnalysisIDInsensitively parses 'input' case-insensitively into a DiagnosticAnalysisId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticAnalysisIDInsensitively(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticAnalysisId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateDiagnosticAnalysisID checks that 'input' can be parsed as a Diagnostic Analysis ID +func ValidateDiagnosticAnalysisID(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 := ParseDiagnosticAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Analysis ID +func (id DiagnosticAnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisName"), + } +} + +// String returns a human-readable description of this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Diagnostic Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_diagnosticanalysis_test.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticanalysis_test.go new file mode 100644 index 00000000000..88593f85f7f --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticanalysis_test.go @@ -0,0 +1,417 @@ +package diagnostics + +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 = &DiagnosticAnalysisId{} + +func TestNewDiagnosticAnalysisID(t *testing.T) { + id := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.AnalysisName != "analysisName" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisName") + } +} + +func TestFormatDiagnosticAnalysisID(t *testing.T) { + actual := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseDiagnosticAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + AnalysisName: "aNaLySiSnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForDiagnosticAnalysisId(t *testing.T) { + segments := DiagnosticAnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticAnalysisId 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/web/2024-04-01/diagnostics/id_diagnosticdetector.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticdetector.go new file mode 100644 index 00000000000..cf131c1681f --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &DiagnosticDetectorId{} + +// DiagnosticDetectorId is a struct representing the Resource ID for a Diagnostic Detector +type DiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + DetectorName string +} + +// NewDiagnosticDetectorID returns a new DiagnosticDetectorId struct +func NewDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, detectorName string) DiagnosticDetectorId { + return DiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseDiagnosticDetectorID parses 'input' into a DiagnosticDetectorId +func ParseDiagnosticDetectorID(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a DiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticDetectorIDInsensitively(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDiagnosticDetectorID checks that 'input' can be parsed as a Diagnostic Detector ID +func ValidateDiagnosticDetectorID(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 := ParseDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Detector ID +func (id DiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Detector ID +func (id DiagnosticDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Diagnostic Detector ID +func (id DiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_diagnosticdetector_test.go b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticdetector_test.go new file mode 100644 index 00000000000..cd45a7927c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_diagnosticdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &DiagnosticDetectorId{} + +func TestNewDiagnosticDetectorID(t *testing.T) { + id := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatDiagnosticDetectorID(t *testing.T) { + actual := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDiagnosticDetectorId(t *testing.T) { + segments := DiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticDetectorId 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/web/2024-04-01/diagnostics/id_hostingenvironmentdetector.go b/resource-manager/web/2024-04-01/diagnostics/id_hostingenvironmentdetector.go new file mode 100644 index 00000000000..617be4bec18 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_hostingenvironmentdetector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDetectorId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDetectorId{} + +// HostingEnvironmentDetectorId is a struct representing the Resource ID for a Hosting Environment Detector +type HostingEnvironmentDetectorId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DetectorName string +} + +// NewHostingEnvironmentDetectorID returns a new HostingEnvironmentDetectorId struct +func NewHostingEnvironmentDetectorID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, detectorName string) HostingEnvironmentDetectorId { + return HostingEnvironmentDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DetectorName: detectorName, + } +} + +// ParseHostingEnvironmentDetectorID parses 'input' into a HostingEnvironmentDetectorId +func ParseHostingEnvironmentDetectorID(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDetectorIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDetectorId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDetectorIDInsensitively(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDetectorId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDetectorID checks that 'input' can be parsed as a Hosting Environment Detector ID +func ValidateHostingEnvironmentDetectorID(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 := ParseHostingEnvironmentDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Hosting Environment Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_hostingenvironmentdetector_test.go b/resource-manager/web/2024-04-01/diagnostics/id_hostingenvironmentdetector_test.go new file mode 100644 index 00000000000..6063fa9cdc0 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_hostingenvironmentdetector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &HostingEnvironmentDetectorId{} + +func TestNewHostingEnvironmentDetectorID(t *testing.T) { + id := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatHostingEnvironmentDetectorID(t *testing.T) { + actual := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseHostingEnvironmentDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDetectorId(t *testing.T) { + segments := HostingEnvironmentDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDetectorId 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/web/2024-04-01/diagnostics/id_slot.go b/resource-manager/web/2024-04-01/diagnostics/id_slot.go new file mode 100644 index 00000000000..3458e4a3bca --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slot.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_slot_test.go b/resource-manager/web/2024-04-01/diagnostics/id_slot_test.go new file mode 100644 index 00000000000..591c34ab7b7 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slot_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2024-04-01/diagnostics/id_slotdetector.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdetector.go new file mode 100644 index 00000000000..287984b0bc5 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDetectorId{} + +// SlotDetectorId is a struct representing the Resource ID for a Slot Detector +type SlotDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DetectorName string +} + +// NewSlotDetectorID returns a new SlotDetectorId struct +func NewSlotDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, detectorName string) SlotDetectorId { + return SlotDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DetectorName: detectorName, + } +} + +// ParseSlotDetectorID parses 'input' into a SlotDetectorId +func ParseSlotDetectorID(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDetectorIDInsensitively parses 'input' case-insensitively into a SlotDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDetectorIDInsensitively(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDetectorID checks that 'input' can be parsed as a Slot Detector ID +func ValidateSlotDetectorID(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 := ParseSlotDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Detector ID +func (id SlotDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Detector ID +func (id SlotDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Slot Detector ID +func (id SlotDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_slotdetector_test.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdetector_test.go new file mode 100644 index 00000000000..32e7f62003b --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &SlotDetectorId{} + +func TestNewSlotDetectorID(t *testing.T) { + id := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatSlotDetectorID(t *testing.T) { + actual := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDetectorId(t *testing.T) { + segments := SlotDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDetectorId 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/web/2024-04-01/diagnostics/id_slotdiagnostic.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnostic.go new file mode 100644 index 00000000000..d94b24e79f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnostic.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticId{} + +// SlotDiagnosticId is a struct representing the Resource ID for a Slot Diagnostic +type SlotDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string +} + +// NewSlotDiagnosticID returns a new SlotDiagnosticId struct +func NewSlotDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string) SlotDiagnosticId { + return SlotDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + } +} + +// ParseSlotDiagnosticID parses 'input' into a SlotDiagnosticId +func ParseSlotDiagnosticID(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticIDInsensitively(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateSlotDiagnosticID checks that 'input' can be parsed as a Slot Diagnostic ID +func ValidateSlotDiagnosticID(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 := ParseSlotDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic ID +func (id SlotDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic ID +func (id SlotDiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Slot Diagnostic ID +func (id SlotDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Slot Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnostic_test.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnostic_test.go new file mode 100644 index 00000000000..af97181d8ad --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnostic_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &SlotDiagnosticId{} + +func TestNewSlotDiagnosticID(t *testing.T) { + id := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatSlotDiagnosticID(t *testing.T) { + actual := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseSlotDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForSlotDiagnosticId(t *testing.T) { + segments := SlotDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticId 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/web/2024-04-01/diagnostics/id_slotdiagnosticdetector.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnosticdetector.go new file mode 100644 index 00000000000..98ccbee3b33 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnosticdetector.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticDetectorId{} + +// SlotDiagnosticDetectorId is a struct representing the Resource ID for a Slot Diagnostic Detector +type SlotDiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + DetectorName string +} + +// NewSlotDiagnosticDetectorID returns a new SlotDiagnosticDetectorId struct +func NewSlotDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, detectorName string) SlotDiagnosticDetectorId { + return SlotDiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseSlotDiagnosticDetectorID parses 'input' into a SlotDiagnosticDetectorId +func ParseSlotDiagnosticDetectorID(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticDetectorIDInsensitively(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDiagnosticDetectorID checks that 'input' can be parsed as a Slot Diagnostic Detector ID +func ValidateSlotDiagnosticDetectorID(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 := ParseSlotDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnosticdetector_test.go b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnosticdetector_test.go new file mode 100644 index 00000000000..bfb6c97fbd8 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/id_slotdiagnosticdetector_test.go @@ -0,0 +1,417 @@ +package diagnostics + +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 = &SlotDiagnosticDetectorId{} + +func TestNewSlotDiagnosticDetectorID(t *testing.T) { + id := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatSlotDiagnosticDetectorID(t *testing.T) { + actual := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDiagnosticDetectorId(t *testing.T) { + segments := SlotDiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticDetectorId 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/web/2024-04-01/diagnostics/method_executesiteanalysis.go b/resource-manager/web/2024-04-01/diagnostics/method_executesiteanalysis.go new file mode 100644 index 00000000000..d9114e45262 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_executesiteanalysis.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisOperationOptions() ExecuteSiteAnalysisOperationOptions { + return ExecuteSiteAnalysisOperationOptions{} +} + +func (o ExecuteSiteAnalysisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysis ... +func (c DiagnosticsClient) ExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (result ExecuteSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticAnalysis + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_executesiteanalysisslot.go b/resource-manager/web/2024-04-01/diagnostics/method_executesiteanalysisslot.go new file mode 100644 index 00000000000..fb43cf7b571 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_executesiteanalysisslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisSlotOperationOptions() ExecuteSiteAnalysisSlotOperationOptions { + return ExecuteSiteAnalysisSlotOperationOptions{} +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysisSlot ... +func (c DiagnosticsClient) ExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticAnalysis + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_executesitedetector.go b/resource-manager/web/2024-04-01/diagnostics/method_executesitedetector.go new file mode 100644 index 00000000000..95fdc0e086d --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_executesitedetector.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorOperationOptions() ExecuteSiteDetectorOperationOptions { + return ExecuteSiteDetectorOperationOptions{} +} + +func (o ExecuteSiteDetectorOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetector ... +func (c DiagnosticsClient) ExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (result ExecuteSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticDetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_executesitedetectorslot.go b/resource-manager/web/2024-04-01/diagnostics/method_executesitedetectorslot.go new file mode 100644 index 00000000000..a4058304682 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_executesitedetectorslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorSlotOperationOptions() ExecuteSiteDetectorSlotOperationOptions { + return ExecuteSiteDetectorSlotOperationOptions{} +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetectorSlot ... +func (c DiagnosticsClient) ExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (result ExecuteSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticDetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_gethostingenvironmentdetectorresponse.go b/resource-manager/web/2024-04-01/diagnostics/method_gethostingenvironmentdetectorresponse.go new file mode 100644 index 00000000000..146dae82a1c --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_gethostingenvironmentdetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetHostingEnvironmentDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetHostingEnvironmentDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetHostingEnvironmentDetectorResponseOperationOptions() GetHostingEnvironmentDetectorResponseOperationOptions { + return GetHostingEnvironmentDetectorResponseOperationOptions{} +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetHostingEnvironmentDetectorResponse ... +func (c DiagnosticsClient) GetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (result GetHostingEnvironmentDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysis.go b/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysis.go new file mode 100644 index 00000000000..b730bee1e40 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysis.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysis ... +func (c DiagnosticsClient) GetSiteAnalysis(ctx context.Context, id AnalysisId) (result GetSiteAnalysisOperationResponse, 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 + } + + var model AnalysisDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysisslot.go b/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysisslot.go new file mode 100644 index 00000000000..14ca76fb852 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsiteanalysisslot.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysisSlot ... +func (c DiagnosticsClient) GetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (result GetSiteAnalysisSlotOperationResponse, 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 + } + + var model AnalysisDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitedetector.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetector.go new file mode 100644 index 00000000000..e90a21838ca --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetector.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetector ... +func (c DiagnosticsClient) GetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (result GetSiteDetectorOperationResponse, 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 + } + + var model DetectorDefinitionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponse.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponse.go new file mode 100644 index 00000000000..91a987796f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetSiteDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseOperationOptions() GetSiteDetectorResponseOperationOptions { + return GetSiteDetectorResponseOperationOptions{} +} + +func (o GetSiteDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponse ... +func (c DiagnosticsClient) GetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (result GetSiteDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponseslot.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponseslot.go new file mode 100644 index 00000000000..84580774fc2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorresponseslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetSiteDetectorResponseSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseSlotOperationOptions() GetSiteDetectorResponseSlotOperationOptions { + return GetSiteDetectorResponseSlotOperationOptions{} +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponseSlot ... +func (c DiagnosticsClient) GetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (result GetSiteDetectorResponseSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorslot.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorslot.go new file mode 100644 index 00000000000..3f2a72744f1 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitedetectorslot.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetectorSlot ... +func (c DiagnosticsClient) GetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (result GetSiteDetectorSlotOperationResponse, 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 + } + + var model DetectorDefinitionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategory.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategory.go new file mode 100644 index 00000000000..1ddb7a72135 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategory.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteDiagnosticCategoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategory ... +func (c DiagnosticsClient) GetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (result GetSiteDiagnosticCategoryOperationResponse, 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 + } + + var model DiagnosticCategory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategoryslot.go b/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategoryslot.go new file mode 100644 index 00000000000..c6572ee2994 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_getsitediagnosticcategoryslot.go @@ -0,0 +1,53 @@ +package diagnostics + +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 GetSiteDiagnosticCategorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategorySlot ... +func (c DiagnosticsClient) GetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (result GetSiteDiagnosticCategorySlotOperationResponse, 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 + } + + var model DiagnosticCategory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listhostingenvironmentdetectorresponses.go b/resource-manager/web/2024-04-01/diagnostics/method_listhostingenvironmentdetectorresponses.go new file mode 100644 index 00000000000..f112dde06bf --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listhostingenvironmentdetectorresponses.go @@ -0,0 +1,106 @@ +package diagnostics + +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 ListHostingEnvironmentDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostingEnvironmentDetectorResponsesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostingEnvironmentDetectorResponses ... +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponses(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostingEnvironmentDetectorResponsesCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostingEnvironmentDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListHostingEnvironmentDetectorResponsesCompleteResult, error) { + return c.ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate DetectorResponseOperationPredicate) (result ListHostingEnvironmentDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListHostingEnvironmentDetectorResponses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHostingEnvironmentDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalyses.go b/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalyses.go new file mode 100644 index 00000000000..91c871786aa --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalyses.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteAnalysesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +type ListSiteAnalysesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteAnalysesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteAnalyses ... +func (c DiagnosticsClient) ListSiteAnalyses(ctx context.Context, id DiagnosticId) (result ListSiteAnalysesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteAnalysesCustomPager{}, + Path: fmt.Sprintf("%s/analyses", 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 *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesComplete(ctx context.Context, id DiagnosticId) (ListSiteAnalysesCompleteResult, error) { + return c.ListSiteAnalysesCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalyses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteAnalysesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalysesslot.go b/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalysesslot.go new file mode 100644 index 00000000000..23f4e7d5c77 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsiteanalysesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteAnalysesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +type ListSiteAnalysesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteAnalysesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteAnalysesSlot ... +func (c DiagnosticsClient) ListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteAnalysesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteAnalysesSlotCustomPager{}, + Path: fmt.Sprintf("%s/analyses", 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 *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteAnalysesSlotCompleteResult, error) { + return c.ListSiteAnalysesSlotCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesSlotCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalysesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteAnalysesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponses.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponses.go new file mode 100644 index 00000000000..69a5711f698 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponses.go @@ -0,0 +1,106 @@ +package diagnostics + +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 ListSiteDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListSiteDetectorResponsesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorResponsesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorResponses ... +func (c DiagnosticsClient) ListSiteDetectorResponses(ctx context.Context, id commonids.AppServiceId) (result ListSiteDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorResponsesCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDetectorResponsesCompleteResult, error) { + return c.ListSiteDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponsesslot.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponsesslot.go new file mode 100644 index 00000000000..d50bb289cf4 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorresponsesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorResponsesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListSiteDetectorResponsesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorResponsesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorResponsesSlot ... +func (c DiagnosticsClient) ListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorResponsesSlotCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotComplete(ctx context.Context, id SlotId) (ListSiteDetectorResponsesSlotCompleteResult, error) { + return c.ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesSlotCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponsesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDetectorResponsesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectors.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectors.go new file mode 100644 index 00000000000..ee307b8dfde --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectors.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +type ListSiteDetectorsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectors ... +func (c DiagnosticsClient) ListSiteDetectors(ctx context.Context, id DiagnosticId) (result ListSiteDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorsCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsComplete(ctx context.Context, id DiagnosticId) (ListSiteDetectorsCompleteResult, error) { + return c.ListSiteDetectorsCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectors(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorsslot.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorsslot.go new file mode 100644 index 00000000000..eb8b985ebc6 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitedetectorsslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorsSlot ... +func (c DiagnosticsClient) ListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteDetectorsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorsSlotCustomPager{}, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteDetectorsSlotCompleteResult, error) { + return c.ListSiteDetectorsSlotCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsSlotCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectorsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDetectorsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategories.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategories.go new file mode 100644 index 00000000000..29ffd71a26c --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategories.go @@ -0,0 +1,106 @@ +package diagnostics + +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 ListSiteDiagnosticCategoriesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDiagnosticCategoriesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDiagnosticCategories ... +func (c DiagnosticsClient) ListSiteDiagnosticCategories(ctx context.Context, id commonids.AppServiceId) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDiagnosticCategoriesCustomPager{}, + Path: fmt.Sprintf("%s/diagnostics", 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 *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDiagnosticCategoriesCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategories(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDiagnosticCategoriesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategoriesslot.go b/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategoriesslot.go new file mode 100644 index 00000000000..1236f4d4ea2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/method_listsitediagnosticcategoriesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDiagnosticCategoriesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDiagnosticCategoriesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDiagnosticCategoriesSlot ... +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDiagnosticCategoriesSlotCustomPager{}, + Path: fmt.Sprintf("%s/diagnostics", 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 *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotComplete(ctx context.Context, id SlotId) (ListSiteDiagnosticCategoriesSlotCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesSlotCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategoriesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteDiagnosticCategoriesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_abnormaltimeperiod.go b/resource-manager/web/2024-04-01/diagnostics/model_abnormaltimeperiod.go new file mode 100644 index 00000000000..a6df9ee83ab --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_abnormaltimeperiod.go @@ -0,0 +1,41 @@ +package diagnostics + +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 AbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Events *[]DetectorAbnormalTimePeriod `json:"events,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *AbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_analysisdata.go b/resource-manager/web/2024-04-01/diagnostics/model_analysisdata.go new file mode 100644 index 00000000000..58dc2411c1b --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_analysisdata.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisData struct { + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + DetectorMetaData *ResponseMetaData `json:"detectorMetaData,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + Source *string `json:"source,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinition.go b/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinition.go new file mode 100644 index 00000000000..08e03e1c0a0 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinition.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AnalysisDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinitionproperties.go b/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinitionproperties.go new file mode 100644 index 00000000000..8a0e57964d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_analysisdefinitionproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_dataprovidermetadata.go b/resource-manager/web/2024-04-01/diagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..c6f80aabe5f --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_datasource.go b/resource-manager/web/2024-04-01/diagnostics/model_datasource.go new file mode 100644 index 00000000000..5843559ebf5 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_datasource.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSource struct { + DataSourceUri *[]NameValuePair `json:"dataSourceUri,omitempty"` + Instructions *[]string `json:"instructions,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2024-04-01/diagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..7ff0fb87216 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_datatableresponseobject.go b/resource-manager/web/2024-04-01/diagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..579ce5cc5d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectorabnormaltimeperiod.go b/resource-manager/web/2024-04-01/diagnostics/model_detectorabnormaltimeperiod.go new file mode 100644 index 00000000000..e0f1933477a --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectorabnormaltimeperiod.go @@ -0,0 +1,45 @@ +package diagnostics + +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 DetectorAbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Message *string `json:"message,omitempty"` + MetaData *[][]NameValuePair `json:"metaData,omitempty"` + Priority *float64 `json:"priority,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + Source *string `json:"source,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Type *IssueType `json:"type,omitempty"` +} + +func (o *DetectorAbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DetectorAbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectordefinition.go b/resource-manager/web/2024-04-01/diagnostics/model_detectordefinition.go new file mode 100644 index 00000000000..8bd10bf28f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectordefinition.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinition struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Rank *float64 `json:"rank,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectordefinitionresource.go b/resource-manager/web/2024-04-01/diagnostics/model_detectordefinitionresource.go new file mode 100644 index 00000000000..3493647c958 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectordefinitionresource.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinitionResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorDefinition `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectorinfo.go b/resource-manager/web/2024-04-01/diagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..153af1a6eec --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectorresponse.go b/resource-manager/web/2024-04-01/diagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..3f2ea2b54a4 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_detectorresponseproperties.go b/resource-manager/web/2024-04-01/diagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..dbad1bb6b3c --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysis.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysis.go new file mode 100644 index 00000000000..86feeab70a5 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysis.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticAnalysis struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticAnalysisProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysisproperties.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysisproperties.go new file mode 100644 index 00000000000..e60f737dd9c --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticanalysisproperties.go @@ -0,0 +1,42 @@ +package diagnostics + +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 DiagnosticAnalysisProperties struct { + AbnormalTimePeriods *[]AbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + EndTime *string `json:"endTime,omitempty"` + NonCorrelatedDetectors *[]DetectorDefinition `json:"nonCorrelatedDetectors,omitempty"` + Payload *[]AnalysisData `json:"payload,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticAnalysisProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticAnalysisProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategory.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategory.go new file mode 100644 index 00000000000..edcfc1a5905 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategory.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticCategoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategoryproperties.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategoryproperties.go new file mode 100644 index 00000000000..d00339539f9 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticcategoryproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategoryProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdata.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..86888b44d22 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponse.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponse.go new file mode 100644 index 00000000000..7cdae4bd506 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticDetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponseproperties.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponseproperties.go new file mode 100644 index 00000000000..b936047e0c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticdetectorresponseproperties.go @@ -0,0 +1,45 @@ +package diagnostics + +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 DiagnosticDetectorResponseProperties struct { + AbnormalTimePeriods *[]DetectorAbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + EndTime *string `json:"endTime,omitempty"` + IssueDetected *bool `json:"issueDetected,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + ResponseMetaData *ResponseMetaData `json:"responseMetaData,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticDetectorResponseProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticDetectorResponseProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricsample.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricsample.go new file mode 100644 index 00000000000..1d0bb623c41 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricsample.go @@ -0,0 +1,31 @@ +package diagnostics + +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 DiagnosticMetricSample struct { + IsAggregated *bool `json:"isAggregated,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + RoleInstance *string `json:"roleInstance,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Total *float64 `json:"total,omitempty"` +} + +func (o *DiagnosticMetricSample) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSample) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricset.go b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricset.go new file mode 100644 index 00000000000..b1331ff017b --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_diagnosticmetricset.go @@ -0,0 +1,43 @@ +package diagnostics + +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 DiagnosticMetricSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *string `json:"unit,omitempty"` + Values *[]DiagnosticMetricSample `json:"values,omitempty"` +} + +func (o *DiagnosticMetricSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticMetricSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2024-04-01/diagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..f1376667ff2 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_namevaluepair.go b/resource-manager/web/2024-04-01/diagnostics/model_namevaluepair.go new file mode 100644 index 00000000000..78a664c6c65 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_namevaluepair.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresult.go b/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..e2f31e703c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresults.go b/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..3a4443fd8f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_rendering.go b/resource-manager/web/2024-04-01/diagnostics/model_rendering.go new file mode 100644 index 00000000000..a5a796665bc --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_responsemetadata.go b/resource-manager/web/2024-04-01/diagnostics/model_responsemetadata.go new file mode 100644 index 00000000000..e887117c071 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_responsemetadata.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMetaData struct { + DataSource *DataSource `json:"dataSource,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_sampleutterance.go b/resource-manager/web/2024-04-01/diagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..a6d9970ed40 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_solution.go b/resource-manager/web/2024-04-01/diagnostics/model_solution.go new file mode 100644 index 00000000000..c19e80a66a9 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_solution.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Solution struct { + Data *[][]NameValuePair `json:"data,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *float64 `json:"id,omitempty"` + Metadata *[][]NameValuePair `json:"metadata,omitempty"` + Order *float64 `json:"order,omitempty"` + Type *SolutionType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_status.go b/resource-manager/web/2024-04-01/diagnostics/model_status.go new file mode 100644 index 00000000000..3f71907964e --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_status.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/model_supporttopic.go b/resource-manager/web/2024-04-01/diagnostics/model_supporttopic.go new file mode 100644 index 00000000000..096120c069d --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/diagnostics/predicates.go b/resource-manager/web/2024-04-01/diagnostics/predicates.go new file mode 100644 index 00000000000..660a1c908be --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/predicates.go @@ -0,0 +1,116 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AnalysisDefinitionOperationPredicate) Matches(input AnalysisDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DetectorDefinitionResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorDefinitionResourceOperationPredicate) Matches(input DetectorDefinitionResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DiagnosticCategoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DiagnosticCategoryOperationPredicate) Matches(input DiagnosticCategory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/diagnostics/version.go b/resource-manager/web/2024-04-01/diagnostics/version.go new file mode 100644 index 00000000000..c8f20e94979 --- /dev/null +++ b/resource-manager/web/2024-04-01/diagnostics/version.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/diagnostics/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/domains/README.md b/resource-manager/web/2024-04-01/domains/README.md new file mode 100644 index 00000000000..8eda5e64048 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/README.md @@ -0,0 +1,307 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/domains` Documentation + +The `domains` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/domains" +``` + + +### Client Initialization + +```go +client := domains.NewDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DomainsClient.CheckAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.NameIdentifier{ + // ... +} + + +read, err := client.CheckAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +payload := domains.Domain{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.CreateOrUpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Delete` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.Delete(ctx, id, domains.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.DeleteOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +read, err := client.DeleteOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Get` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +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: `DomainsClient.GetControlCenterSsoRequest` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetControlCenterSsoRequest(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.GetOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +read, err := client.GetOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `DomainsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +// alternatively `client.ListOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListRecommendations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.DomainRecommendationSearchParameters{ + // ... +} + + +// alternatively `client.ListRecommendations(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListRecommendationsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.Renew` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.Renew(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.TransferOut` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.TransferOut(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Update` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +payload := domains.DomainPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.UpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.UpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/domains/client.go b/resource-manager/web/2024-04-01/domains/client.go new file mode 100644 index 00000000000..59ee394333f --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/client.go @@ -0,0 +1,26 @@ +package domains + +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 DomainsClient struct { + Client *resourcemanager.Client +} + +func NewDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*DomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "domains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DomainsClient: %+v", err) + } + + return &DomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/domains/constants.go b/resource-manager/web/2024-04-01/domains/constants.go new file mode 100644 index 00000000000..a2302025ac5 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/constants.go @@ -0,0 +1,407 @@ +package domains + +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 AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DnsType string + +const ( + DnsTypeAzureDns DnsType = "AzureDns" + DnsTypeDefaultDomainRegistrarDns DnsType = "DefaultDomainRegistrarDns" +) + +func PossibleValuesForDnsType() []string { + return []string{ + string(DnsTypeAzureDns), + string(DnsTypeDefaultDomainRegistrarDns), + } +} + +func (s *DnsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsType(input string) (*DnsType, error) { + vals := map[string]DnsType{ + "azuredns": DnsTypeAzureDns, + "defaultdomainregistrardns": DnsTypeDefaultDomainRegistrarDns, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsType(input) + return &out, nil +} + +type DomainStatus string + +const ( + DomainStatusActive DomainStatus = "Active" + DomainStatusAwaiting DomainStatus = "Awaiting" + DomainStatusCancelled DomainStatus = "Cancelled" + DomainStatusConfiscated DomainStatus = "Confiscated" + DomainStatusDisabled DomainStatus = "Disabled" + DomainStatusExcluded DomainStatus = "Excluded" + DomainStatusExpired DomainStatus = "Expired" + DomainStatusFailed DomainStatus = "Failed" + DomainStatusHeld DomainStatus = "Held" + DomainStatusJsonConverterFailed DomainStatus = "JsonConverterFailed" + DomainStatusLocked DomainStatus = "Locked" + DomainStatusParked DomainStatus = "Parked" + DomainStatusPending DomainStatus = "Pending" + DomainStatusReserved DomainStatus = "Reserved" + DomainStatusReverted DomainStatus = "Reverted" + DomainStatusSuspended DomainStatus = "Suspended" + DomainStatusTransferred DomainStatus = "Transferred" + DomainStatusUnknown DomainStatus = "Unknown" + DomainStatusUnlocked DomainStatus = "Unlocked" + DomainStatusUnparked DomainStatus = "Unparked" + DomainStatusUpdated DomainStatus = "Updated" +) + +func PossibleValuesForDomainStatus() []string { + return []string{ + string(DomainStatusActive), + string(DomainStatusAwaiting), + string(DomainStatusCancelled), + string(DomainStatusConfiscated), + string(DomainStatusDisabled), + string(DomainStatusExcluded), + string(DomainStatusExpired), + string(DomainStatusFailed), + string(DomainStatusHeld), + string(DomainStatusJsonConverterFailed), + string(DomainStatusLocked), + string(DomainStatusParked), + string(DomainStatusPending), + string(DomainStatusReserved), + string(DomainStatusReverted), + string(DomainStatusSuspended), + string(DomainStatusTransferred), + string(DomainStatusUnknown), + string(DomainStatusUnlocked), + string(DomainStatusUnparked), + string(DomainStatusUpdated), + } +} + +func (s *DomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainStatus(input string) (*DomainStatus, error) { + vals := map[string]DomainStatus{ + "active": DomainStatusActive, + "awaiting": DomainStatusAwaiting, + "cancelled": DomainStatusCancelled, + "confiscated": DomainStatusConfiscated, + "disabled": DomainStatusDisabled, + "excluded": DomainStatusExcluded, + "expired": DomainStatusExpired, + "failed": DomainStatusFailed, + "held": DomainStatusHeld, + "jsonconverterfailed": DomainStatusJsonConverterFailed, + "locked": DomainStatusLocked, + "parked": DomainStatusParked, + "pending": DomainStatusPending, + "reserved": DomainStatusReserved, + "reverted": DomainStatusReverted, + "suspended": DomainStatusSuspended, + "transferred": DomainStatusTransferred, + "unknown": DomainStatusUnknown, + "unlocked": DomainStatusUnlocked, + "unparked": DomainStatusUnparked, + "updated": DomainStatusUpdated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainStatus(input) + return &out, nil +} + +type DomainType string + +const ( + DomainTypeRegular DomainType = "Regular" + DomainTypeSoftDeleted DomainType = "SoftDeleted" +) + +func PossibleValuesForDomainType() []string { + return []string{ + string(DomainTypeRegular), + string(DomainTypeSoftDeleted), + } +} + +func (s *DomainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainType(input string) (*DomainType, error) { + vals := map[string]DomainType{ + "regular": DomainTypeRegular, + "softdeleted": DomainTypeSoftDeleted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainType(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/domains/id_domain.go b/resource-manager/web/2024-04-01/domains/id_domain.go new file mode 100644 index 00000000000..2aa26691017 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/id_domain.go @@ -0,0 +1,130 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DomainId{}) +} + +var _ resourceids.ResourceId = &DomainId{} + +// DomainId is a struct representing the Resource ID for a Domain +type DomainId struct { + SubscriptionId string + ResourceGroupName string + DomainName string +} + +// NewDomainID returns a new DomainId struct +func NewDomainID(subscriptionId string, resourceGroupName string, domainName string) DomainId { + return DomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + } +} + +// ParseDomainID parses 'input' into a DomainId +func ParseDomainID(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainIDInsensitively parses 'input' case-insensitively into a DomainId +// note: this method should only be used for API response data and not user input +func ParseDomainIDInsensitively(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainId) 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.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + return nil +} + +// ValidateDomainID checks that 'input' can be parsed as a Domain ID +func ValidateDomainID(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 := ParseDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain ID +func (id DomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain ID +func (id DomainId) 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("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainName"), + } +} + +// String returns a human-readable description of this Domain ID +func (id DomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + } + return fmt.Sprintf("Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/domains/id_domain_test.go b/resource-manager/web/2024-04-01/domains/id_domain_test.go new file mode 100644 index 00000000000..e07dc94da5a --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/id_domain_test.go @@ -0,0 +1,282 @@ +package domains + +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 = &DomainId{} + +func TestNewDomainID(t *testing.T) { + id := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + + 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.DomainName != "domainName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainName") + } +} + +func TestFormatDomainID(t *testing.T) { + actual := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainID(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.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestParseDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNnAmE", + }, + }, + { + // 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.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainIDInsensitively(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.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestSegmentsForDomainId(t *testing.T) { + segments := DomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainId 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/web/2024-04-01/domains/id_domainownershipidentifier.go b/resource-manager/web/2024-04-01/domains/id_domainownershipidentifier.go new file mode 100644 index 00000000000..d15193f1a7b --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/id_domainownershipidentifier.go @@ -0,0 +1,139 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &DomainOwnershipIdentifierId{} + +// DomainOwnershipIdentifierId is a struct representing the Resource ID for a Domain Ownership Identifier +type DomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + DomainName string + DomainOwnershipIdentifierName string +} + +// NewDomainOwnershipIdentifierID returns a new DomainOwnershipIdentifierId struct +func NewDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, domainName string, domainOwnershipIdentifierName string) DomainOwnershipIdentifierId { + return DomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseDomainOwnershipIdentifierID parses 'input' into a DomainOwnershipIdentifierId +func ParseDomainOwnershipIdentifierID(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a DomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseDomainOwnershipIdentifierIDInsensitively(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainOwnershipIdentifierId) 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.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateDomainOwnershipIdentifierID checks that 'input' can be parsed as a Domain Ownership Identifier ID +func ValidateDomainOwnershipIdentifierID(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 := ParseDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) 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("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/domains/id_domainownershipidentifier_test.go b/resource-manager/web/2024-04-01/domains/id_domainownershipidentifier_test.go new file mode 100644 index 00000000000..14debd4f5fb --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/id_domainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package domains + +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 = &DomainOwnershipIdentifierId{} + +func TestNewDomainOwnershipIdentifierID(t *testing.T) { + id := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + + 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.DomainName != "domainName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatDomainOwnershipIdentifierID(t *testing.T) { + actual := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierID(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.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // 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.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierIDInsensitively(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.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForDomainOwnershipIdentifierId(t *testing.T) { + segments := DomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainOwnershipIdentifierId 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/web/2024-04-01/domains/method_checkavailability.go b/resource-manager/web/2024-04-01/domains/method_checkavailability.go new file mode 100644 index 00000000000..1ebced69f7f --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_checkavailability.go @@ -0,0 +1,59 @@ +package domains + +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 CheckAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainAvailabilityCheckResult +} + +// CheckAvailability ... +func (c DomainsClient) CheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result CheckAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/checkDomainAvailability", 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 + } + + var model DomainAvailabilityCheckResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_createorupdate.go b/resource-manager/web/2024-04-01/domains/method_createorupdate.go new file mode 100644 index 00000000000..42b7775e27c --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_createorupdate.go @@ -0,0 +1,75 @@ +package domains + +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 + Model *Domain +} + +// CreateOrUpdate ... +func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input Domain) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input Domain) 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/web/2024-04-01/domains/method_createorupdateownershipidentifier.go b/resource-manager/web/2024-04-01/domains/method_createorupdateownershipidentifier.go new file mode 100644 index 00000000000..7a48ce2a59c --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_createorupdateownershipidentifier.go @@ -0,0 +1,57 @@ +package domains + +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 CreateOrUpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// CreateOrUpdateOwnershipIdentifier ... +func (c DomainsClient) CreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_delete.go b/resource-manager/web/2024-04-01/domains/method_delete.go new file mode 100644 index 00000000000..6d7df4dfe6c --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_delete.go @@ -0,0 +1,77 @@ +package domains + +import ( + "context" + "fmt" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceHardDeleteDomain *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceHardDeleteDomain != nil { + out.Append("forceHardDeleteDomain", fmt.Sprintf("%v", *o.ForceHardDeleteDomain)) + } + return &out +} + +// Delete ... +func (c DomainsClient) Delete(ctx context.Context, id DomainId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_deleteownershipidentifier.go b/resource-manager/web/2024-04-01/domains/method_deleteownershipidentifier.go new file mode 100644 index 00000000000..d1367d2232d --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_deleteownershipidentifier.go @@ -0,0 +1,47 @@ +package domains + +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 DeleteOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteOwnershipIdentifier ... +func (c DomainsClient) DeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_get.go b/resource-manager/web/2024-04-01/domains/method_get.go new file mode 100644 index 00000000000..20619dde9a0 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_get.go @@ -0,0 +1,53 @@ +package domains + +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 *Domain +} + +// Get ... +func (c DomainsClient) Get(ctx context.Context, id DomainId) (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 + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_getcontrolcenterssorequest.go b/resource-manager/web/2024-04-01/domains/method_getcontrolcenterssorequest.go new file mode 100644 index 00000000000..97001bc7198 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_getcontrolcenterssorequest.go @@ -0,0 +1,55 @@ +package domains + +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 GetControlCenterSsoRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainControlCenterSsoRequest +} + +// GetControlCenterSsoRequest ... +func (c DomainsClient) GetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (result GetControlCenterSsoRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/generateSsoRequest", 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 + } + + var model DomainControlCenterSsoRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_getownershipidentifier.go b/resource-manager/web/2024-04-01/domains/method_getownershipidentifier.go new file mode 100644 index 00000000000..b40df756137 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_getownershipidentifier.go @@ -0,0 +1,53 @@ +package domains + +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 GetOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// GetOwnershipIdentifier ... +func (c DomainsClient) GetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetOwnershipIdentifierOperationResponse, 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 + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_list.go b/resource-manager/web/2024-04-01/domains/method_list.go new file mode 100644 index 00000000000..526910a6cc5 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_list.go @@ -0,0 +1,106 @@ +package domains + +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 *[]Domain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", 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 *[]Domain `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 DomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/domains/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/domains/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d65249dc0bb --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package domains + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c DomainsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", 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 *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DomainsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DomainOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_listownershipidentifiers.go b/resource-manager/web/2024-04-01/domains/method_listownershipidentifiers.go new file mode 100644 index 00000000000..7081d3bef77 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_listownershipidentifiers.go @@ -0,0 +1,105 @@ +package domains + +import ( + "context" + "fmt" + "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 ListOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListOwnershipIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListOwnershipIdentifiers ... +func (c DomainsClient) ListOwnershipIdentifiers(ctx context.Context, id DomainId) (result ListOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListOwnershipIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]DomainOwnershipIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOwnershipIdentifiersComplete retrieves all the results into a single object +func (c DomainsClient) ListOwnershipIdentifiersComplete(ctx context.Context, id DomainId) (ListOwnershipIdentifiersCompleteResult, error) { + return c.ListOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, DomainOwnershipIdentifierOperationPredicate{}) +} + +// ListOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id DomainId, predicate DomainOwnershipIdentifierOperationPredicate) (result ListOwnershipIdentifiersCompleteResult, err error) { + items := make([]DomainOwnershipIdentifier, 0) + + resp, err := c.ListOwnershipIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_listrecommendations.go b/resource-manager/web/2024-04-01/domains/method_listrecommendations.go new file mode 100644 index 00000000000..e59b7c9f97c --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_listrecommendations.go @@ -0,0 +1,106 @@ +package domains + +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 ListRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NameIdentifier +} + +type ListRecommendationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []NameIdentifier +} + +type ListRecommendationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendations ... +func (c DomainsClient) ListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (result ListRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListRecommendationsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/listDomainRecommendations", 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 *[]NameIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendationsComplete retrieves all the results into a single object +func (c DomainsClient) ListRecommendationsComplete(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (ListRecommendationsCompleteResult, error) { + return c.ListRecommendationsCompleteMatchingPredicate(ctx, id, input, NameIdentifierOperationPredicate{}) +} + +// ListRecommendationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListRecommendationsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters, predicate NameIdentifierOperationPredicate) (result ListRecommendationsCompleteResult, err error) { + items := make([]NameIdentifier, 0) + + resp, err := c.ListRecommendations(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListRecommendationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_renew.go b/resource-manager/web/2024-04-01/domains/method_renew.go new file mode 100644 index 00000000000..e3a9b6abefd --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_renew.go @@ -0,0 +1,49 @@ +package domains + +import ( + "context" + "fmt" + "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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c DomainsClient) Renew(ctx context.Context, id DomainId) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_transferout.go b/resource-manager/web/2024-04-01/domains/method_transferout.go new file mode 100644 index 00000000000..463bfd22489 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_transferout.go @@ -0,0 +1,54 @@ +package domains + +import ( + "context" + "fmt" + "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 TransferOutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// TransferOut ... +func (c DomainsClient) TransferOut(ctx context.Context, id DomainId) (result TransferOutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/transferOut", 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 + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_update.go b/resource-manager/web/2024-04-01/domains/method_update.go new file mode 100644 index 00000000000..08ef3fbeef2 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_update.go @@ -0,0 +1,58 @@ +package domains + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Update ... +func (c DomainsClient) Update(ctx context.Context, id DomainId, input DomainPatchResource) (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 + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/method_updateownershipidentifier.go b/resource-manager/web/2024-04-01/domains/method_updateownershipidentifier.go new file mode 100644 index 00000000000..0ac28164a96 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/method_updateownershipidentifier.go @@ -0,0 +1,57 @@ +package domains + +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 UpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// UpdateOwnershipIdentifier ... +func (c DomainsClient) UpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result UpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/domains/model_address.go b/resource-manager/web/2024-04-01/domains/model_address.go new file mode 100644 index 00000000000..7d9d06d5e19 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_address.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Address struct { + Address1 string `json:"address1"` + Address2 *string `json:"address2,omitempty"` + City string `json:"city"` + Country string `json:"country"` + PostalCode string `json:"postalCode"` + State string `json:"state"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_contact.go b/resource-manager/web/2024-04-01/domains/model_contact.go new file mode 100644 index 00000000000..742a9691f02 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_contact.go @@ -0,0 +1,16 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Contact struct { + AddressMailing *Address `json:"addressMailing,omitempty"` + Email string `json:"email"` + Fax *string `json:"fax,omitempty"` + JobTitle *string `json:"jobTitle,omitempty"` + NameFirst string `json:"nameFirst"` + NameLast string `json:"nameLast"` + NameMiddle *string `json:"nameMiddle,omitempty"` + Organization *string `json:"organization,omitempty"` + Phone string `json:"phone"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domain.go b/resource-manager/web/2024-04-01/domains/model_domain.go new file mode 100644 index 00000000000..2befd74efa0 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domain.go @@ -0,0 +1,14 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Domain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DomainProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainavailabilitycheckresult.go b/resource-manager/web/2024-04-01/domains/model_domainavailabilitycheckresult.go new file mode 100644 index 00000000000..5e189d049c2 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainavailabilitycheckresult.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainAvailabilityCheckResult struct { + Available *bool `json:"available,omitempty"` + DomainType *DomainType `json:"domainType,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domaincontrolcenterssorequest.go b/resource-manager/web/2024-04-01/domains/model_domaincontrolcenterssorequest.go new file mode 100644 index 00000000000..cddf04a4702 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domaincontrolcenterssorequest.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainControlCenterSsoRequest struct { + PostParameterKey *string `json:"postParameterKey,omitempty"` + PostParameterValue *string `json:"postParameterValue,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainownershipidentifier.go b/resource-manager/web/2024-04-01/domains/model_domainownershipidentifier.go new file mode 100644 index 00000000000..b5ef7bbb733 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainownershipidentifier.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainOwnershipIdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainownershipidentifierproperties.go b/resource-manager/web/2024-04-01/domains/model_domainownershipidentifierproperties.go new file mode 100644 index 00000000000..64cd1600998 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainownershipidentifierproperties.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifierProperties struct { + OwnershipId *string `json:"ownershipId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainpatchresource.go b/resource-manager/web/2024-04-01/domains/model_domainpatchresource.go new file mode 100644 index 00000000000..3a744cc4328 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainpatchresource.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainpatchresourceproperties.go b/resource-manager/web/2024-04-01/domains/model_domainpatchresourceproperties.go new file mode 100644 index 00000000000..aaec61895f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainpatchresourceproperties.go @@ -0,0 +1,69 @@ +package domains + +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 DomainPatchResourceProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainPatchResourceProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainproperties.go b/resource-manager/web/2024-04-01/domains/model_domainproperties.go new file mode 100644 index 00000000000..860ae366326 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainproperties.go @@ -0,0 +1,69 @@ +package domains + +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 DomainProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainpurchaseconsent.go b/resource-manager/web/2024-04-01/domains/model_domainpurchaseconsent.go new file mode 100644 index 00000000000..afc6cdb7d25 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainpurchaseconsent.go @@ -0,0 +1,28 @@ +package domains + +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 DomainPurchaseConsent struct { + AgreedAt *string `json:"agreedAt,omitempty"` + AgreedBy *string `json:"agreedBy,omitempty"` + AgreementKeys *[]string `json:"agreementKeys,omitempty"` +} + +func (o *DomainPurchaseConsent) GetAgreedAtAsTime() (*time.Time, error) { + if o.AgreedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgreedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPurchaseConsent) SetAgreedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgreedAt = &formatted +} diff --git a/resource-manager/web/2024-04-01/domains/model_domainrecommendationsearchparameters.go b/resource-manager/web/2024-04-01/domains/model_domainrecommendationsearchparameters.go new file mode 100644 index 00000000000..161e93dc3aa --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_domainrecommendationsearchparameters.go @@ -0,0 +1,9 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainRecommendationSearchParameters struct { + Keywords *string `json:"keywords,omitempty"` + MaxDomainRecommendations *int64 `json:"maxDomainRecommendations,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_hostname.go b/resource-manager/web/2024-04-01/domains/model_hostname.go new file mode 100644 index 00000000000..e81ea21cc80 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_hostname.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostName struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + Name *string `json:"name,omitempty"` + SiteNames *[]string `json:"siteNames,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/model_nameidentifier.go b/resource-manager/web/2024-04-01/domains/model_nameidentifier.go new file mode 100644 index 00000000000..8602a243966 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/model_nameidentifier.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/domains/predicates.go b/resource-manager/web/2024-04-01/domains/predicates.go new file mode 100644 index 00000000000..dcd7e69873b --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/predicates.go @@ -0,0 +1,78 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p DomainOperationPredicate) Matches(input Domain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DomainOwnershipIdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DomainOwnershipIdentifierOperationPredicate) Matches(input DomainOwnershipIdentifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type NameIdentifierOperationPredicate struct { + Name *string +} + +func (p NameIdentifierOperationPredicate) Matches(input NameIdentifier) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-04-01/domains/version.go b/resource-manager/web/2024-04-01/domains/version.go new file mode 100644 index 00000000000..59262c4a506 --- /dev/null +++ b/resource-manager/web/2024-04-01/domains/version.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/domains/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/global/README.md b/resource-manager/web/2024-04-01/global/README.md new file mode 100644 index 00000000000..de67f04b97e --- /dev/null +++ b/resource-manager/web/2024-04-01/global/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/global` Documentation + +The `global` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/global" +``` + + +### Client Initialization + +```go +client := global.NewGlobalClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GlobalClient.GetDeletedWebApp` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + +read, err := client.GetDeletedWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `GlobalClient.GetDeletedWebAppSnapshots` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + +read, err := client.GetDeletedWebAppSnapshots(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/global/client.go b/resource-manager/web/2024-04-01/global/client.go new file mode 100644 index 00000000000..d760ea36811 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/client.go @@ -0,0 +1,26 @@ +package global + +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 GlobalClient struct { + Client *resourcemanager.Client +} + +func NewGlobalClientWithBaseURI(sdkApi sdkEnv.Api) (*GlobalClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "global", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GlobalClient: %+v", err) + } + + return &GlobalClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/global/id_deletedsite.go b/resource-manager/web/2024-04-01/global/id_deletedsite.go new file mode 100644 index 00000000000..4591f6ffafa --- /dev/null +++ b/resource-manager/web/2024-04-01/global/id_deletedsite.go @@ -0,0 +1,121 @@ +package global + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DeletedSiteId{}) +} + +var _ resourceids.ResourceId = &DeletedSiteId{} + +// DeletedSiteId is a struct representing the Resource ID for a Deleted Site +type DeletedSiteId struct { + SubscriptionId string + DeletedSiteId string +} + +// NewDeletedSiteID returns a new DeletedSiteId struct +func NewDeletedSiteID(subscriptionId string, deletedSiteId string) DeletedSiteId { + return DeletedSiteId{ + SubscriptionId: subscriptionId, + DeletedSiteId: deletedSiteId, + } +} + +// ParseDeletedSiteID parses 'input' into a DeletedSiteId +func ParseDeletedSiteID(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeletedSiteIDInsensitively parses 'input' case-insensitively into a DeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseDeletedSiteIDInsensitively(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateDeletedSiteID checks that 'input' can be parsed as a Deleted Site ID +func ValidateDeletedSiteID(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 := ParseDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deleted Site ID +func (id DeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deleted Site ID +func (id DeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteId"), + } +} + +// String returns a human-readable description of this Deleted Site ID +func (id DeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/global/id_deletedsite_test.go b/resource-manager/web/2024-04-01/global/id_deletedsite_test.go new file mode 100644 index 00000000000..31318f3d772 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/id_deletedsite_test.go @@ -0,0 +1,237 @@ +package global + +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 = &DeletedSiteId{} + +func TestNewDeletedSiteID(t *testing.T) { + id := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + + 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.DeletedSiteId != "deletedSiteId" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteId") + } +} + +func TestFormatDeletedSiteID(t *testing.T) { + actual := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteID(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.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "dElEtEdSiTeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteIDInsensitively(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.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForDeletedSiteId(t *testing.T) { + segments := DeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeletedSiteId 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/web/2024-04-01/global/method_getdeletedwebapp.go b/resource-manager/web/2024-04-01/global/method_getdeletedwebapp.go new file mode 100644 index 00000000000..9daa1017f5c --- /dev/null +++ b/resource-manager/web/2024-04-01/global/method_getdeletedwebapp.go @@ -0,0 +1,53 @@ +package global + +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 GetDeletedWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebApp ... +func (c GlobalClient) GetDeletedWebApp(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppOperationResponse, 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 + } + + var model DeletedSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/global/method_getdeletedwebappsnapshots.go b/resource-manager/web/2024-04-01/global/method_getdeletedwebappsnapshots.go new file mode 100644 index 00000000000..e18e9e44a71 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/method_getdeletedwebappsnapshots.go @@ -0,0 +1,54 @@ +package global + +import ( + "context" + "fmt" + "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 GetDeletedWebAppSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +// GetDeletedWebAppSnapshots ... +func (c GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", 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 + } + + var model []Snapshot + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/global/model_deletedsite.go b/resource-manager/web/2024-04-01/global/model_deletedsite.go new file mode 100644 index 00000000000..99e49e47843 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/model_deletedsite.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/global/model_deletedsiteproperties.go b/resource-manager/web/2024-04-01/global/model_deletedsiteproperties.go new file mode 100644 index 00000000000..3c42017baf5 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/global/model_snapshot.go b/resource-manager/web/2024-04-01/global/model_snapshot.go new file mode 100644 index 00000000000..6bd24519f97 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/model_snapshot.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/global/model_snapshotproperties.go b/resource-manager/web/2024-04-01/global/model_snapshotproperties.go new file mode 100644 index 00000000000..bbae9a0171c --- /dev/null +++ b/resource-manager/web/2024-04-01/global/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/global/version.go b/resource-manager/web/2024-04-01/global/version.go new file mode 100644 index 00000000000..db675d3fcd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/global/version.go @@ -0,0 +1,10 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/global/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/README.md b/resource-manager/web/2024-04-01/kubeenvironments/README.md new file mode 100644 index 00000000000..8617220a219 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/kubeenvironments` Documentation + +The `kubeenvironments` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/kubeenvironments" +``` + + +### Client Initialization + +```go +client := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `KubeEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +payload := kubeenvironments.KubeEnvironment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +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: `KubeEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +payload := kubeenvironments.KubeEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/kubeenvironments/client.go b/resource-manager/web/2024-04-01/kubeenvironments/client.go new file mode 100644 index 00000000000..7bcf8670016 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/client.go @@ -0,0 +1,26 @@ +package kubeenvironments + +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 KubeEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewKubeEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*KubeEnvironmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "kubeenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KubeEnvironmentsClient: %+v", err) + } + + return &KubeEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/constants.go b/resource-manager/web/2024-04-01/kubeenvironments/constants.go new file mode 100644 index 00000000000..7aaae27eece --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/constants.go @@ -0,0 +1,157 @@ +package kubeenvironments + +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 FrontEndServiceType string + +const ( + FrontEndServiceTypeLoadBalancer FrontEndServiceType = "LoadBalancer" + FrontEndServiceTypeNodePort FrontEndServiceType = "NodePort" +) + +func PossibleValuesForFrontEndServiceType() []string { + return []string{ + string(FrontEndServiceTypeLoadBalancer), + string(FrontEndServiceTypeNodePort), + } +} + +func (s *FrontEndServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrontEndServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrontEndServiceType(input string) (*FrontEndServiceType, error) { + vals := map[string]FrontEndServiceType{ + "loadbalancer": FrontEndServiceTypeLoadBalancer, + "nodeport": FrontEndServiceTypeNodePort, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrontEndServiceType(input) + return &out, nil +} + +type KubeEnvironmentProvisioningState string + +const ( + KubeEnvironmentProvisioningStateCanceled KubeEnvironmentProvisioningState = "Canceled" + KubeEnvironmentProvisioningStateFailed KubeEnvironmentProvisioningState = "Failed" + KubeEnvironmentProvisioningStateInfrastructureSetupComplete KubeEnvironmentProvisioningState = "InfrastructureSetupComplete" + KubeEnvironmentProvisioningStateInfrastructureSetupInProgress KubeEnvironmentProvisioningState = "InfrastructureSetupInProgress" + KubeEnvironmentProvisioningStateInitializationInProgress KubeEnvironmentProvisioningState = "InitializationInProgress" + KubeEnvironmentProvisioningStateScheduledForDelete KubeEnvironmentProvisioningState = "ScheduledForDelete" + KubeEnvironmentProvisioningStateSucceeded KubeEnvironmentProvisioningState = "Succeeded" + KubeEnvironmentProvisioningStateUpgradeFailed KubeEnvironmentProvisioningState = "UpgradeFailed" + KubeEnvironmentProvisioningStateUpgradeRequested KubeEnvironmentProvisioningState = "UpgradeRequested" + KubeEnvironmentProvisioningStateWaiting KubeEnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForKubeEnvironmentProvisioningState() []string { + return []string{ + string(KubeEnvironmentProvisioningStateCanceled), + string(KubeEnvironmentProvisioningStateFailed), + string(KubeEnvironmentProvisioningStateInfrastructureSetupComplete), + string(KubeEnvironmentProvisioningStateInfrastructureSetupInProgress), + string(KubeEnvironmentProvisioningStateInitializationInProgress), + string(KubeEnvironmentProvisioningStateScheduledForDelete), + string(KubeEnvironmentProvisioningStateSucceeded), + string(KubeEnvironmentProvisioningStateUpgradeFailed), + string(KubeEnvironmentProvisioningStateUpgradeRequested), + string(KubeEnvironmentProvisioningStateWaiting), + } +} + +func (s *KubeEnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeEnvironmentProvisioningState(input string) (*KubeEnvironmentProvisioningState, error) { + vals := map[string]KubeEnvironmentProvisioningState{ + "canceled": KubeEnvironmentProvisioningStateCanceled, + "failed": KubeEnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": KubeEnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": KubeEnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": KubeEnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": KubeEnvironmentProvisioningStateScheduledForDelete, + "succeeded": KubeEnvironmentProvisioningStateSucceeded, + "upgradefailed": KubeEnvironmentProvisioningStateUpgradeFailed, + "upgraderequested": KubeEnvironmentProvisioningStateUpgradeRequested, + "waiting": KubeEnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeEnvironmentProvisioningState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeLocalNode StorageType = "LocalNode" + StorageTypeNetworkFileSystem StorageType = "NetworkFileSystem" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeLocalNode), + string(StorageTypeNetworkFileSystem), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "localnode": StorageTypeLocalNode, + "networkfilesystem": StorageTypeNetworkFileSystem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment.go b/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment.go new file mode 100644 index 00000000000..73c1a578e48 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment.go @@ -0,0 +1,130 @@ +package kubeenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&KubeEnvironmentId{}) +} + +var _ resourceids.ResourceId = &KubeEnvironmentId{} + +// KubeEnvironmentId is a struct representing the Resource ID for a Kube Environment +type KubeEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + KubeEnvironmentName string +} + +// NewKubeEnvironmentID returns a new KubeEnvironmentId struct +func NewKubeEnvironmentID(subscriptionId string, resourceGroupName string, kubeEnvironmentName string) KubeEnvironmentId { + return KubeEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubeEnvironmentName: kubeEnvironmentName, + } +} + +// ParseKubeEnvironmentID parses 'input' into a KubeEnvironmentId +func ParseKubeEnvironmentID(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKubeEnvironmentIDInsensitively parses 'input' case-insensitively into a KubeEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseKubeEnvironmentIDInsensitively(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KubeEnvironmentId) 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.KubeEnvironmentName, ok = input.Parsed["kubeEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubeEnvironmentName", input) + } + + return nil +} + +// ValidateKubeEnvironmentID checks that 'input' can be parsed as a Kube Environment ID +func ValidateKubeEnvironmentID(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 := ParseKubeEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Kube Environment ID +func (id KubeEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/kubeEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubeEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Kube Environment ID +func (id KubeEnvironmentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticKubeEnvironments", "kubeEnvironments", "kubeEnvironments"), + resourceids.UserSpecifiedSegment("kubeEnvironmentName", "kubeEnvironmentName"), + } +} + +// String returns a human-readable description of this Kube Environment ID +func (id KubeEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kube Environment Name: %q", id.KubeEnvironmentName), + } + return fmt.Sprintf("Kube Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment_test.go b/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment_test.go new file mode 100644 index 00000000000..e209728abab --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/id_kubeenvironment_test.go @@ -0,0 +1,282 @@ +package kubeenvironments + +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 = &KubeEnvironmentId{} + +func TestNewKubeEnvironmentID(t *testing.T) { + id := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + + 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.KubeEnvironmentName != "kubeEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'KubeEnvironmentName'", id.KubeEnvironmentName, "kubeEnvironmentName") + } +} + +func TestFormatKubeEnvironmentID(t *testing.T) { + actual := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKubeEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentID(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.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestParseKubeEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtNaMe", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubeEnvironmentName: "kUbEeNvIrOnMeNtNaMe", + }, + }, + { + // 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.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentIDInsensitively(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.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestSegmentsForKubeEnvironmentId(t *testing.T) { + segments := KubeEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KubeEnvironmentId 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/web/2024-04-01/kubeenvironments/method_createorupdate.go b/resource-manager/web/2024-04-01/kubeenvironments/method_createorupdate.go new file mode 100644 index 00000000000..e6af85b34b3 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package kubeenvironments + +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 + Model *KubeEnvironment +} + +// CreateOrUpdate ... +func (c KubeEnvironmentsClient) CreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (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 KubeEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) 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/web/2024-04-01/kubeenvironments/method_delete.go b/resource-manager/web/2024-04-01/kubeenvironments/method_delete.go new file mode 100644 index 00000000000..9a86ed36127 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_delete.go @@ -0,0 +1,71 @@ +package kubeenvironments + +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 KubeEnvironmentsClient) Delete(ctx context.Context, id KubeEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 KubeEnvironmentsClient) DeleteThenPoll(ctx context.Context, id KubeEnvironmentId) 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/web/2024-04-01/kubeenvironments/method_get.go b/resource-manager/web/2024-04-01/kubeenvironments/method_get.go new file mode 100644 index 00000000000..4dde6e8cfea --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_get.go @@ -0,0 +1,53 @@ +package kubeenvironments + +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 *KubeEnvironment +} + +// Get ... +func (c KubeEnvironmentsClient) Get(ctx context.Context, id KubeEnvironmentId) (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 + } + + var model KubeEnvironment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/kubeenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5b378fe3212 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package kubeenvironments + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c KubeEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", 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 *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubeEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/method_listbysubscription.go b/resource-manager/web/2024-04-01/kubeenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..a315f826e7c --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_listbysubscription.go @@ -0,0 +1,106 @@ +package kubeenvironments + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c KubeEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", 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 *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubeEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/method_update.go b/resource-manager/web/2024-04-01/kubeenvironments/method_update.go new file mode 100644 index 00000000000..7192afd41a4 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/method_update.go @@ -0,0 +1,58 @@ +package kubeenvironments + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Update ... +func (c KubeEnvironmentsClient) Update(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 + } + + var model KubeEnvironment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_applogsconfiguration.go b/resource-manager/web/2024-04-01/kubeenvironments/model_applogsconfiguration.go new file mode 100644 index 00000000000..1d001f4eb4b --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_applogsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppLogsConfiguration struct { + Destination *string `json:"destination,omitempty"` + LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_arcconfiguration.go b/resource-manager/web/2024-04-01/kubeenvironments/model_arcconfiguration.go new file mode 100644 index 00000000000..a3340b2ff85 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_arcconfiguration.go @@ -0,0 +1,14 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArcConfiguration struct { + ArtifactStorageAccessMode *string `json:"artifactStorageAccessMode,omitempty"` + ArtifactStorageClassName *string `json:"artifactStorageClassName,omitempty"` + ArtifactStorageMountPath *string `json:"artifactStorageMountPath,omitempty"` + ArtifactStorageNodeName *string `json:"artifactStorageNodeName,omitempty"` + ArtifactsStorageType *StorageType `json:"artifactsStorageType,omitempty"` + FrontEndServiceConfiguration *FrontEndConfiguration `json:"frontEndServiceConfiguration,omitempty"` + KubeConfig *string `json:"kubeConfig,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_containerappsconfiguration.go b/resource-manager/web/2024-04-01/kubeenvironments/model_containerappsconfiguration.go new file mode 100644 index 00000000000..8d72c14cee2 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_containerappsconfiguration.go @@ -0,0 +1,13 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppsConfiguration struct { + AppSubnetResourceId *string `json:"appSubnetResourceId,omitempty"` + ControlPlaneSubnetResourceId *string `json:"controlPlaneSubnetResourceId,omitempty"` + DaprAIInstrumentationKey *string `json:"daprAIInstrumentationKey,omitempty"` + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + PlatformReservedCidr *string `json:"platformReservedCidr,omitempty"` + PlatformReservedDnsIP *string `json:"platformReservedDnsIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_extendedlocation.go b/resource-manager/web/2024-04-01/kubeenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..616cec03daa --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// 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 *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_frontendconfiguration.go b/resource-manager/web/2024-04-01/kubeenvironments/model_frontendconfiguration.go new file mode 100644 index 00000000000..c19181a1257 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_frontendconfiguration.go @@ -0,0 +1,8 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontEndConfiguration struct { + Kind *FrontEndServiceType `json:"kind,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironment.go b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironment.go new file mode 100644 index 00000000000..d57722efdef --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironment.go @@ -0,0 +1,15 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironment struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresource.go b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresource.go new file mode 100644 index 00000000000..912ea3cb9c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go new file mode 100644 index 00000000000..49c9bfaabc1 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go @@ -0,0 +1,16 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResourceProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentproperties.go b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentproperties.go new file mode 100644 index 00000000000..c56c83c5220 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_kubeenvironmentproperties.go @@ -0,0 +1,17 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + EnvironmentType *string `json:"environmentType,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/model_loganalyticsconfiguration.go b/resource-manager/web/2024-04-01/kubeenvironments/model_loganalyticsconfiguration.go new file mode 100644 index 00000000000..0e361710361 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/model_loganalyticsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsConfiguration struct { + CustomerId *string `json:"customerId,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/kubeenvironments/predicates.go b/resource-manager/web/2024-04-01/kubeenvironments/predicates.go new file mode 100644 index 00000000000..cf25ede1f18 --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/predicates.go @@ -0,0 +1,37 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p KubeEnvironmentOperationPredicate) Matches(input KubeEnvironment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/kubeenvironments/version.go b/resource-manager/web/2024-04-01/kubeenvironments/version.go new file mode 100644 index 00000000000..ca32e11280a --- /dev/null +++ b/resource-manager/web/2024-04-01/kubeenvironments/version.go @@ -0,0 +1,10 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/kubeenvironments/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/provider/README.md b/resource-manager/web/2024-04-01/provider/README.md new file mode 100644 index 00000000000..03b214151ab --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/provider` Documentation + +The `provider` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/provider" +``` + + +### Client Initialization + +```go +client := provider.NewProviderClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProviderClient.GetAvailableStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetAvailableStacks(ctx, provider.DefaultGetAvailableStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksComplete(ctx, provider.DefaultGetAvailableStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetAvailableStacksOnPrem` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.GetAvailableStacksOnPrem(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksOnPremComplete(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetFunctionAppStacks(ctx, provider.DefaultGetFunctionAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksComplete(ctx, provider.DefaultGetFunctionAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationName") + +// alternatively `client.GetFunctionAppStacksForLocation(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksForLocationComplete(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetWebAppStacks(ctx, provider.DefaultGetWebAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksComplete(ctx, provider.DefaultGetWebAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationName") + +// alternatively `client.GetWebAppStacksForLocation(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksForLocationComplete(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/provider/client.go b/resource-manager/web/2024-04-01/provider/client.go new file mode 100644 index 00000000000..b982cfdab87 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/client.go @@ -0,0 +1,26 @@ +package provider + +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 ProviderClient struct { + Client *resourcemanager.Client +} + +func NewProviderClientWithBaseURI(sdkApi sdkEnv.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) + } + + return &ProviderClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/provider/constants.go b/resource-manager/web/2024-04-01/provider/constants.go new file mode 100644 index 00000000000..27444d5870f --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/constants.go @@ -0,0 +1,145 @@ +package provider + +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 ProviderOsTypeSelected string + +const ( + ProviderOsTypeSelectedAll ProviderOsTypeSelected = "All" + ProviderOsTypeSelectedLinux ProviderOsTypeSelected = "Linux" + ProviderOsTypeSelectedLinuxFunctions ProviderOsTypeSelected = "LinuxFunctions" + ProviderOsTypeSelectedWindows ProviderOsTypeSelected = "Windows" + ProviderOsTypeSelectedWindowsFunctions ProviderOsTypeSelected = "WindowsFunctions" +) + +func PossibleValuesForProviderOsTypeSelected() []string { + return []string{ + string(ProviderOsTypeSelectedAll), + string(ProviderOsTypeSelectedLinux), + string(ProviderOsTypeSelectedLinuxFunctions), + string(ProviderOsTypeSelectedWindows), + string(ProviderOsTypeSelectedWindowsFunctions), + } +} + +func (s *ProviderOsTypeSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderOsTypeSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderOsTypeSelected(input string) (*ProviderOsTypeSelected, error) { + vals := map[string]ProviderOsTypeSelected{ + "all": ProviderOsTypeSelectedAll, + "linux": ProviderOsTypeSelectedLinux, + "linuxfunctions": ProviderOsTypeSelectedLinuxFunctions, + "windows": ProviderOsTypeSelectedWindows, + "windowsfunctions": ProviderOsTypeSelectedWindowsFunctions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderOsTypeSelected(input) + return &out, nil +} + +type ProviderStackOsType string + +const ( + ProviderStackOsTypeAll ProviderStackOsType = "All" + ProviderStackOsTypeLinux ProviderStackOsType = "Linux" + ProviderStackOsTypeWindows ProviderStackOsType = "Windows" +) + +func PossibleValuesForProviderStackOsType() []string { + return []string{ + string(ProviderStackOsTypeAll), + string(ProviderStackOsTypeLinux), + string(ProviderStackOsTypeWindows), + } +} + +func (s *ProviderStackOsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderStackOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderStackOsType(input string) (*ProviderStackOsType, error) { + vals := map[string]ProviderStackOsType{ + "all": ProviderStackOsTypeAll, + "linux": ProviderStackOsTypeLinux, + "windows": ProviderStackOsTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderStackOsType(input) + return &out, nil +} + +type StackPreferredOs string + +const ( + StackPreferredOsLinux StackPreferredOs = "Linux" + StackPreferredOsWindows StackPreferredOs = "Windows" +) + +func PossibleValuesForStackPreferredOs() []string { + return []string{ + string(StackPreferredOsLinux), + string(StackPreferredOsWindows), + } +} + +func (s *StackPreferredOs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackPreferredOs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStackPreferredOs(input string) (*StackPreferredOs, error) { + vals := map[string]StackPreferredOs{ + "linux": StackPreferredOsLinux, + "windows": StackPreferredOsWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StackPreferredOs(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/provider/id_location.go b/resource-manager/web/2024-04-01/provider/id_location.go new file mode 100644 index 00000000000..73ea1c40a58 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/id_location.go @@ -0,0 +1,112 @@ +package provider + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(locationName string) LocationId { + return LocationId{ + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/provider/id_location_test.go b/resource-manager/web/2024-04-01/provider/id_location_test.go new file mode 100644 index 00000000000..e0391552ed6 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/id_location_test.go @@ -0,0 +1,192 @@ +package provider + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("locationName") + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("locationName").ID() + expected := "/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationName", + Expected: &LocationId{ + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationName", + Expected: &LocationId{ + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/web/2024-04-01/provider/method_getavailablestacks.go b/resource-manager/web/2024-04-01/provider/method_getavailablestacks.go new file mode 100644 index 00000000000..1572e58bd2a --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getavailablestacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "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 GetAvailableStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOperationOptions() GetAvailableStacksOperationOptions { + return GetAvailableStacksOperationOptions{} +} + +func (o GetAvailableStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +type GetAvailableStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAvailableStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAvailableStacks ... +func (c ProviderClient) GetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (result GetAvailableStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetAvailableStacksCustomPager{}, + Path: "/providers/Microsoft.Web/availableStacks", + } + + 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 *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksComplete(ctx context.Context, options GetAvailableStacksOperationOptions) (GetAvailableStacksCompleteResult, error) { + return c.GetAvailableStacksCompleteMatchingPredicate(ctx, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksCompleteMatchingPredicate(ctx context.Context, options GetAvailableStacksOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetAvailableStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/method_getavailablestacksonprem.go b/resource-manager/web/2024-04-01/provider/method_getavailablestacksonprem.go new file mode 100644 index 00000000000..20773813e76 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getavailablestacksonprem.go @@ -0,0 +1,135 @@ +package provider + +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 GetAvailableStacksOnPremOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksOnPremCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOnPremOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOnPremOperationOptions() GetAvailableStacksOnPremOperationOptions { + return GetAvailableStacksOnPremOperationOptions{} +} + +func (o GetAvailableStacksOnPremOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +type GetAvailableStacksOnPremCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAvailableStacksOnPremCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAvailableStacksOnPrem ... +func (c ProviderClient) GetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (result GetAvailableStacksOnPremOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetAvailableStacksOnPremCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/availableStacks", 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 *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksOnPremComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksOnPremComplete(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (GetAvailableStacksOnPremCompleteResult, error) { + return c.GetAvailableStacksOnPremCompleteMatchingPredicate(ctx, id, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksOnPremCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksOnPremCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksOnPremCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacksOnPrem(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetAvailableStacksOnPremCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/method_getfunctionappstacks.go b/resource-manager/web/2024-04-01/provider/method_getfunctionappstacks.go new file mode 100644 index 00000000000..a1846c17cd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getfunctionappstacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "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 GetFunctionAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksOperationOptions() GetFunctionAppStacksOperationOptions { + return GetFunctionAppStacksOperationOptions{} +} + +func (o GetFunctionAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetFunctionAppStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetFunctionAppStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetFunctionAppStacks ... +func (c ProviderClient) GetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (result GetFunctionAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetFunctionAppStacksCustomPager{}, + Path: "/providers/Microsoft.Web/functionAppStacks", + } + + 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 *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksComplete(ctx context.Context, options GetFunctionAppStacksOperationOptions) (GetFunctionAppStacksCompleteResult, error) { + return c.GetFunctionAppStacksCompleteMatchingPredicate(ctx, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksCompleteMatchingPredicate(ctx context.Context, options GetFunctionAppStacksOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetFunctionAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/method_getfunctionappstacksforlocation.go b/resource-manager/web/2024-04-01/provider/method_getfunctionappstacksforlocation.go new file mode 100644 index 00000000000..684a0b14882 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getfunctionappstacksforlocation.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "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 GetFunctionAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksForLocationOperationOptions() GetFunctionAppStacksForLocationOperationOptions { + return GetFunctionAppStacksForLocationOperationOptions{} +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetFunctionAppStacksForLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetFunctionAppStacksForLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetFunctionAppStacksForLocation ... +func (c ProviderClient) GetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (result GetFunctionAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetFunctionAppStacksForLocationCustomPager{}, + Path: fmt.Sprintf("%s/functionAppStacks", 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 *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (GetFunctionAppStacksForLocationCompleteResult, error) { + return c.GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksForLocationCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacksForLocation(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetFunctionAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/method_getwebappstacks.go b/resource-manager/web/2024-04-01/provider/method_getwebappstacks.go new file mode 100644 index 00000000000..3223aecd71b --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getwebappstacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "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 GetWebAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksOperationOptions() GetWebAppStacksOperationOptions { + return GetWebAppStacksOperationOptions{} +} + +func (o GetWebAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetWebAppStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetWebAppStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetWebAppStacks ... +func (c ProviderClient) GetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (result GetWebAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetWebAppStacksCustomPager{}, + Path: "/providers/Microsoft.Web/webAppStacks", + } + + 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 *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksComplete(ctx context.Context, options GetWebAppStacksOperationOptions) (GetWebAppStacksCompleteResult, error) { + return c.GetWebAppStacksCompleteMatchingPredicate(ctx, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksCompleteMatchingPredicate(ctx context.Context, options GetWebAppStacksOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetWebAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/method_getwebappstacksforlocation.go b/resource-manager/web/2024-04-01/provider/method_getwebappstacksforlocation.go new file mode 100644 index 00000000000..2dad249e986 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/method_getwebappstacksforlocation.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "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 GetWebAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksForLocationOperationOptions() GetWebAppStacksForLocationOperationOptions { + return GetWebAppStacksForLocationOperationOptions{} +} + +func (o GetWebAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetWebAppStacksForLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetWebAppStacksForLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetWebAppStacksForLocation ... +func (c ProviderClient) GetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (result GetWebAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetWebAppStacksForLocationCustomPager{}, + Path: fmt.Sprintf("%s/webAppStacks", 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 *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (GetWebAppStacksForLocationCompleteResult, error) { + return c.GetWebAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksForLocationCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacksForLocation(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetWebAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/provider/model_appinsightswebappstacksettings.go b/resource-manager/web/2024-04-01/provider/model_appinsightswebappstacksettings.go new file mode 100644 index 00000000000..33c98c5a840 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_appinsightswebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppInsightsWebAppStackSettings struct { + IsDefaultOff *bool `json:"isDefaultOff,omitempty"` + IsSupported *bool `json:"isSupported,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_applicationstack.go b/resource-manager/web/2024-04-01/provider/model_applicationstack.go new file mode 100644 index 00000000000..2f4a241919a --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_applicationstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStack struct { + Dependency *string `json:"dependency,omitempty"` + Display *string `json:"display,omitempty"` + Frameworks *[]ApplicationStack `json:"frameworks,omitempty"` + IsDeprecated *[]ApplicationStack `json:"isDeprecated,omitempty"` + MajorVersions *[]StackMajorVersion `json:"majorVersions,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_applicationstackresource.go b/resource-manager/web/2024-04-01/provider/model_applicationstackresource.go new file mode 100644 index 00000000000..6257ea657ae --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_applicationstackresource.go @@ -0,0 +1,12 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationStack `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappmajorversion.go b/resource-manager/web/2024-04-01/provider/model_functionappmajorversion.go new file mode 100644 index 00000000000..b256d10d2d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]FunctionAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappminorversion.go b/resource-manager/web/2024-04-01/provider/model_functionappminorversion.go new file mode 100644 index 00000000000..2fdcc030a72 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *FunctionAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappruntimes.go b/resource-manager/web/2024-04-01/provider/model_functionappruntimes.go new file mode 100644 index 00000000000..8c3b2a595f1 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappruntimes.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppRuntimes struct { + LinuxRuntimeSettings *FunctionAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsRuntimeSettings *FunctionAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappruntimesettings.go b/resource-manager/web/2024-04-01/provider/model_functionappruntimesettings.go new file mode 100644 index 00000000000..14b93765b39 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappruntimesettings.go @@ -0,0 +1,39 @@ +package provider + +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 FunctionAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + AppSettingsDictionary *map[string]string `json:"appSettingsDictionary,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *SiteConfigPropertiesDictionary `json:"siteConfigPropertiesDictionary,omitempty"` + SupportedFunctionsExtensionVersions *[]string `json:"supportedFunctionsExtensionVersions,omitempty"` +} + +func (o *FunctionAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *FunctionAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappstack.go b/resource-manager/web/2024-04-01/provider/model_functionappstack.go new file mode 100644 index 00000000000..e4237db1a8b --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_functionappstackproperties.go b/resource-manager/web/2024-04-01/provider/model_functionappstackproperties.go new file mode 100644 index 00000000000..fdc2ac67ad2 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_functionappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]FunctionAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_githubactionwebappstacksettings.go b/resource-manager/web/2024-04-01/provider/model_githubactionwebappstacksettings.go new file mode 100644 index 00000000000..e43a56abbf1 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_githubactionwebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionWebAppStackSettings struct { + IsSupported *bool `json:"isSupported,omitempty"` + SupportedVersion *string `json:"supportedVersion,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_linuxjavacontainersettings.go b/resource-manager/web/2024-04-01/provider/model_linuxjavacontainersettings.go new file mode 100644 index 00000000000..9f872d51929 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_linuxjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +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 LinuxJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + Java11Runtime *string `json:"java11Runtime,omitempty"` + Java8Runtime *string `json:"java8Runtime,omitempty"` +} + +func (o *LinuxJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *LinuxJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/provider/model_siteconfigpropertiesdictionary.go b/resource-manager/web/2024-04-01/provider/model_siteconfigpropertiesdictionary.go new file mode 100644 index 00000000000..a0f34e1f2c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_siteconfigpropertiesdictionary.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigPropertiesDictionary struct { + JavaVersion *string `json:"javaVersion,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_stackmajorversion.go b/resource-manager/web/2024-04-01/provider/model_stackmajorversion.go new file mode 100644 index 00000000000..3790b4a134a --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_stackmajorversion.go @@ -0,0 +1,17 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMajorVersion struct { + AppSettingsDictionary *map[string]interface{} `json:"appSettingsDictionary,omitempty"` + ApplicationInsights *bool `json:"applicationInsights,omitempty"` + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + MinorVersions *[]StackMinorVersion `json:"minorVersions,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *map[string]interface{} `json:"siteConfigPropertiesDictionary,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_stackminorversion.go b/resource-manager/web/2024-04-01/provider/model_stackminorversion.go new file mode 100644 index 00000000000..7cd0a233af1 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_stackminorversion.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMinorVersion struct { + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsRemoteDebuggingEnabled *bool `json:"isRemoteDebuggingEnabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappmajorversion.go b/resource-manager/web/2024-04-01/provider/model_webappmajorversion.go new file mode 100644 index 00000000000..14ddab92252 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]WebAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappminorversion.go b/resource-manager/web/2024-04-01/provider/model_webappminorversion.go new file mode 100644 index 00000000000..c38aae7508d --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *WebAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappruntimes.go b/resource-manager/web/2024-04-01/provider/model_webappruntimes.go new file mode 100644 index 00000000000..d5d1d7691d1 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappruntimes.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppRuntimes struct { + LinuxContainerSettings *LinuxJavaContainerSettings `json:"linuxContainerSettings,omitempty"` + LinuxRuntimeSettings *WebAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsContainerSettings *WindowsJavaContainerSettings `json:"windowsContainerSettings,omitempty"` + WindowsRuntimeSettings *WebAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappruntimesettings.go b/resource-manager/web/2024-04-01/provider/model_webappruntimesettings.go new file mode 100644 index 00000000000..f828522456d --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappruntimesettings.go @@ -0,0 +1,35 @@ +package provider + +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 WebAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} + +func (o *WebAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WebAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappstack.go b/resource-manager/web/2024-04-01/provider/model_webappstack.go new file mode 100644 index 00000000000..6d111339d6d --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_webappstackproperties.go b/resource-manager/web/2024-04-01/provider/model_webappstackproperties.go new file mode 100644 index 00000000000..a37e8588aae --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_webappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]WebAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/provider/model_windowsjavacontainersettings.go b/resource-manager/web/2024-04-01/provider/model_windowsjavacontainersettings.go new file mode 100644 index 00000000000..0bba076cec7 --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/model_windowsjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +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 WindowsJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` +} + +func (o *WindowsJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WindowsJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-04-01/provider/predicates.go b/resource-manager/web/2024-04-01/provider/predicates.go new file mode 100644 index 00000000000..152a0bd64bb --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/predicates.go @@ -0,0 +1,98 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApplicationStackResourceOperationPredicate) Matches(input ApplicationStackResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type FunctionAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p FunctionAppStackOperationPredicate) Matches(input FunctionAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.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 +} + +type WebAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WebAppStackOperationPredicate) Matches(input WebAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.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/web/2024-04-01/provider/version.go b/resource-manager/web/2024-04-01/provider/version.go new file mode 100644 index 00000000000..3c61fdc3bdb --- /dev/null +++ b/resource-manager/web/2024-04-01/provider/version.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/provider/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/recommendations/README.md b/resource-manager/web/2024-04-01/recommendations/README.md new file mode 100644 index 00000000000..79922250b0a --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/README.md @@ -0,0 +1,266 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/recommendations` Documentation + +The `recommendations` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/recommendations" +``` + + +### Client Initialization + +```go +client := recommendations.NewRecommendationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecommendationsClient.DisableAllForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.DisableAllForHostingEnvironment(ctx, id, recommendations.DefaultDisableAllForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableAllForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DisableAllForWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + +read, err := client.DisableRecommendationForHostingEnvironment(ctx, id, recommendations.DefaultDisableRecommendationForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSite` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + +read, err := client.DisableRecommendationForSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSubscription` + +```go +ctx := context.TODO() +id := recommendations.NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName") + +read, err := client.DisableRecommendationForSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + +read, err := client.GetRuleDetailsByHostingEnvironment(ctx, id, recommendations.DefaultGetRuleDetailsByHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByWebApp` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + +read, err := client.GetRuleDetailsByWebApp(ctx, id, recommendations.DefaultGetRuleDetailsByWebAppOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, recommendations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recommendations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListHistoryForHostingEnvironment(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListHistoryForWebApp(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForWebAppComplete(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListRecommendedRulesForHostingEnvironment(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListRecommendedRulesForWebApp(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForWebAppComplete(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFilters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ResetAllFilters(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ResetAllFiltersForHostingEnvironment(ctx, id, recommendations.DefaultResetAllFiltersForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ResetAllFiltersForWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/recommendations/client.go b/resource-manager/web/2024-04-01/recommendations/client.go new file mode 100644 index 00000000000..5c0b92661cf --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/client.go @@ -0,0 +1,26 @@ +package recommendations + +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 RecommendationsClient struct { + Client *resourcemanager.Client +} + +func NewRecommendationsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecommendationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "recommendations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecommendationsClient: %+v", err) + } + + return &RecommendationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/recommendations/constants.go b/resource-manager/web/2024-04-01/recommendations/constants.go new file mode 100644 index 00000000000..207c2a4c8a5 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/constants.go @@ -0,0 +1,151 @@ +package recommendations + +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 Channels string + +const ( + ChannelsAll Channels = "All" + ChannelsApi Channels = "Api" + ChannelsEmail Channels = "Email" + ChannelsNotification Channels = "Notification" + ChannelsWebhook Channels = "Webhook" +) + +func PossibleValuesForChannels() []string { + return []string{ + string(ChannelsAll), + string(ChannelsApi), + string(ChannelsEmail), + string(ChannelsNotification), + string(ChannelsWebhook), + } +} + +func (s *Channels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChannels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChannels(input string) (*Channels, error) { + vals := map[string]Channels{ + "all": ChannelsAll, + "api": ChannelsApi, + "email": ChannelsEmail, + "notification": ChannelsNotification, + "webhook": ChannelsWebhook, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Channels(input) + return &out, nil +} + +type NotificationLevel string + +const ( + NotificationLevelCritical NotificationLevel = "Critical" + NotificationLevelInformation NotificationLevel = "Information" + NotificationLevelNonUrgentSuggestion NotificationLevel = "NonUrgentSuggestion" + NotificationLevelWarning NotificationLevel = "Warning" +) + +func PossibleValuesForNotificationLevel() []string { + return []string{ + string(NotificationLevelCritical), + string(NotificationLevelInformation), + string(NotificationLevelNonUrgentSuggestion), + string(NotificationLevelWarning), + } +} + +func (s *NotificationLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNotificationLevel(input string) (*NotificationLevel, error) { + vals := map[string]NotificationLevel{ + "critical": NotificationLevelCritical, + "information": NotificationLevelInformation, + "nonurgentsuggestion": NotificationLevelNonUrgentSuggestion, + "warning": NotificationLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NotificationLevel(input) + return &out, nil +} + +type ResourceScopeType string + +const ( + ResourceScopeTypeServerFarm ResourceScopeType = "ServerFarm" + ResourceScopeTypeSubscription ResourceScopeType = "Subscription" + ResourceScopeTypeWebSite ResourceScopeType = "WebSite" +) + +func PossibleValuesForResourceScopeType() []string { + return []string{ + string(ResourceScopeTypeServerFarm), + string(ResourceScopeTypeSubscription), + string(ResourceScopeTypeWebSite), + } +} + +func (s *ResourceScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceScopeType(input string) (*ResourceScopeType, error) { + vals := map[string]ResourceScopeType{ + "serverfarm": ResourceScopeTypeServerFarm, + "subscription": ResourceScopeTypeSubscription, + "website": ResourceScopeTypeWebSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceScopeType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation.go b/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation.go new file mode 100644 index 00000000000..6c8bb19b20b --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentRecommendationId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentRecommendationId{} + +// HostingEnvironmentRecommendationId is a struct representing the Resource ID for a Hosting Environment Recommendation +type HostingEnvironmentRecommendationId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + RecommendationName string +} + +// NewHostingEnvironmentRecommendationID returns a new HostingEnvironmentRecommendationId struct +func NewHostingEnvironmentRecommendationID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, recommendationName string) HostingEnvironmentRecommendationId { + return HostingEnvironmentRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + RecommendationName: recommendationName, + } +} + +// ParseHostingEnvironmentRecommendationID parses 'input' into a HostingEnvironmentRecommendationId +func ParseHostingEnvironmentRecommendationID(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentRecommendationIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentRecommendationId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentRecommendationIDInsensitively(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentRecommendationId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateHostingEnvironmentRecommendationID checks that 'input' can be parsed as a Hosting Environment Recommendation ID +func ValidateHostingEnvironmentRecommendationID(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 := ParseHostingEnvironmentRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Hosting Environment Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation_test.go b/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation_test.go new file mode 100644 index 00000000000..89a2959452d --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_hostingenvironmentrecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +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 = &HostingEnvironmentRecommendationId{} + +func TestNewHostingEnvironmentRecommendationID(t *testing.T) { + id := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + + 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.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatHostingEnvironmentRecommendationID(t *testing.T) { + actual := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationID(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseHostingEnvironmentRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationIDInsensitively(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.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForHostingEnvironmentRecommendationId(t *testing.T) { + segments := HostingEnvironmentRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentRecommendationId 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/web/2024-04-01/recommendations/id_recommendation.go b/resource-manager/web/2024-04-01/recommendations/id_recommendation.go new file mode 100644 index 00000000000..b42bf6faa1d --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_recommendation.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RecommendationId{}) +} + +var _ resourceids.ResourceId = &RecommendationId{} + +// RecommendationId is a struct representing the Resource ID for a Recommendation +type RecommendationId struct { + SubscriptionId string + RecommendationName string +} + +// NewRecommendationID returns a new RecommendationId struct +func NewRecommendationID(subscriptionId string, recommendationName string) RecommendationId { + return RecommendationId{ + SubscriptionId: subscriptionId, + RecommendationName: recommendationName, + } +} + +// ParseRecommendationID parses 'input' into a RecommendationId +func ParseRecommendationID(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecommendationIDInsensitively parses 'input' case-insensitively into a RecommendationId +// note: this method should only be used for API response data and not user input +func ParseRecommendationIDInsensitively(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecommendationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateRecommendationID checks that 'input' can be parsed as a Recommendation ID +func ValidateRecommendationID(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 := ParseRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recommendation ID +func (id RecommendationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recommendation ID +func (id RecommendationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Recommendation ID +func (id RecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/recommendations/id_recommendation_test.go b/resource-manager/web/2024-04-01/recommendations/id_recommendation_test.go new file mode 100644 index 00000000000..a6c44f1f14c --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_recommendation_test.go @@ -0,0 +1,237 @@ +package recommendations + +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 = &RecommendationId{} + +func TestNewRecommendationID(t *testing.T) { + id := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName") + + 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.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatRecommendationID(t *testing.T) { + actual := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationID(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.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationIDInsensitively(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.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForRecommendationId(t *testing.T) { + segments := RecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecommendationId 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/web/2024-04-01/recommendations/id_siterecommendation.go b/resource-manager/web/2024-04-01/recommendations/id_siterecommendation.go new file mode 100644 index 00000000000..2876f7cd3e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_siterecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SiteRecommendationId{}) +} + +var _ resourceids.ResourceId = &SiteRecommendationId{} + +// SiteRecommendationId is a struct representing the Resource ID for a Site Recommendation +type SiteRecommendationId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + RecommendationName string +} + +// NewSiteRecommendationID returns a new SiteRecommendationId struct +func NewSiteRecommendationID(subscriptionId string, resourceGroupName string, siteName string, recommendationName string) SiteRecommendationId { + return SiteRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + RecommendationName: recommendationName, + } +} + +// ParseSiteRecommendationID parses 'input' into a SiteRecommendationId +func ParseSiteRecommendationID(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteRecommendationIDInsensitively parses 'input' case-insensitively into a SiteRecommendationId +// note: this method should only be used for API response data and not user input +func ParseSiteRecommendationIDInsensitively(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteRecommendationId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateSiteRecommendationID checks that 'input' can be parsed as a Site Recommendation ID +func ValidateSiteRecommendationID(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 := ParseSiteRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Recommendation ID +func (id SiteRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Recommendation ID +func (id SiteRecommendationId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Site Recommendation ID +func (id SiteRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Site Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/recommendations/id_siterecommendation_test.go b/resource-manager/web/2024-04-01/recommendations/id_siterecommendation_test.go new file mode 100644 index 00000000000..5bf28fb326c --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/id_siterecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +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 = &SiteRecommendationId{} + +func TestNewSiteRecommendationID(t *testing.T) { + id := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatSiteRecommendationID(t *testing.T) { + actual := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseSiteRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForSiteRecommendationId(t *testing.T) { + segments := SiteRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteRecommendationId 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/web/2024-04-01/recommendations/method_disableallforhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_disableallforhostingenvironment.go new file mode 100644 index 00000000000..3f1378ddbbc --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_disableallforhostingenvironment.go @@ -0,0 +1,77 @@ +package recommendations + +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 DisableAllForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableAllForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableAllForHostingEnvironmentOperationOptions() DisableAllForHostingEnvironmentOperationOptions { + return DisableAllForHostingEnvironmentOperationOptions{} +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableAllForHostingEnvironment ... +func (c RecommendationsClient) DisableAllForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (result DisableAllForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/recommendations/disable", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_disableallforwebapp.go b/resource-manager/web/2024-04-01/recommendations/method_disableallforwebapp.go new file mode 100644 index 00000000000..ce325151614 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_disableallforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +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 DisableAllForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableAllForWebApp ... +func (c RecommendationsClient) DisableAllForWebApp(ctx context.Context, id commonids.AppServiceId) (result DisableAllForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforhostingenvironment.go new file mode 100644 index 00000000000..452a1d24ac9 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforhostingenvironment.go @@ -0,0 +1,76 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableRecommendationForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableRecommendationForHostingEnvironmentOperationOptions() DisableRecommendationForHostingEnvironmentOperationOptions { + return DisableRecommendationForHostingEnvironmentOperationOptions{} +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableRecommendationForHostingEnvironment ... +func (c RecommendationsClient) DisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsite.go b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsite.go new file mode 100644 index 00000000000..da51644b3c1 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsite.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSite ... +func (c RecommendationsClient) DisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (result DisableRecommendationForSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsubscription.go b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsubscription.go new file mode 100644 index 00000000000..a3f4f94f085 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_disablerecommendationforsubscription.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSubscription ... +func (c RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (result DisableRecommendationForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbyhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbyhostingenvironment.go new file mode 100644 index 00000000000..0086ec07d1d --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbyhostingenvironment.go @@ -0,0 +1,87 @@ +package recommendations + +import ( + "context" + "fmt" + "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 GetRuleDetailsByHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByHostingEnvironmentOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByHostingEnvironmentOperationOptions() GetRuleDetailsByHostingEnvironmentOperationOptions { + return GetRuleDetailsByHostingEnvironmentOperationOptions{} +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByHostingEnvironment ... +func (c RecommendationsClient) GetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (result GetRuleDetailsByHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model RecommendationRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbywebapp.go b/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbywebapp.go new file mode 100644 index 00000000000..9d34652f182 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_getruledetailsbywebapp.go @@ -0,0 +1,87 @@ +package recommendations + +import ( + "context" + "fmt" + "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 GetRuleDetailsByWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByWebAppOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByWebAppOperationOptions() GetRuleDetailsByWebAppOperationOptions { + return GetRuleDetailsByWebAppOperationOptions{} +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByWebApp ... +func (c RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (result GetRuleDetailsByWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 + } + + var model RecommendationRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_list.go b/resource-manager/web/2024-04-01/recommendations/method_list.go new file mode 100644 index 00000000000..784389aa71e --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_list.go @@ -0,0 +1,139 @@ +package recommendations + +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 *[]Recommendation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RecommendationsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations", 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 *[]Recommendation `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 RecommendationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate RecommendationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/recommendations/method_listhistoryforhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_listhistoryforhostingenvironment.go new file mode 100644 index 00000000000..6b92d0e2bb0 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_listhistoryforhostingenvironment.go @@ -0,0 +1,139 @@ +package recommendations + +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 ListHistoryForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForHostingEnvironmentOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForHostingEnvironmentOperationOptions() ListHistoryForHostingEnvironmentOperationOptions { + return ListHistoryForHostingEnvironmentOperationOptions{} +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListHistoryForHostingEnvironmentCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHistoryForHostingEnvironmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHistoryForHostingEnvironment ... +func (c RecommendationsClient) ListHistoryForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListHistoryForHostingEnvironmentCustomPager{}, + Path: fmt.Sprintf("%s/recommendationHistory", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (ListHistoryForHostingEnvironmentCompleteResult, error) { + return c.ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForHostingEnvironment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHistoryForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_listhistoryforwebapp.go b/resource-manager/web/2024-04-01/recommendations/method_listhistoryforwebapp.go new file mode 100644 index 00000000000..9fe581ed380 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_listhistoryforwebapp.go @@ -0,0 +1,139 @@ +package recommendations + +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 ListHistoryForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForWebAppOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForWebAppOperationOptions() ListHistoryForWebAppOperationOptions { + return ListHistoryForWebAppOperationOptions{} +} + +func (o ListHistoryForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListHistoryForWebAppCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHistoryForWebAppCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHistoryForWebApp ... +func (c RecommendationsClient) ListHistoryForWebApp(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (result ListHistoryForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListHistoryForWebAppCustomPager{}, + Path: fmt.Sprintf("%s/recommendationHistory", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (ListHistoryForWebAppCompleteResult, error) { + return c.ListHistoryForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForWebApp(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHistoryForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforhostingenvironment.go new file mode 100644 index 00000000000..3d8956760e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforhostingenvironment.go @@ -0,0 +1,139 @@ +package recommendations + +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 ListRecommendedRulesForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForHostingEnvironmentOperationOptions() ListRecommendedRulesForHostingEnvironmentOperationOptions { + return ListRecommendedRulesForHostingEnvironmentOperationOptions{} +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListRecommendedRulesForHostingEnvironmentCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendedRulesForHostingEnvironmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendedRulesForHostingEnvironment ... +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListRecommendedRulesForHostingEnvironmentCustomPager{}, + Path: fmt.Sprintf("%s/recommendations", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (ListRecommendedRulesForHostingEnvironmentCompleteResult, error) { + return c.ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForHostingEnvironment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListRecommendedRulesForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforwebapp.go b/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforwebapp.go new file mode 100644 index 00000000000..f417cf7c61a --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_listrecommendedrulesforwebapp.go @@ -0,0 +1,139 @@ +package recommendations + +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 ListRecommendedRulesForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForWebAppOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForWebAppOperationOptions() ListRecommendedRulesForWebAppOperationOptions { + return ListRecommendedRulesForWebAppOperationOptions{} +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListRecommendedRulesForWebAppCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendedRulesForWebAppCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendedRulesForWebApp ... +func (c RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (result ListRecommendedRulesForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListRecommendedRulesForWebAppCustomPager{}, + Path: fmt.Sprintf("%s/recommendations", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (ListRecommendedRulesForWebAppCompleteResult, error) { + return c.ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForWebApp(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListRecommendedRulesForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_resetallfilters.go b/resource-manager/web/2024-04-01/recommendations/method_resetallfilters.go new file mode 100644 index 00000000000..9ca523a21a2 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_resetallfilters.go @@ -0,0 +1,48 @@ +package recommendations + +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 ResetAllFiltersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFilters ... +func (c RecommendationsClient) ResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (result ResetAllFiltersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforhostingenvironment.go b/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforhostingenvironment.go new file mode 100644 index 00000000000..c6d9e982291 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforhostingenvironment.go @@ -0,0 +1,77 @@ +package recommendations + +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 ResetAllFiltersForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ResetAllFiltersForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultResetAllFiltersForHostingEnvironmentOperationOptions() ResetAllFiltersForHostingEnvironmentOperationOptions { + return ResetAllFiltersForHostingEnvironmentOperationOptions{} +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// ResetAllFiltersForHostingEnvironment ... +func (c RecommendationsClient) ResetAllFiltersForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforwebapp.go b/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforwebapp.go new file mode 100644 index 00000000000..79dcbd7603a --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/method_resetallfiltersforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +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 ResetAllFiltersForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFiltersForWebApp ... +func (c RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, id commonids.AppServiceId) (result ResetAllFiltersForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/recommendations/model_recommendation.go b/resource-manager/web/2024-04-01/recommendations/model_recommendation.go new file mode 100644 index 00000000000..341907a80ad --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/model_recommendation.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Recommendation struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/recommendations/model_recommendationproperties.go b/resource-manager/web/2024-04-01/recommendations/model_recommendationproperties.go new file mode 100644 index 00000000000..af604189bbf --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/model_recommendationproperties.go @@ -0,0 +1,108 @@ +package recommendations + +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 RecommendationProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + CreationTime *string `json:"creationTime,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Enabled *int64 `json:"enabled,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + NextNotificationTime *string `json:"nextNotificationTime,omitempty"` + NotificationExpirationTime *string `json:"notificationExpirationTime,omitempty"` + NotifiedTime *string `json:"notifiedTime,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceScope *ResourceScopeType `json:"resourceScope,omitempty"` + RuleName *string `json:"ruleName,omitempty"` + Score *float64 `json:"score,omitempty"` + StartTime *string `json:"startTime,omitempty"` + States *[]string `json:"states,omitempty"` +} + +func (o *RecommendationProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RecommendationProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RecommendationProperties) GetNextNotificationTimeAsTime() (*time.Time, error) { + if o.NextNotificationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextNotificationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNextNotificationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextNotificationTime = &formatted +} + +func (o *RecommendationProperties) GetNotificationExpirationTimeAsTime() (*time.Time, error) { + if o.NotificationExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotificationExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotificationExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotificationExpirationTime = &formatted +} + +func (o *RecommendationProperties) GetNotifiedTimeAsTime() (*time.Time, error) { + if o.NotifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotifiedTime = &formatted +} + +func (o *RecommendationProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/recommendations/model_recommendationrule.go b/resource-manager/web/2024-04-01/recommendations/model_recommendationrule.go new file mode 100644 index 00000000000..48fdfd600fd --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/model_recommendationrule.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRule struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/recommendations/model_recommendationruleproperties.go b/resource-manager/web/2024-04-01/recommendations/model_recommendationruleproperties.go new file mode 100644 index 00000000000..0352c174d79 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/model_recommendationruleproperties.go @@ -0,0 +1,20 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRuleProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + RecommendationName *string `json:"recommendationName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/recommendations/predicates.go b/resource-manager/web/2024-04-01/recommendations/predicates.go new file mode 100644 index 00000000000..bb0901fe9f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/predicates.go @@ -0,0 +1,32 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RecommendationOperationPredicate) Matches(input Recommendation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/recommendations/version.go b/resource-manager/web/2024-04-01/recommendations/version.go new file mode 100644 index 00000000000..0946c462bb4 --- /dev/null +++ b/resource-manager/web/2024-04-01/recommendations/version.go @@ -0,0 +1,10 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recommendations/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/README.md b/resource-manager/web/2024-04-01/resourcehealthmetadata/README.md new file mode 100644 index 00000000000..d565a56eb63 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourcehealthmetadata` Documentation + +The `resourcehealthmetadata` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourcehealthmetadata" +``` + + +### Client Initialization + +```go +client := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetBySite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetBySiteSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `ResourceHealthMetadataClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBySite(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBySiteSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/client.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/client.go new file mode 100644 index 00000000000..8d0b22d4c33 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/client.go @@ -0,0 +1,26 @@ +package resourcehealthmetadata + +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 ResourceHealthMetadataClient struct { + Client *resourcemanager.Client +} + +func NewResourceHealthMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceHealthMetadataClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resourcehealthmetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceHealthMetadataClient: %+v", err) + } + + return &ResourceHealthMetadataClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot.go new file mode 100644 index 00000000000..ef1e7ddf14c --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot.go @@ -0,0 +1,139 @@ +package resourcehealthmetadata + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot_test.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot_test.go new file mode 100644 index 00000000000..1713ffbdc7d --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/id_slot_test.go @@ -0,0 +1,327 @@ +package resourcehealthmetadata + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2024-04-01/resourcehealthmetadata/method_getbysite.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_getbysite.go new file mode 100644 index 00000000000..0b5f4205ef8 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_getbysite.go @@ -0,0 +1,55 @@ +package resourcehealthmetadata + +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 GetBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySite ... +func (c ResourceHealthMetadataClient) GetBySite(ctx context.Context, id commonids.AppServiceId) (result GetBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/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 + } + + var model ResourceHealthMetadata + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/method_getbysiteslot.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_getbysiteslot.go new file mode 100644 index 00000000000..24365f1341a --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_getbysiteslot.go @@ -0,0 +1,54 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 GetBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySiteSlot ... +func (c ResourceHealthMetadataClient) GetBySiteSlot(ctx context.Context, id SlotId) (result GetBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/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 + } + + var model ResourceHealthMetadata + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/method_list.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_list.go new file mode 100644 index 00000000000..fc5ca6a83d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_list.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +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 *[]ResourceHealthMetadata +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ResourceHealthMetadataClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `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 ResourceHealthMetadataClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceHealthMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/resourcehealthmetadata/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbyresourcegroup.go new file mode 100644 index 00000000000..44f705f6ee9 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ResourceHealthMetadataClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceHealthMetadataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysite.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysite.go new file mode 100644 index 00000000000..8b3c47e6b0c --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysite.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +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 ListBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListBySiteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySiteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySite ... +func (c ResourceHealthMetadataClient) ListBySite(ctx context.Context, id commonids.AppServiceId) (result ListBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySiteCustomPager{}, + Path: fmt.Sprintf("%s/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteComplete(ctx context.Context, id commonids.AppServiceId) (ListBySiteCompleteResult, error) { + return c.ListBySiteCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySite(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysiteslot.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysiteslot.go new file mode 100644 index 00000000000..49e47b7379d --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/method_listbysiteslot.go @@ -0,0 +1,105 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 ListBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListBySiteSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySiteSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySiteSlot ... +func (c ResourceHealthMetadataClient) ListBySiteSlot(ctx context.Context, id SlotId) (result ListBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySiteSlotCustomPager{}, + Path: fmt.Sprintf("%s/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteSlotComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteSlotComplete(ctx context.Context, id SlotId) (ListBySiteSlotCompleteResult, error) { + return c.ListBySiteSlotCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteSlotCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySiteSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySiteSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadata.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadata.go new file mode 100644 index 00000000000..14d0fa99d6c --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadata.go @@ -0,0 +1,12 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadata struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceHealthMetadataProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go new file mode 100644 index 00000000000..a59e92db1ed --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go @@ -0,0 +1,9 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataProperties struct { + Category *string `json:"category,omitempty"` + SignalAvailability *bool `json:"signalAvailability,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourcehealthmetadata/predicates.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/predicates.go new file mode 100644 index 00000000000..5682d0611c2 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/predicates.go @@ -0,0 +1,32 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceHealthMetadataOperationPredicate) Matches(input ResourceHealthMetadata) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/resourcehealthmetadata/version.go b/resource-manager/web/2024-04-01/resourcehealthmetadata/version.go new file mode 100644 index 00000000000..c0fda33aa68 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourcehealthmetadata/version.go @@ -0,0 +1,10 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourcehealthmetadata/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/README.md b/resource-manager/web/2024-04-01/resourceproviders/README.md new file mode 100644 index 00000000000..ad5d700fbf1 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/README.md @@ -0,0 +1,372 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourceproviders` Documentation + +The `resourceproviders` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/resourceproviders" +``` + + +### Client Initialization + +```go +client := resourceproviders.NewResourceProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceProvidersClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.ResourceNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetPublishingUser` + +```go +ctx := context.TODO() + + +read, err := client.GetPublishingUser(ctx) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlName") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSubscriptionDeploymentLocations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetSubscriptionDeploymentLocations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetUsagesInLocationlist` + +```go +ctx := context.TODO() +id := resourceproviders.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.GetUsagesInLocationlist(ctx, id)` can be used to do batched pagination +items, err := client.GetUsagesInLocationlistComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListAseRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAseRegions(ctx, id)` can be used to do batched pagination +items, err := client.ListAseRegionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListBillingMeters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBillingMeters(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions())` can be used to do batched pagination +items, err := client.ListBillingMetersComplete(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListCustomHostNameSites` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListCustomHostNameSites(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions())` can be used to do batched pagination +items, err := client.ListCustomHostNameSitesComplete(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListGeoRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListGeoRegions(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions())` can be used to do batched pagination +items, err := client.ListGeoRegionsComplete(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListPremierAddOnOffers` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListPremierAddOnOffers(ctx, id)` can be used to do batched pagination +items, err := client.ListPremierAddOnOffersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSiteIdentifiersAssignedToHostName` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.NameIdentifier{ + // ... +} + + +// alternatively `client.ListSiteIdentifiersAssignedToHostName(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSiteIdentifiersAssignedToHostNameComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSkus` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSourceControls` + +```go +ctx := context.TODO() + + +// alternatively `client.ListSourceControls(ctx)` can be used to do batched pagination +items, err := client.ListSourceControlsComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.Move` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.Move(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdatePublishingUser` + +```go +ctx := context.TODO() + +payload := resourceproviders.User{ + // ... +} + + +read, err := client.UpdatePublishingUser(ctx, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlName") + +payload := resourceproviders.SourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.Validate` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.ValidateRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ValidateMove` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.ValidateMove(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.VerifyHostingEnvironmentVnet` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.VnetParameters{ + // ... +} + + +read, err := client.VerifyHostingEnvironmentVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/resourceproviders/client.go b/resource-manager/web/2024-04-01/resourceproviders/client.go new file mode 100644 index 00000000000..f5374bb3bc3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/client.go @@ -0,0 +1,26 @@ +package resourceproviders + +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 ResourceProvidersClient struct { + Client *resourcemanager.Client +} + +func NewResourceProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resourceproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceProvidersClient: %+v", err) + } + + return &ResourceProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/constants.go b/resource-manager/web/2024-04-01/resourceproviders/constants.go new file mode 100644 index 00000000000..3f211102eb2 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/constants.go @@ -0,0 +1,563 @@ +package resourceproviders + +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 AppServicePlanRestrictions string + +const ( + AppServicePlanRestrictionsBasic AppServicePlanRestrictions = "Basic" + AppServicePlanRestrictionsFree AppServicePlanRestrictions = "Free" + AppServicePlanRestrictionsNone AppServicePlanRestrictions = "None" + AppServicePlanRestrictionsPremium AppServicePlanRestrictions = "Premium" + AppServicePlanRestrictionsShared AppServicePlanRestrictions = "Shared" + AppServicePlanRestrictionsStandard AppServicePlanRestrictions = "Standard" +) + +func PossibleValuesForAppServicePlanRestrictions() []string { + return []string{ + string(AppServicePlanRestrictionsBasic), + string(AppServicePlanRestrictionsFree), + string(AppServicePlanRestrictionsNone), + string(AppServicePlanRestrictionsPremium), + string(AppServicePlanRestrictionsShared), + string(AppServicePlanRestrictionsStandard), + } +} + +func (s *AppServicePlanRestrictions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppServicePlanRestrictions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppServicePlanRestrictions(input string) (*AppServicePlanRestrictions, error) { + vals := map[string]AppServicePlanRestrictions{ + "basic": AppServicePlanRestrictionsBasic, + "free": AppServicePlanRestrictionsFree, + "none": AppServicePlanRestrictionsNone, + "premium": AppServicePlanRestrictionsPremium, + "shared": AppServicePlanRestrictionsShared, + "standard": AppServicePlanRestrictionsStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppServicePlanRestrictions(input) + return &out, nil +} + +type CheckNameResourceTypes string + +const ( + CheckNameResourceTypesHostingEnvironment CheckNameResourceTypes = "HostingEnvironment" + CheckNameResourceTypesMicrosoftPointWebHostingEnvironments CheckNameResourceTypes = "Microsoft.Web/hostingEnvironments" + CheckNameResourceTypesMicrosoftPointWebPublishingUsers CheckNameResourceTypes = "Microsoft.Web/publishingUsers" + CheckNameResourceTypesMicrosoftPointWebSites CheckNameResourceTypes = "Microsoft.Web/sites" + CheckNameResourceTypesMicrosoftPointWebSitesSlots CheckNameResourceTypes = "Microsoft.Web/sites/slots" + CheckNameResourceTypesPublishingUser CheckNameResourceTypes = "PublishingUser" + CheckNameResourceTypesSite CheckNameResourceTypes = "Site" + CheckNameResourceTypesSlot CheckNameResourceTypes = "Slot" +) + +func PossibleValuesForCheckNameResourceTypes() []string { + return []string{ + string(CheckNameResourceTypesHostingEnvironment), + string(CheckNameResourceTypesMicrosoftPointWebHostingEnvironments), + string(CheckNameResourceTypesMicrosoftPointWebPublishingUsers), + string(CheckNameResourceTypesMicrosoftPointWebSites), + string(CheckNameResourceTypesMicrosoftPointWebSitesSlots), + string(CheckNameResourceTypesPublishingUser), + string(CheckNameResourceTypesSite), + string(CheckNameResourceTypesSlot), + } +} + +func (s *CheckNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameResourceTypes(input string) (*CheckNameResourceTypes, error) { + vals := map[string]CheckNameResourceTypes{ + "hostingenvironment": CheckNameResourceTypesHostingEnvironment, + "microsoft.web/hostingenvironments": CheckNameResourceTypesMicrosoftPointWebHostingEnvironments, + "microsoft.web/publishingusers": CheckNameResourceTypesMicrosoftPointWebPublishingUsers, + "microsoft.web/sites": CheckNameResourceTypesMicrosoftPointWebSites, + "microsoft.web/sites/slots": CheckNameResourceTypesMicrosoftPointWebSitesSlots, + "publishinguser": CheckNameResourceTypesPublishingUser, + "site": CheckNameResourceTypesSite, + "slot": CheckNameResourceTypesSlot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameResourceTypes(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type InAvailabilityReasonType string + +const ( + InAvailabilityReasonTypeAlreadyExists InAvailabilityReasonType = "AlreadyExists" + InAvailabilityReasonTypeInvalid InAvailabilityReasonType = "Invalid" +) + +func PossibleValuesForInAvailabilityReasonType() []string { + return []string{ + string(InAvailabilityReasonTypeAlreadyExists), + string(InAvailabilityReasonTypeInvalid), + } +} + +func (s *InAvailabilityReasonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInAvailabilityReasonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInAvailabilityReasonType(input string) (*InAvailabilityReasonType, error) { + vals := map[string]InAvailabilityReasonType{ + "alreadyexists": InAvailabilityReasonTypeAlreadyExists, + "invalid": InAvailabilityReasonTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InAvailabilityReasonType(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNameDynamic SkuName = "Dynamic" + SkuNameElasticIsolated SkuName = "ElasticIsolated" + SkuNameElasticPremium SkuName = "ElasticPremium" + SkuNameFlexConsumption SkuName = "FlexConsumption" + SkuNameFree SkuName = "Free" + SkuNameIsolated SkuName = "Isolated" + SkuNameIsolatedVTwo SkuName = "IsolatedV2" + SkuNamePremium SkuName = "Premium" + SkuNamePremiumContainer SkuName = "PremiumContainer" + SkuNamePremiumVThree SkuName = "PremiumV3" + SkuNamePremiumVTwo SkuName = "PremiumV2" + SkuNameShared SkuName = "Shared" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameDynamic), + string(SkuNameElasticIsolated), + string(SkuNameElasticPremium), + string(SkuNameFlexConsumption), + string(SkuNameFree), + string(SkuNameIsolated), + string(SkuNameIsolatedVTwo), + string(SkuNamePremium), + string(SkuNamePremiumContainer), + string(SkuNamePremiumVThree), + string(SkuNamePremiumVTwo), + string(SkuNameShared), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "dynamic": SkuNameDynamic, + "elasticisolated": SkuNameElasticIsolated, + "elasticpremium": SkuNameElasticPremium, + "flexconsumption": SkuNameFlexConsumption, + "free": SkuNameFree, + "isolated": SkuNameIsolated, + "isolatedv2": SkuNameIsolatedVTwo, + "premium": SkuNamePremium, + "premiumcontainer": SkuNamePremiumContainer, + "premiumv3": SkuNamePremiumVThree, + "premiumv2": SkuNamePremiumVTwo, + "shared": SkuNameShared, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type ValidateResourceTypes string + +const ( + ValidateResourceTypesMicrosoftPointWebHostingEnvironments ValidateResourceTypes = "Microsoft.Web/hostingEnvironments" + ValidateResourceTypesServerFarm ValidateResourceTypes = "ServerFarm" + ValidateResourceTypesSite ValidateResourceTypes = "Site" +) + +func PossibleValuesForValidateResourceTypes() []string { + return []string{ + string(ValidateResourceTypesMicrosoftPointWebHostingEnvironments), + string(ValidateResourceTypesServerFarm), + string(ValidateResourceTypesSite), + } +} + +func (s *ValidateResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidateResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidateResourceTypes(input string) (*ValidateResourceTypes, error) { + vals := map[string]ValidateResourceTypes{ + "microsoft.web/hostingenvironments": ValidateResourceTypesMicrosoftPointWebHostingEnvironments, + "serverfarm": ValidateResourceTypesServerFarm, + "site": ValidateResourceTypesSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidateResourceTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation.go b/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation.go new file mode 100644 index 00000000000..93f55de2bf3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation.go @@ -0,0 +1,121 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(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 := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation_test.go b/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation_test.go new file mode 100644 index 00000000000..4d560e91917 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package resourceproviders + +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 = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId 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/web/2024-04-01/resourceproviders/id_sourcecontrol.go b/resource-manager/web/2024-04-01/resourceproviders/id_sourcecontrol.go new file mode 100644 index 00000000000..a78436e8801 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/id_sourcecontrol.go @@ -0,0 +1,112 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SourceControlId{}) +} + +var _ resourceids.ResourceId = &SourceControlId{} + +// SourceControlId is a struct representing the Resource ID for a Source Control +type SourceControlId struct { + SourceControlName string +} + +// NewSourceControlID returns a new SourceControlId struct +func NewSourceControlID(sourceControlName string) SourceControlId { + return SourceControlId{ + SourceControlName: sourceControlName, + } +} + +// ParseSourceControlID parses 'input' into a SourceControlId +func ParseSourceControlID(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSourceControlIDInsensitively parses 'input' case-insensitively into a SourceControlId +// note: this method should only be used for API response data and not user input +func ParseSourceControlIDInsensitively(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SourceControlId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SourceControlName, ok = input.Parsed["sourceControlName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sourceControlName", input) + } + + return nil +} + +// ValidateSourceControlID checks that 'input' can be parsed as a Source Control ID +func ValidateSourceControlID(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 := ParseSourceControlID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Source Control ID +func (id SourceControlId) ID() string { + fmtString := "/providers/Microsoft.Web/sourceControls/%s" + return fmt.Sprintf(fmtString, id.SourceControlName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Source Control ID +func (id SourceControlId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSourceControls", "sourceControls", "sourceControls"), + resourceids.UserSpecifiedSegment("sourceControlName", "sourceControlName"), + } +} + +// String returns a human-readable description of this Source Control ID +func (id SourceControlId) String() string { + components := []string{ + fmt.Sprintf("Source Control Name: %q", id.SourceControlName), + } + return fmt.Sprintf("Source Control (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/id_sourcecontrol_test.go b/resource-manager/web/2024-04-01/resourceproviders/id_sourcecontrol_test.go new file mode 100644 index 00000000000..a64983484b3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/id_sourcecontrol_test.go @@ -0,0 +1,192 @@ +package resourceproviders + +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 = &SourceControlId{} + +func TestNewSourceControlID(t *testing.T) { + id := NewSourceControlID("sourceControlName") + + if id.SourceControlName != "sourceControlName" { + t.Fatalf("Expected %q but got %q for Segment 'SourceControlName'", id.SourceControlName, "sourceControlName") + } +} + +func TestFormatSourceControlID(t *testing.T) { + actual := NewSourceControlID("sourceControlName").ID() + expected := "/providers/Microsoft.Web/sourceControls/sourceControlName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSourceControlID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName", + Expected: &SourceControlId{ + SourceControlName: "sourceControlName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlID(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.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestParseSourceControlIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName", + Expected: &SourceControlId{ + SourceControlName: "sourceControlName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlNaMe", + Expected: &SourceControlId{ + SourceControlName: "sOuRcEcOnTrOlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlIDInsensitively(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.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestSegmentsForSourceControlId(t *testing.T) { + segments := SourceControlId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SourceControlId 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/web/2024-04-01/resourceproviders/method_checknameavailability.go b/resource-manager/web/2024-04-01/resourceproviders/method_checknameavailability.go new file mode 100644 index 00000000000..8d708561b66 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_checknameavailability.go @@ -0,0 +1,59 @@ +package resourceproviders + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceNameAvailability +} + +// CheckNameAvailability ... +func (c ResourceProvidersClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/checknameavailability", 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 + } + + var model ResourceNameAvailability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_getpublishinguser.go b/resource-manager/web/2024-04-01/resourceproviders/method_getpublishinguser.go new file mode 100644 index 00000000000..e0529900390 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_getpublishinguser.go @@ -0,0 +1,53 @@ +package resourceproviders + +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 GetPublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// GetPublishingUser ... +func (c ResourceProvidersClient) GetPublishingUser(ctx context.Context) (result GetPublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + 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 + } + + var model User + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_getsourcecontrol.go b/resource-manager/web/2024-04-01/resourceproviders/method_getsourcecontrol.go new file mode 100644 index 00000000000..2684d63d83c --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_getsourcecontrol.go @@ -0,0 +1,53 @@ +package resourceproviders + +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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// GetSourceControl ... +func (c ResourceProvidersClient) GetSourceControl(ctx context.Context, id SourceControlId) (result GetSourceControlOperationResponse, 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 + } + + var model SourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_getsubscriptiondeploymentlocations.go b/resource-manager/web/2024-04-01/resourceproviders/method_getsubscriptiondeploymentlocations.go new file mode 100644 index 00000000000..3564d1ecad9 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_getsubscriptiondeploymentlocations.go @@ -0,0 +1,55 @@ +package resourceproviders + +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 GetSubscriptionDeploymentLocationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeploymentLocations +} + +// GetSubscriptionDeploymentLocations ... +func (c ResourceProvidersClient) GetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deploymentLocations", 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 + } + + var model DeploymentLocations + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_getusagesinlocationlist.go b/resource-manager/web/2024-04-01/resourceproviders/method_getusagesinlocationlist.go new file mode 100644 index 00000000000..34301f4dd5f --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_getusagesinlocationlist.go @@ -0,0 +1,105 @@ +package resourceproviders + +import ( + "context" + "fmt" + "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 GetUsagesInLocationlistOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type GetUsagesInLocationlistCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type GetUsagesInLocationlistCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUsagesInLocationlistCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUsagesInLocationlist ... +func (c ResourceProvidersClient) GetUsagesInLocationlist(ctx context.Context, id ProviderLocationId) (result GetUsagesInLocationlistOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUsagesInLocationlistCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUsagesInLocationlistComplete retrieves all the results into a single object +func (c ResourceProvidersClient) GetUsagesInLocationlistComplete(ctx context.Context, id ProviderLocationId) (GetUsagesInLocationlistCompleteResult, error) { + return c.GetUsagesInLocationlistCompleteMatchingPredicate(ctx, id, CsmUsageQuotaOperationPredicate{}) +} + +// GetUsagesInLocationlistCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) GetUsagesInLocationlistCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate CsmUsageQuotaOperationPredicate) (result GetUsagesInLocationlistCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.GetUsagesInLocationlist(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetUsagesInLocationlistCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listaseregions.go b/resource-manager/web/2024-04-01/resourceproviders/method_listaseregions.go new file mode 100644 index 00000000000..401237f0e41 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listaseregions.go @@ -0,0 +1,106 @@ +package resourceproviders + +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 ListAseRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AseRegion +} + +type ListAseRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []AseRegion +} + +type ListAseRegionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAseRegionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAseRegions ... +func (c ResourceProvidersClient) ListAseRegions(ctx context.Context, id commonids.SubscriptionId) (result ListAseRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAseRegionsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/aseRegions", 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 *[]AseRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAseRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListAseRegionsComplete(ctx context.Context, id commonids.SubscriptionId) (ListAseRegionsCompleteResult, error) { + return c.ListAseRegionsCompleteMatchingPredicate(ctx, id, AseRegionOperationPredicate{}) +} + +// ListAseRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListAseRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AseRegionOperationPredicate) (result ListAseRegionsCompleteResult, err error) { + items := make([]AseRegion, 0) + + resp, err := c.ListAseRegions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListAseRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listbillingmeters.go b/resource-manager/web/2024-04-01/resourceproviders/method_listbillingmeters.go new file mode 100644 index 00000000000..97f4b003c15 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listbillingmeters.go @@ -0,0 +1,139 @@ +package resourceproviders + +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 ListBillingMetersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingMeter +} + +type ListBillingMetersCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingMeter +} + +type ListBillingMetersOperationOptions struct { + BillingLocation *string + OsType *string +} + +func DefaultListBillingMetersOperationOptions() ListBillingMetersOperationOptions { + return ListBillingMetersOperationOptions{} +} + +func (o ListBillingMetersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.BillingLocation != nil { + out.Append("billingLocation", fmt.Sprintf("%v", *o.BillingLocation)) + } + if o.OsType != nil { + out.Append("osType", fmt.Sprintf("%v", *o.OsType)) + } + return &out +} + +type ListBillingMetersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBillingMetersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBillingMeters ... +func (c ResourceProvidersClient) ListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (result ListBillingMetersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBillingMetersCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/billingMeters", 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 *[]BillingMeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBillingMetersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListBillingMetersComplete(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (ListBillingMetersCompleteResult, error) { + return c.ListBillingMetersCompleteMatchingPredicate(ctx, id, options, BillingMeterOperationPredicate{}) +} + +// ListBillingMetersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListBillingMetersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions, predicate BillingMeterOperationPredicate) (result ListBillingMetersCompleteResult, err error) { + items := make([]BillingMeter, 0) + + resp, err := c.ListBillingMeters(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBillingMetersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listcustomhostnamesites.go b/resource-manager/web/2024-04-01/resourceproviders/method_listcustomhostnamesites.go new file mode 100644 index 00000000000..f3f451bdaf0 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listcustomhostnamesites.go @@ -0,0 +1,135 @@ +package resourceproviders + +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 ListCustomHostNameSitesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomHostnameSites +} + +type ListCustomHostNameSitesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomHostnameSites +} + +type ListCustomHostNameSitesOperationOptions struct { + Hostname *string +} + +func DefaultListCustomHostNameSitesOperationOptions() ListCustomHostNameSitesOperationOptions { + return ListCustomHostNameSitesOperationOptions{} +} + +func (o ListCustomHostNameSitesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Hostname != nil { + out.Append("hostname", fmt.Sprintf("%v", *o.Hostname)) + } + return &out +} + +type ListCustomHostNameSitesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomHostNameSitesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCustomHostNameSites ... +func (c ResourceProvidersClient) ListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (result ListCustomHostNameSitesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomHostNameSitesCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customhostnameSites", 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 *[]CustomHostnameSites `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCustomHostNameSitesComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListCustomHostNameSitesComplete(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (ListCustomHostNameSitesCompleteResult, error) { + return c.ListCustomHostNameSitesCompleteMatchingPredicate(ctx, id, options, CustomHostnameSitesOperationPredicate{}) +} + +// ListCustomHostNameSitesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListCustomHostNameSitesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions, predicate CustomHostnameSitesOperationPredicate) (result ListCustomHostNameSitesCompleteResult, err error) { + items := make([]CustomHostnameSites, 0) + + resp, err := c.ListCustomHostNameSites(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListCustomHostNameSitesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listgeoregions.go b/resource-manager/web/2024-04-01/resourceproviders/method_listgeoregions.go new file mode 100644 index 00000000000..e1022e689b7 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listgeoregions.go @@ -0,0 +1,147 @@ +package resourceproviders + +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 ListGeoRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GeoRegion +} + +type ListGeoRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []GeoRegion +} + +type ListGeoRegionsOperationOptions struct { + LinuxDynamicWorkersEnabled *bool + LinuxWorkersEnabled *bool + Sku *SkuName + XenonWorkersEnabled *bool +} + +func DefaultListGeoRegionsOperationOptions() ListGeoRegionsOperationOptions { + return ListGeoRegionsOperationOptions{} +} + +func (o ListGeoRegionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.LinuxDynamicWorkersEnabled != nil { + out.Append("linuxDynamicWorkersEnabled", fmt.Sprintf("%v", *o.LinuxDynamicWorkersEnabled)) + } + if o.LinuxWorkersEnabled != nil { + out.Append("linuxWorkersEnabled", fmt.Sprintf("%v", *o.LinuxWorkersEnabled)) + } + if o.Sku != nil { + out.Append("sku", fmt.Sprintf("%v", *o.Sku)) + } + if o.XenonWorkersEnabled != nil { + out.Append("xenonWorkersEnabled", fmt.Sprintf("%v", *o.XenonWorkersEnabled)) + } + return &out +} + +type ListGeoRegionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListGeoRegionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListGeoRegions ... +func (c ResourceProvidersClient) ListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (result ListGeoRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListGeoRegionsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/geoRegions", 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 *[]GeoRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListGeoRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListGeoRegionsComplete(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (ListGeoRegionsCompleteResult, error) { + return c.ListGeoRegionsCompleteMatchingPredicate(ctx, id, options, GeoRegionOperationPredicate{}) +} + +// ListGeoRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListGeoRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions, predicate GeoRegionOperationPredicate) (result ListGeoRegionsCompleteResult, err error) { + items := make([]GeoRegion, 0) + + resp, err := c.ListGeoRegions(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListGeoRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listpremieraddonoffers.go b/resource-manager/web/2024-04-01/resourceproviders/method_listpremieraddonoffers.go new file mode 100644 index 00000000000..330e4571b61 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listpremieraddonoffers.go @@ -0,0 +1,106 @@ +package resourceproviders + +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 ListPremierAddOnOffersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PremierAddOnOffer +} + +type ListPremierAddOnOffersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PremierAddOnOffer +} + +type ListPremierAddOnOffersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPremierAddOnOffersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPremierAddOnOffers ... +func (c ResourceProvidersClient) ListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (result ListPremierAddOnOffersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPremierAddOnOffersCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/premieraddonoffers", 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 *[]PremierAddOnOffer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPremierAddOnOffersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListPremierAddOnOffersComplete(ctx context.Context, id commonids.SubscriptionId) (ListPremierAddOnOffersCompleteResult, error) { + return c.ListPremierAddOnOffersCompleteMatchingPredicate(ctx, id, PremierAddOnOfferOperationPredicate{}) +} + +// ListPremierAddOnOffersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListPremierAddOnOffersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PremierAddOnOfferOperationPredicate) (result ListPremierAddOnOffersCompleteResult, err error) { + items := make([]PremierAddOnOffer, 0) + + resp, err := c.ListPremierAddOnOffers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListPremierAddOnOffersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go b/resource-manager/web/2024-04-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go new file mode 100644 index 00000000000..b759ab015d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go @@ -0,0 +1,106 @@ +package resourceproviders + +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 ListSiteIdentifiersAssignedToHostNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteIdentifiersAssignedToHostNameCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteIdentifiersAssignedToHostName ... +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteIdentifiersAssignedToHostNameCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/listSitesAssignedToHostName", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteIdentifiersAssignedToHostNameComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameComplete(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (ListSiteIdentifiersAssignedToHostNameCompleteResult, error) { + return c.ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx, id, input, IdentifierOperationPredicate{}) +} + +// ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier, predicate IdentifierOperationPredicate) (result ListSiteIdentifiersAssignedToHostNameCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListSiteIdentifiersAssignedToHostName(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteIdentifiersAssignedToHostNameCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listskus.go b/resource-manager/web/2024-04-01/resourceproviders/method_listskus.go new file mode 100644 index 00000000000..cffe2769c1b --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listskus.go @@ -0,0 +1,55 @@ +package resourceproviders + +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 ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuInfos +} + +// ListSkus ... +func (c ResourceProvidersClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/skus", 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 + } + + var model SkuInfos + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_listsourcecontrols.go b/resource-manager/web/2024-04-01/resourceproviders/method_listsourcecontrols.go new file mode 100644 index 00000000000..b06f0d3e624 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_listsourcecontrols.go @@ -0,0 +1,105 @@ +package resourceproviders + +import ( + "context" + "fmt" + "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 ListSourceControlsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SourceControl +} + +type ListSourceControlsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SourceControl +} + +type ListSourceControlsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSourceControlsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSourceControls ... +func (c ResourceProvidersClient) ListSourceControls(ctx context.Context) (result ListSourceControlsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSourceControlsCustomPager{}, + Path: "/providers/Microsoft.Web/sourceControls", + } + + 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 *[]SourceControl `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSourceControlsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSourceControlsComplete(ctx context.Context) (ListSourceControlsCompleteResult, error) { + return c.ListSourceControlsCompleteMatchingPredicate(ctx, SourceControlOperationPredicate{}) +} + +// ListSourceControlsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSourceControlsCompleteMatchingPredicate(ctx context.Context, predicate SourceControlOperationPredicate) (result ListSourceControlsCompleteResult, err error) { + items := make([]SourceControl, 0) + + resp, err := c.ListSourceControls(ctx) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSourceControlsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_move.go b/resource-manager/web/2024-04-01/resourceproviders/method_move.go new file mode 100644 index 00000000000..1d47ce748e7 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_move.go @@ -0,0 +1,52 @@ +package resourceproviders + +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 MoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Move ... +func (c ResourceProvidersClient) Move(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result MoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/moveResources", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_updatepublishinguser.go b/resource-manager/web/2024-04-01/resourceproviders/method_updatepublishinguser.go new file mode 100644 index 00000000000..e994b006317 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_updatepublishinguser.go @@ -0,0 +1,57 @@ +package resourceproviders + +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 UpdatePublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// UpdatePublishingUser ... +func (c ResourceProvidersClient) UpdatePublishingUser(ctx context.Context, input User) (result UpdatePublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + 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 + } + + var model User + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_updatesourcecontrol.go b/resource-manager/web/2024-04-01/resourceproviders/method_updatesourcecontrol.go new file mode 100644 index 00000000000..1d9f45f198e --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_updatesourcecontrol.go @@ -0,0 +1,57 @@ +package resourceproviders + +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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// UpdateSourceControl ... +func (c ResourceProvidersClient) UpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_validate.go b/resource-manager/web/2024-04-01/resourceproviders/method_validate.go new file mode 100644 index 00000000000..4db5e1bb83c --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_validate.go @@ -0,0 +1,59 @@ +package resourceproviders + +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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateResponse +} + +// Validate ... +func (c ResourceProvidersClient) Validate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/validate", 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 + } + + var model ValidateResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_validatemove.go b/resource-manager/web/2024-04-01/resourceproviders/method_validatemove.go new file mode 100644 index 00000000000..7df2e3df0eb --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_validatemove.go @@ -0,0 +1,52 @@ +package resourceproviders + +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 ValidateMoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateMove ... +func (c ResourceProvidersClient) ValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result ValidateMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateMoveResources", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/method_verifyhostingenvironmentvnet.go b/resource-manager/web/2024-04-01/resourceproviders/method_verifyhostingenvironmentvnet.go new file mode 100644 index 00000000000..733f7cd2e65 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/method_verifyhostingenvironmentvnet.go @@ -0,0 +1,59 @@ +package resourceproviders + +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 VerifyHostingEnvironmentVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetValidationFailureDetails +} + +// VerifyHostingEnvironmentVnet ... +func (c ResourceProvidersClient) VerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/verifyHostingEnvironmentVnet", 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 + } + + var model VnetValidationFailureDetails + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_appserviceenvironment.go b/resource-manager/web/2024-04-01/resourceproviders/model_appserviceenvironment.go new file mode 100644 index 00000000000..4c64f3befc2 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_aseregion.go b/resource-manager/web/2024-04-01/resourceproviders/model_aseregion.go new file mode 100644 index 00000000000..75229a008cc --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_aseregion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_aseregionproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_aseregionproperties.go new file mode 100644 index 00000000000..193d6e9cc24 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_aseregionproperties.go @@ -0,0 +1,13 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionProperties struct { + AvailableOS *[]string `json:"availableOS,omitempty"` + AvailableSku *[]string `json:"availableSku,omitempty"` + DedicatedHost *bool `json:"dedicatedHost,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Standard *bool `json:"standard,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfiguration.go b/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..44e592b0c22 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..d93b1c90db6 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_billingmeter.go b/resource-manager/web/2024-04-01/resourceproviders/model_billingmeter.go new file mode 100644 index 00000000000..5d22f02ed37 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_billingmeter.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeter struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingMeterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_billingmeterproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_billingmeterproperties.go new file mode 100644 index 00000000000..aae6e22c948 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_billingmeterproperties.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeterProperties struct { + BillingLocation *string `json:"billingLocation,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + MeterId *string `json:"meterId,omitempty"` + Multiplier *float64 `json:"multiplier,omitempty"` + OsType *string `json:"osType,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + ShortName *string `json:"shortName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_capability.go b/resource-manager/web/2024-04-01/resourceproviders/model_capability.go new file mode 100644 index 00000000000..85356855f60 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_capability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_csmmoveresourceenvelope.go b/resource-manager/web/2024-04-01/resourceproviders/model_csmmoveresourceenvelope.go new file mode 100644 index 00000000000..6e585fdc416 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_csmmoveresourceenvelope.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmMoveResourceEnvelope struct { + Resources *[]string `json:"resources,omitempty"` + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_csmusagequota.go b/resource-manager/web/2024-04-01/resourceproviders/model_csmusagequota.go new file mode 100644 index 00000000000..d3c613eb248 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_csmusagequota.go @@ -0,0 +1,30 @@ +package resourceproviders + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfiguration.go b/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..59f89a9a6b2 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..cac2d224e58 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateURL *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesites.go b/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesites.go new file mode 100644 index 00000000000..f967d7a3153 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesites.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSites struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameSitesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesitesproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesitesproperties.go new file mode 100644 index 00000000000..d7767777efa --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_customhostnamesitesproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSitesProperties struct { + CustomHostname *string `json:"customHostname,omitempty"` + Region *string `json:"region,omitempty"` + SiteResourceIds *[]Identifier `json:"siteResourceIds,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_deploymentlocations.go b/resource-manager/web/2024-04-01/resourceproviders/model_deploymentlocations.go new file mode 100644 index 00000000000..0cf632a9502 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_deploymentlocations.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentLocations struct { + HostingEnvironmentDeploymentInfos *[]HostingEnvironmentDeploymentInfo `json:"hostingEnvironmentDeploymentInfos,omitempty"` + HostingEnvironments *[]AppServiceEnvironment `json:"hostingEnvironments,omitempty"` + Locations *[]GeoRegion `json:"locations,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_georegion.go b/resource-manager/web/2024-04-01/resourceproviders/model_georegion.go new file mode 100644 index 00000000000..bc4c17360b5 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_georegion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GeoRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_georegionproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_georegionproperties.go new file mode 100644 index 00000000000..1511ccc9e28 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_georegionproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + OrgDomain *string `json:"orgDomain,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_globalcsmskudescription.go b/resource-manager/web/2024-04-01/resourceproviders/model_globalcsmskudescription.go new file mode 100644 index 00000000000..fee5a130039 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_globalcsmskudescription.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalCsmSkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *SkuCapacity `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go b/resource-manager/web/2024-04-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go new file mode 100644 index 00000000000..5cbdecfc3f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDeploymentInfo struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_identifier.go b/resource-manager/web/2024-04-01/resourceproviders/model_identifier.go new file mode 100644 index 00000000000..879aff521be --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_identifier.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_identifierproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_identifierproperties.go new file mode 100644 index 00000000000..5fee3a1ed5d --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_identifierproperties.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_localizablestring.go b/resource-manager/web/2024-04-01/resourceproviders/model_localizablestring.go new file mode 100644 index 00000000000..4ee07f00d95 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_localizablestring.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_nameidentifier.go b/resource-manager/web/2024-04-01/resourceproviders/model_nameidentifier.go new file mode 100644 index 00000000000..94caff8a110 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_namevaluepair.go b/resource-manager/web/2024-04-01/resourceproviders/model_namevaluepair.go new file mode 100644 index 00000000000..30d7a8f6546 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_namevaluepair.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonoffer.go b/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonoffer.go new file mode 100644 index 00000000000..8245c61bc6e --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonoffer.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOffer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnOfferProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonofferproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonofferproperties.go new file mode 100644 index 00000000000..4d6d6786360 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_premieraddonofferproperties.go @@ -0,0 +1,17 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOfferProperties struct { + LegalTermsURL *string `json:"legalTermsUrl,omitempty"` + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + PrivacyPolicyURL *string `json:"privacyPolicyUrl,omitempty"` + Product *string `json:"product,omitempty"` + PromoCodeRequired *bool `json:"promoCodeRequired,omitempty"` + Quota *int64 `json:"quota,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` + WebHostingPlanRestrictions *AppServicePlanRestrictions `json:"webHostingPlanRestrictions,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailability.go b/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailability.go new file mode 100644 index 00000000000..0a19de2fac8 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailability struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *InAvailabilityReasonType `json:"reason,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailabilityrequest.go b/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailabilityrequest.go new file mode 100644 index 00000000000..abefca1cda6 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_resourcenameavailabilityrequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailabilityRequest struct { + EnvironmentId *string `json:"environmentId,omitempty"` + IsFqdn *bool `json:"isFqdn,omitempty"` + Name string `json:"name"` + Type CheckNameResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_skucapacity.go b/resource-manager/web/2024-04-01/resourceproviders/model_skucapacity.go new file mode 100644 index 00000000000..9f5bcf3423d --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_skucapacity.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_skuinfos.go b/resource-manager/web/2024-04-01/resourceproviders/model_skuinfos.go new file mode 100644 index 00000000000..c0c36d86b52 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_skuinfos.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfos struct { + ResourceType *string `json:"resourceType,omitempty"` + Skus *[]GlobalCsmSkuDescription `json:"skus,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrol.go b/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrol.go new file mode 100644 index 00000000000..03ce9771a74 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrol.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrolproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrolproperties.go new file mode 100644 index 00000000000..012dfe7a3c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_sourcecontrolproperties.go @@ -0,0 +1,29 @@ +package resourceproviders + +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 SourceControlProperties struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Token *string `json:"token,omitempty"` + TokenSecret *string `json:"tokenSecret,omitempty"` +} + +func (o *SourceControlProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SourceControlProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_user.go b/resource-manager/web/2024-04-01/resourceproviders/model_user.go new file mode 100644 index 00000000000..adb8119b83f --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_user.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_userproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_userproperties.go new file mode 100644 index 00000000000..7ac82ad3b1f --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_userproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_validateproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_validateproperties.go new file mode 100644 index 00000000000..76c9b025d30 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_validateproperties.go @@ -0,0 +1,21 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateProperties struct { + AppServiceEnvironment *AppServiceEnvironment `json:"appServiceEnvironment,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + ContainerImagePlatform *string `json:"containerImagePlatform,omitempty"` + ContainerImageRepository *string `json:"containerImageRepository,omitempty"` + ContainerImageTag *string `json:"containerImageTag,omitempty"` + ContainerRegistryBaseURL *string `json:"containerRegistryBaseUrl,omitempty"` + ContainerRegistryPassword *string `json:"containerRegistryPassword,omitempty"` + ContainerRegistryUsername *string `json:"containerRegistryUsername,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + NeedLinuxWorkers *bool `json:"needLinuxWorkers,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SkuName *string `json:"skuName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_validaterequest.go b/resource-manager/web/2024-04-01/resourceproviders/model_validaterequest.go new file mode 100644 index 00000000000..c7dc8dc05f4 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_validaterequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateRequest struct { + Location string `json:"location"` + Name string `json:"name"` + Properties ValidateProperties `json:"properties"` + Type ValidateResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_validateresponse.go b/resource-manager/web/2024-04-01/resourceproviders/model_validateresponse.go new file mode 100644 index 00000000000..dbc96e23750 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_validateresponse.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponse struct { + Error *ValidateResponseError `json:"error,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_validateresponseerror.go b/resource-manager/web/2024-04-01/resourceproviders/model_validateresponseerror.go new file mode 100644 index 00000000000..8d4f8adf944 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_validateresponseerror.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponseError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_virtualnetworkprofile.go b/resource-manager/web/2024-04-01/resourceproviders/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..b6498b01aea --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetparameters.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetparameters.go new file mode 100644 index 00000000000..195de734cb3 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetparameters.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParameters struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetParametersProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetparametersproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetparametersproperties.go new file mode 100644 index 00000000000..86fff378387 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetparametersproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParametersProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetResourceGroup *string `json:"vnetResourceGroup,omitempty"` + VnetSubnetName *string `json:"vnetSubnetName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetails.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetails.go new file mode 100644 index 00000000000..c6f31ff5b83 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetails.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetails struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationFailureDetailsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go new file mode 100644 index 00000000000..edae58023cb --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetailsProperties struct { + Failed *bool `json:"failed,omitempty"` + FailedTests *[]VnetValidationTestFailure `json:"failedTests,omitempty"` + Message *string `json:"message,omitempty"` + Warnings *[]VnetValidationTestFailure `json:"warnings,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailure.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailure.go new file mode 100644 index 00000000000..2ecad9b35ca --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailure.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailure struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationTestFailureProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailureproperties.go b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailureproperties.go new file mode 100644 index 00000000000..68ba825c530 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/model_vnetvalidationtestfailureproperties.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailureProperties struct { + Details *string `json:"details,omitempty"` + TestName *string `json:"testName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/resourceproviders/predicates.go b/resource-manager/web/2024-04-01/resourceproviders/predicates.go new file mode 100644 index 00000000000..c633f44ef01 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/predicates.go @@ -0,0 +1,228 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AseRegionOperationPredicate) Matches(input AseRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type BillingMeterOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BillingMeterOperationPredicate) Matches(input BillingMeter) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type CustomHostnameSitesOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CustomHostnameSitesOperationPredicate) Matches(input CustomHostnameSites) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type GeoRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p GeoRegionOperationPredicate) Matches(input GeoRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PremierAddOnOfferOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PremierAddOnOfferOperationPredicate) Matches(input PremierAddOnOffer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SourceControlOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SourceControlOperationPredicate) Matches(input SourceControl) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/resourceproviders/version.go b/resource-manager/web/2024-04-01/resourceproviders/version.go new file mode 100644 index 00000000000..2c074594b31 --- /dev/null +++ b/resource-manager/web/2024-04-01/resourceproviders/version.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourceproviders/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/staticsites/README.md b/resource-manager/web/2024-04-01/staticsites/README.md new file mode 100644 index 00000000000..b32b76989ac --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/README.md @@ -0,0 +1,1300 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/staticsites` Documentation + +The `staticsites` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/staticsites" +``` + + +### Client Initialization + +```go +client := staticsites.NewStaticSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StaticSitesClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +payload := staticsites.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteBasicAuthPropertiesARMResource{ + // ... +} + + +read, err := client.CreateOrUpdateBasicAuth(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateUserRolesInvitationLink` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteUserInvitationRequestResource{ + // ... +} + + +read, err := client.CreateUserRolesInvitationLink(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.DeleteBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeleteDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.DeleteDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +if err := client.DeleteStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +if err := client.DeleteStaticSiteBuildThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +if err := client.DeleteStaticSiteCustomDomainThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + +read, err := client.DeleteStaticSiteUser(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +if err := client.DetachStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetBasicAuth(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.GetBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.GetBuildDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetBuildDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetBuildDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.GetDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.GetDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +read, err := client.GetLinkedBackend(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +read, err := client.GetLinkedBackendForBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackends` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetLinkedBackends(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendsForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetLinkedBackendsForBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsForBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.GetStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuilds` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetStaticSiteBuilds(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSiteBuildsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +read, err := client.GetStaticSiteCustomDomain(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSitesByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.GetStaticSitesByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSitesByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +read, err := client.GetUserProvidedFunctionAppForStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +read, err := client.GetUserProvidedFunctionAppForStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSite(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackendToBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendToBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `StaticSitesClient.ListBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListBasicAuth(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicAuthComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.ListStaticSiteBuildAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.ListStaticSiteBuildFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.ListStaticSiteBuildFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteBuildFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteConfiguredRoles` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteConfiguredRoles(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteCustomDomains` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListStaticSiteCustomDomains(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteCustomDomainsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListStaticSiteFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteSecrets` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteUsers` + +```go +ctx := context.TODO() +id := staticsites.NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName") + +// alternatively `client.ListStaticSiteUsers(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteUsersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.PreviewWorkflow` + +```go +ctx := context.TODO() +id := staticsites.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := staticsites.StaticSitesWorkflowPreviewRequest{ + // ... +} + + +read, err := client.PreviewWorkflow(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ResetStaticSiteApiKey` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteResetPropertiesARMResource{ + // ... +} + + +read, err := client.ResetStaticSiteApiKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +read, err := client.UnlinkBackend(ctx, id, staticsites.DefaultUnlinkBackendOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackendFromBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +read, err := client.UnlinkBackendFromBuild(ctx, id, staticsites.DefaultUnlinkBackendFromBuildOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSitePatchResource{ + // ... +} + + +read, err := client.UpdateStaticSite(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + +payload := staticsites.StaticSiteUserARMResource{ + // ... +} + + +read, err := client.UpdateStaticSiteUser(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendForBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateCustomDomainCanBeAddedToStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-04-01/staticsites/client.go b/resource-manager/web/2024-04-01/staticsites/client.go new file mode 100644 index 00000000000..1843789810a --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/client.go @@ -0,0 +1,26 @@ +package staticsites + +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 StaticSitesClient struct { + Client *resourcemanager.Client +} + +func NewStaticSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*StaticSitesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "staticsites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticSitesClient: %+v", err) + } + + return &StaticSitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/constants.go b/resource-manager/web/2024-04-01/staticsites/constants.go new file mode 100644 index 00000000000..dfdde973015 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/constants.go @@ -0,0 +1,251 @@ +package staticsites + +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 BuildStatus string + +const ( + BuildStatusDeleting BuildStatus = "Deleting" + BuildStatusDeploying BuildStatus = "Deploying" + BuildStatusDetached BuildStatus = "Detached" + BuildStatusFailed BuildStatus = "Failed" + BuildStatusReady BuildStatus = "Ready" + BuildStatusUploading BuildStatus = "Uploading" + BuildStatusWaitingForDeployment BuildStatus = "WaitingForDeployment" +) + +func PossibleValuesForBuildStatus() []string { + return []string{ + string(BuildStatusDeleting), + string(BuildStatusDeploying), + string(BuildStatusDetached), + string(BuildStatusFailed), + string(BuildStatusReady), + string(BuildStatusUploading), + string(BuildStatusWaitingForDeployment), + } +} + +func (s *BuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuildStatus(input string) (*BuildStatus, error) { + vals := map[string]BuildStatus{ + "deleting": BuildStatusDeleting, + "deploying": BuildStatusDeploying, + "detached": BuildStatusDetached, + "failed": BuildStatusFailed, + "ready": BuildStatusReady, + "uploading": BuildStatusUploading, + "waitingfordeployment": BuildStatusWaitingForDeployment, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuildStatus(input) + return &out, nil +} + +type CustomDomainStatus string + +const ( + CustomDomainStatusAdding CustomDomainStatus = "Adding" + CustomDomainStatusDeleting CustomDomainStatus = "Deleting" + CustomDomainStatusFailed CustomDomainStatus = "Failed" + CustomDomainStatusReady CustomDomainStatus = "Ready" + CustomDomainStatusRetrievingValidationToken CustomDomainStatus = "RetrievingValidationToken" + CustomDomainStatusUnhealthy CustomDomainStatus = "Unhealthy" + CustomDomainStatusValidating CustomDomainStatus = "Validating" +) + +func PossibleValuesForCustomDomainStatus() []string { + return []string{ + string(CustomDomainStatusAdding), + string(CustomDomainStatusDeleting), + string(CustomDomainStatusFailed), + string(CustomDomainStatusReady), + string(CustomDomainStatusRetrievingValidationToken), + string(CustomDomainStatusUnhealthy), + string(CustomDomainStatusValidating), + } +} + +func (s *CustomDomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDomainStatus(input string) (*CustomDomainStatus, error) { + vals := map[string]CustomDomainStatus{ + "adding": CustomDomainStatusAdding, + "deleting": CustomDomainStatusDeleting, + "failed": CustomDomainStatusFailed, + "ready": CustomDomainStatusReady, + "retrievingvalidationtoken": CustomDomainStatusRetrievingValidationToken, + "unhealthy": CustomDomainStatusUnhealthy, + "validating": CustomDomainStatusValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDomainStatus(input) + return &out, nil +} + +type EnterpriseGradeCdnStatus string + +const ( + EnterpriseGradeCdnStatusDisabled EnterpriseGradeCdnStatus = "Disabled" + EnterpriseGradeCdnStatusDisabling EnterpriseGradeCdnStatus = "Disabling" + EnterpriseGradeCdnStatusEnabled EnterpriseGradeCdnStatus = "Enabled" + EnterpriseGradeCdnStatusEnabling EnterpriseGradeCdnStatus = "Enabling" +) + +func PossibleValuesForEnterpriseGradeCdnStatus() []string { + return []string{ + string(EnterpriseGradeCdnStatusDisabled), + string(EnterpriseGradeCdnStatusDisabling), + string(EnterpriseGradeCdnStatusEnabled), + string(EnterpriseGradeCdnStatusEnabling), + } +} + +func (s *EnterpriseGradeCdnStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnterpriseGradeCdnStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnterpriseGradeCdnStatus(input string) (*EnterpriseGradeCdnStatus, error) { + vals := map[string]EnterpriseGradeCdnStatus{ + "disabled": EnterpriseGradeCdnStatusDisabled, + "disabling": EnterpriseGradeCdnStatusDisabling, + "enabled": EnterpriseGradeCdnStatusEnabled, + "enabling": EnterpriseGradeCdnStatusEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnterpriseGradeCdnStatus(input) + return &out, nil +} + +type StagingEnvironmentPolicy string + +const ( + StagingEnvironmentPolicyDisabled StagingEnvironmentPolicy = "Disabled" + StagingEnvironmentPolicyEnabled StagingEnvironmentPolicy = "Enabled" +) + +func PossibleValuesForStagingEnvironmentPolicy() []string { + return []string{ + string(StagingEnvironmentPolicyDisabled), + string(StagingEnvironmentPolicyEnabled), + } +} + +func (s *StagingEnvironmentPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStagingEnvironmentPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStagingEnvironmentPolicy(input string) (*StagingEnvironmentPolicy, error) { + vals := map[string]StagingEnvironmentPolicy{ + "disabled": StagingEnvironmentPolicyDisabled, + "enabled": StagingEnvironmentPolicyEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StagingEnvironmentPolicy(input) + return &out, nil +} + +type TriggerTypes string + +const ( + TriggerTypesHTTPTrigger TriggerTypes = "HttpTrigger" + TriggerTypesUnknown TriggerTypes = "Unknown" +) + +func PossibleValuesForTriggerTypes() []string { + return []string{ + string(TriggerTypesHTTPTrigger), + string(TriggerTypesUnknown), + } +} + +func (s *TriggerTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerTypes(input string) (*TriggerTypes, error) { + vals := map[string]TriggerTypes{ + "httptrigger": TriggerTypesHTTPTrigger, + "unknown": TriggerTypesUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_authprovider.go b/resource-manager/web/2024-04-01/staticsites/id_authprovider.go new file mode 100644 index 00000000000..73ad2ff2650 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_authprovider.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AuthProviderId{}) +} + +var _ resourceids.ResourceId = &AuthProviderId{} + +// AuthProviderId is a struct representing the Resource ID for a Auth Provider +type AuthProviderId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string +} + +// NewAuthProviderID returns a new AuthProviderId struct +func NewAuthProviderID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string) AuthProviderId { + return AuthProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + } +} + +// ParseAuthProviderID parses 'input' into a AuthProviderId +func ParseAuthProviderID(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthProviderIDInsensitively parses 'input' case-insensitively into a AuthProviderId +// note: this method should only be used for API response data and not user input +func ParseAuthProviderIDInsensitively(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthProviderId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + return nil +} + +// ValidateAuthProviderID checks that 'input' can be parsed as a Auth Provider ID +func ValidateAuthProviderID(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 := ParseAuthProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Auth Provider ID +func (id AuthProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Auth Provider ID +func (id AuthProviderId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderName"), + } +} + +// String returns a human-readable description of this Auth Provider ID +func (id AuthProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + } + return fmt.Sprintf("Auth Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_authprovider_test.go b/resource-manager/web/2024-04-01/staticsites/id_authprovider_test.go new file mode 100644 index 00000000000..8ea5e3431e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_authprovider_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &AuthProviderId{} + +func TestNewAuthProviderID(t *testing.T) { + id := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.AuthProviderName != "authProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderName") + } +} + +func TestFormatAuthProviderID(t *testing.T) { + actual := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestParseAuthProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + AuthProviderName: "aUtHpRoViDeRnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestSegmentsForAuthProviderId(t *testing.T) { + segments := AuthProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthProviderId 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/web/2024-04-01/staticsites/id_build.go b/resource-manager/web/2024-04-01/staticsites/id_build.go new file mode 100644 index 00000000000..9b2d3b3a03d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_build.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BuildId{}) +} + +var _ resourceids.ResourceId = &BuildId{} + +// BuildId is a struct representing the Resource ID for a Build +type BuildId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string +} + +// NewBuildID returns a new BuildId struct +func NewBuildID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string) BuildId { + return BuildId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + } +} + +// ParseBuildID parses 'input' into a BuildId +func ParseBuildID(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildIDInsensitively parses 'input' case-insensitively into a BuildId +// note: this method should only be used for API response data and not user input +func ParseBuildIDInsensitively(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + return nil +} + +// ValidateBuildID checks that 'input' can be parsed as a Build ID +func ValidateBuildID(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 := ParseBuildID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build ID +func (id BuildId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build ID +func (id BuildId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + } +} + +// String returns a human-readable description of this Build ID +func (id BuildId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + } + return fmt.Sprintf("Build (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_build_test.go b/resource-manager/web/2024-04-01/staticsites/id_build_test.go new file mode 100644 index 00000000000..9f08be01439 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_build_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &BuildId{} + +func TestNewBuildID(t *testing.T) { + id := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } +} + +func TestFormatBuildID(t *testing.T) { + actual := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestParseBuildIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestSegmentsForBuildId(t *testing.T) { + segments := BuildId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildId 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/web/2024-04-01/staticsites/id_builddatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/id_builddatabaseconnection.go new file mode 100644 index 00000000000..660071b7aab --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_builddatabaseconnection.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BuildDatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &BuildDatabaseConnectionId{} + +// BuildDatabaseConnectionId is a struct representing the Resource ID for a Build Database Connection +type BuildDatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + DatabaseConnectionName string +} + +// NewBuildDatabaseConnectionID returns a new BuildDatabaseConnectionId struct +func NewBuildDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, databaseConnectionName string) BuildDatabaseConnectionId { + return BuildDatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseBuildDatabaseConnectionID parses 'input' into a BuildDatabaseConnectionId +func ParseBuildDatabaseConnectionID(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a BuildDatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseBuildDatabaseConnectionIDInsensitively(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildDatabaseConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateBuildDatabaseConnectionID checks that 'input' can be parsed as a Build Database Connection ID +func ValidateBuildDatabaseConnectionID(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 := ParseBuildDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Database Connection ID +func (id BuildDatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Database Connection ID +func (id BuildDatabaseConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionName"), + } +} + +// String returns a human-readable description of this Build Database Connection ID +func (id BuildDatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Build Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_builddatabaseconnection_test.go b/resource-manager/web/2024-04-01/staticsites/id_builddatabaseconnection_test.go new file mode 100644 index 00000000000..68f9cc60dd9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_builddatabaseconnection_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildDatabaseConnectionId{} + +func TestNewBuildDatabaseConnectionID(t *testing.T) { + id := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.DatabaseConnectionName != "databaseConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionName") + } +} + +func TestFormatBuildDatabaseConnectionID(t *testing.T) { + actual := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseBuildDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForBuildDatabaseConnectionId(t *testing.T) { + segments := BuildDatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildDatabaseConnectionId 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/web/2024-04-01/staticsites/id_buildlinkedbackend.go b/resource-manager/web/2024-04-01/staticsites/id_buildlinkedbackend.go new file mode 100644 index 00000000000..42b3fe8e789 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_buildlinkedbackend.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BuildLinkedBackendId{}) +} + +var _ resourceids.ResourceId = &BuildLinkedBackendId{} + +// BuildLinkedBackendId is a struct representing the Resource ID for a Build Linked Backend +type BuildLinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + LinkedBackendName string +} + +// NewBuildLinkedBackendID returns a new BuildLinkedBackendId struct +func NewBuildLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, linkedBackendName string) BuildLinkedBackendId { + return BuildLinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseBuildLinkedBackendID parses 'input' into a BuildLinkedBackendId +func ParseBuildLinkedBackendID(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildLinkedBackendIDInsensitively parses 'input' case-insensitively into a BuildLinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseBuildLinkedBackendIDInsensitively(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildLinkedBackendId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateBuildLinkedBackendID checks that 'input' can be parsed as a Build Linked Backend ID +func ValidateBuildLinkedBackendID(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 := ParseBuildLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Linked Backend ID +func (id BuildLinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Linked Backend ID +func (id BuildLinkedBackendId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendName"), + } +} + +// String returns a human-readable description of this Build Linked Backend ID +func (id BuildLinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Build Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_buildlinkedbackend_test.go b/resource-manager/web/2024-04-01/staticsites/id_buildlinkedbackend_test.go new file mode 100644 index 00000000000..e7a2cb9e253 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_buildlinkedbackend_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildLinkedBackendId{} + +func TestNewBuildLinkedBackendID(t *testing.T) { + id := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.LinkedBackendName != "linkedBackendName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendName") + } +} + +func TestFormatBuildLinkedBackendID(t *testing.T) { + actual := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseBuildLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + LinkedBackendName: "lInKeDbAcKeNdNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForBuildLinkedBackendId(t *testing.T) { + segments := BuildLinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildLinkedBackendId 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/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp.go b/resource-manager/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp.go new file mode 100644 index 00000000000..23a557f57de --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BuildUserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &BuildUserProvidedFunctionAppId{} + +// BuildUserProvidedFunctionAppId is a struct representing the Resource ID for a Build User Provided Function App +type BuildUserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + UserProvidedFunctionAppName string +} + +// NewBuildUserProvidedFunctionAppID returns a new BuildUserProvidedFunctionAppId struct +func NewBuildUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, userProvidedFunctionAppName string) BuildUserProvidedFunctionAppId { + return BuildUserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseBuildUserProvidedFunctionAppID parses 'input' into a BuildUserProvidedFunctionAppId +func ParseBuildUserProvidedFunctionAppID(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a BuildUserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseBuildUserProvidedFunctionAppIDInsensitively(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildUserProvidedFunctionAppId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateBuildUserProvidedFunctionAppID checks that 'input' can be parsed as a Build User Provided Function App ID +func ValidateBuildUserProvidedFunctionAppID(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 := ParseBuildUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppName"), + } +} + +// String returns a human-readable description of this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("Build User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp_test.go b/resource-manager/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp_test.go new file mode 100644 index 00000000000..04e65c3a35b --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_builduserprovidedfunctionapp_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildUserProvidedFunctionAppId{} + +func TestNewBuildUserProvidedFunctionAppID(t *testing.T) { + id := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppName" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppName") + } +} + +func TestFormatBuildUserProvidedFunctionAppID(t *testing.T) { + actual := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseBuildUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForBuildUserProvidedFunctionAppId(t *testing.T) { + segments := BuildUserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildUserProvidedFunctionAppId 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/web/2024-04-01/staticsites/id_customdomain.go b/resource-manager/web/2024-04-01/staticsites/id_customdomain.go new file mode 100644 index 00000000000..52bb3f0abb2 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_customdomain.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, staticSiteName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(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 := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainName"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_customdomain_test.go b/resource-manager/web/2024-04-01/staticsites/id_customdomain_test.go new file mode 100644 index 00000000000..64add194b56 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_customdomain_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.CustomDomainName != "customDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainName") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + CustomDomainName: "cUsToMdOmAiNnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId 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/web/2024-04-01/staticsites/id_databaseconnection.go b/resource-manager/web/2024-04-01/staticsites/id_databaseconnection.go new file mode 100644 index 00000000000..0646be22614 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_databaseconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &DatabaseConnectionId{} + +// DatabaseConnectionId is a struct representing the Resource ID for a Database Connection +type DatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + DatabaseConnectionName string +} + +// NewDatabaseConnectionID returns a new DatabaseConnectionId struct +func NewDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, databaseConnectionName string) DatabaseConnectionId { + return DatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseDatabaseConnectionID parses 'input' into a DatabaseConnectionId +func ParseDatabaseConnectionID(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a DatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseDatabaseConnectionIDInsensitively(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateDatabaseConnectionID checks that 'input' can be parsed as a Database Connection ID +func ValidateDatabaseConnectionID(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 := ParseDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Connection ID +func (id DatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Connection ID +func (id DatabaseConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionName"), + } +} + +// String returns a human-readable description of this Database Connection ID +func (id DatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_databaseconnection_test.go b/resource-manager/web/2024-04-01/staticsites/id_databaseconnection_test.go new file mode 100644 index 00000000000..c91658ac616 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_databaseconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &DatabaseConnectionId{} + +func TestNewDatabaseConnectionID(t *testing.T) { + id := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.DatabaseConnectionName != "databaseConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionName") + } +} + +func TestFormatDatabaseConnectionID(t *testing.T) { + actual := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForDatabaseConnectionId(t *testing.T) { + segments := DatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseConnectionId 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/web/2024-04-01/staticsites/id_linkedbackend.go b/resource-manager/web/2024-04-01/staticsites/id_linkedbackend.go new file mode 100644 index 00000000000..2db02661f88 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_linkedbackend.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LinkedBackendId{}) +} + +var _ resourceids.ResourceId = &LinkedBackendId{} + +// LinkedBackendId is a struct representing the Resource ID for a Linked Backend +type LinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + LinkedBackendName string +} + +// NewLinkedBackendID returns a new LinkedBackendId struct +func NewLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, linkedBackendName string) LinkedBackendId { + return LinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseLinkedBackendID parses 'input' into a LinkedBackendId +func ParseLinkedBackendID(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkedBackendIDInsensitively parses 'input' case-insensitively into a LinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseLinkedBackendIDInsensitively(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkedBackendId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateLinkedBackendID checks that 'input' can be parsed as a Linked Backend ID +func ValidateLinkedBackendID(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 := ParseLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Linked Backend ID +func (id LinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Linked Backend ID +func (id LinkedBackendId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendName"), + } +} + +// String returns a human-readable description of this Linked Backend ID +func (id LinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_linkedbackend_test.go b/resource-manager/web/2024-04-01/staticsites/id_linkedbackend_test.go new file mode 100644 index 00000000000..bbbdc7a534f --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_linkedbackend_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &LinkedBackendId{} + +func TestNewLinkedBackendID(t *testing.T) { + id := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.LinkedBackendName != "linkedBackendName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendName") + } +} + +func TestFormatLinkedBackendID(t *testing.T) { + actual := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + LinkedBackendName: "lInKeDbAcKeNdNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForLinkedBackendId(t *testing.T) { + segments := LinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkedBackendId 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/web/2024-04-01/staticsites/id_providerlocation.go b/resource-manager/web/2024-04-01/staticsites/id_providerlocation.go new file mode 100644 index 00000000000..c53d10beaa5 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_providerlocation.go @@ -0,0 +1,121 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(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 := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_providerlocation_test.go b/resource-manager/web/2024-04-01/staticsites/id_providerlocation_test.go new file mode 100644 index 00000000000..e48b5f6c6d4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package staticsites + +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 = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId 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/web/2024-04-01/staticsites/id_staticsite.go b/resource-manager/web/2024-04-01/staticsites/id_staticsite.go new file mode 100644 index 00000000000..5b7df0899c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_staticsite.go @@ -0,0 +1,130 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&StaticSiteId{}) +} + +var _ resourceids.ResourceId = &StaticSiteId{} + +// StaticSiteId is a struct representing the Resource ID for a Static Site +type StaticSiteId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string +} + +// NewStaticSiteID returns a new StaticSiteId struct +func NewStaticSiteID(subscriptionId string, resourceGroupName string, staticSiteName string) StaticSiteId { + return StaticSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + } +} + +// ParseStaticSiteID parses 'input' into a StaticSiteId +func ParseStaticSiteID(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSiteIDInsensitively parses 'input' case-insensitively into a StaticSiteId +// note: this method should only be used for API response data and not user input +func ParseStaticSiteIDInsensitively(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSiteId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + return nil +} + +// ValidateStaticSiteID checks that 'input' can be parsed as a Static Site ID +func ValidateStaticSiteID(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 := ParseStaticSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site ID +func (id StaticSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site ID +func (id StaticSiteId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + } +} + +// String returns a human-readable description of this Static Site ID +func (id StaticSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + } + return fmt.Sprintf("Static Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_staticsite_test.go b/resource-manager/web/2024-04-01/staticsites/id_staticsite_test.go new file mode 100644 index 00000000000..429bdfeaed4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_staticsite_test.go @@ -0,0 +1,282 @@ +package staticsites + +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 = &StaticSiteId{} + +func TestNewStaticSiteID(t *testing.T) { + id := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } +} + +func TestFormatStaticSiteID(t *testing.T) { + actual := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestParseStaticSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestSegmentsForStaticSiteId(t *testing.T) { + segments := StaticSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSiteId 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/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection.go new file mode 100644 index 00000000000..8c4c4fd7cb9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&StaticSitePrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &StaticSitePrivateEndpointConnectionId{} + +// StaticSitePrivateEndpointConnectionId is a struct representing the Resource ID for a Static Site Private Endpoint Connection +type StaticSitePrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + PrivateEndpointConnectionName string +} + +// NewStaticSitePrivateEndpointConnectionID returns a new StaticSitePrivateEndpointConnectionId struct +func NewStaticSitePrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, privateEndpointConnectionName string) StaticSitePrivateEndpointConnectionId { + return StaticSitePrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseStaticSitePrivateEndpointConnectionID parses 'input' into a StaticSitePrivateEndpointConnectionId +func ParseStaticSitePrivateEndpointConnectionID(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSitePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a StaticSitePrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseStaticSitePrivateEndpointConnectionIDInsensitively(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSitePrivateEndpointConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateStaticSitePrivateEndpointConnectionID checks that 'input' can be parsed as a Static Site Private Endpoint Connection ID +func ValidateStaticSitePrivateEndpointConnectionID(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 := ParseStaticSitePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Static Site Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection_test.go b/resource-manager/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection_test.go new file mode 100644 index 00000000000..aef661aa34c --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_staticsiteprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &StaticSitePrivateEndpointConnectionId{} + +func TestNewStaticSitePrivateEndpointConnectionID(t *testing.T) { + id := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatStaticSitePrivateEndpointConnectionID(t *testing.T) { + actual := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSitePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseStaticSitePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForStaticSitePrivateEndpointConnectionId(t *testing.T) { + segments := StaticSitePrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSitePrivateEndpointConnectionId 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/web/2024-04-01/staticsites/id_user.go b/resource-manager/web/2024-04-01/staticsites/id_user.go new file mode 100644 index 00000000000..fe210ef0473 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_user.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&UserId{}) +} + +var _ resourceids.ResourceId = &UserId{} + +// UserId is a struct representing the Resource ID for a User +type UserId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string + UserName string +} + +// NewUserID returns a new UserId struct +func NewUserID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string, userName string) UserId { + return UserId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + UserName: userName, + } +} + +// ParseUserID parses 'input' into a UserId +func ParseUserID(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserIDInsensitively parses 'input' case-insensitively into a UserId +// note: this method should only be used for API response data and not user input +func ParseUserIDInsensitively(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + if id.UserName, ok = input.Parsed["userName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userName", input) + } + + return nil +} + +// ValidateUserID checks that 'input' can be parsed as a User ID +func ValidateUserID(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 := ParseUserID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User ID +func (id UserId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s/users/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName, id.UserName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User ID +func (id UserId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderName"), + resourceids.StaticSegment("staticUsers", "users", "users"), + resourceids.UserSpecifiedSegment("userName", "userName"), + } +} + +// String returns a human-readable description of this User ID +func (id UserId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + fmt.Sprintf("User Name: %q", id.UserName), + } + return fmt.Sprintf("User (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_user_test.go b/resource-manager/web/2024-04-01/staticsites/id_user_test.go new file mode 100644 index 00000000000..e79e3a28959 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_user_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &UserId{} + +func TestNewUserID(t *testing.T) { + id := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.AuthProviderName != "authProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderName") + } + + if id.UserName != "userName" { + t.Fatalf("Expected %q but got %q for Segment 'UserName'", id.UserName, "userName") + } +} + +func TestFormatUserID(t *testing.T) { + actual := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + UserName: "userName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestParseUserIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + UserName: "userName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs/uSeRnAmE", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + AuthProviderName: "aUtHpRoViDeRnAmE", + UserName: "uSeRnAmE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs/uSeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestSegmentsForUserId(t *testing.T) { + segments := UserId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserId 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/web/2024-04-01/staticsites/id_userprovidedfunctionapp.go b/resource-manager/web/2024-04-01/staticsites/id_userprovidedfunctionapp.go new file mode 100644 index 00000000000..ff361f6c538 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_userprovidedfunctionapp.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&UserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &UserProvidedFunctionAppId{} + +// UserProvidedFunctionAppId is a struct representing the Resource ID for a User Provided Function App +type UserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + UserProvidedFunctionAppName string +} + +// NewUserProvidedFunctionAppID returns a new UserProvidedFunctionAppId struct +func NewUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, userProvidedFunctionAppName string) UserProvidedFunctionAppId { + return UserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseUserProvidedFunctionAppID parses 'input' into a UserProvidedFunctionAppId +func ParseUserProvidedFunctionAppID(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a UserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseUserProvidedFunctionAppIDInsensitively(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserProvidedFunctionAppId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateUserProvidedFunctionAppID checks that 'input' can be parsed as a User Provided Function App ID +func ValidateUserProvidedFunctionAppID(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 := ParseUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User Provided Function App ID +func (id UserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User Provided Function App ID +func (id UserProvidedFunctionAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppName"), + } +} + +// String returns a human-readable description of this User Provided Function App ID +func (id UserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/staticsites/id_userprovidedfunctionapp_test.go b/resource-manager/web/2024-04-01/staticsites/id_userprovidedfunctionapp_test.go new file mode 100644 index 00000000000..038fecd6ba1 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/id_userprovidedfunctionapp_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &UserProvidedFunctionAppId{} + +func TestNewUserProvidedFunctionAppID(t *testing.T) { + id := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + + 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.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppName" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppName") + } +} + +func TestFormatUserProvidedFunctionAppID(t *testing.T) { + actual := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppID(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpNaMe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppIDInsensitively(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.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForUserProvidedFunctionAppId(t *testing.T) { + segments := UserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserProvidedFunctionAppId 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/web/2024-04-01/staticsites/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..b07e7684411 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package staticsites + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatebasicauth.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatebasicauth.go new file mode 100644 index 00000000000..e320de5ee8d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatebasicauth.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// CreateOrUpdateBasicAuth ... +func (c StaticSitesClient) CreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (result CreateOrUpdateBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicAuth/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 + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatebuilddatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatebuilddatabaseconnection.go new file mode 100644 index 00000000000..577ea3e3a33 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatebuilddatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +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 CreateOrUpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateBuildDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatedatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatedatabaseconnection.go new file mode 100644 index 00000000000..4e9d93d0c60 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatedatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +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 CreateOrUpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsite.go new file mode 100644 index 00000000000..15bec306823 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsite.go @@ -0,0 +1,75 @@ +package staticsites + +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 CreateOrUpdateStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// CreateOrUpdateStaticSite ... +func (c StaticSitesClient) CreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (result CreateOrUpdateStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateStaticSiteThenPoll performs CreateOrUpdateStaticSite then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) error { + result, err := c.CreateOrUpdateStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsiteappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsiteappsettings.go new file mode 100644 index 00000000000..7664955e4a5 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsiteappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildappsettings.go new file mode 100644 index 00000000000..ea9eccbeb1d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..6ccea1d9510 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitecustomdomain.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitecustomdomain.go new file mode 100644 index 00000000000..77c06560af1 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitecustomdomain.go @@ -0,0 +1,75 @@ +package staticsites + +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 CreateOrUpdateStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// CreateOrUpdateStaticSiteCustomDomain ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result CreateOrUpdateStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateStaticSiteCustomDomainThenPoll performs CreateOrUpdateStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.CreateOrUpdateStaticSiteCustomDomain(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go new file mode 100644 index 00000000000..8bc2ba7c3e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createuserrolesinvitationlink.go b/resource-manager/web/2024-04-01/staticsites/method_createuserrolesinvitationlink.go new file mode 100644 index 00000000000..62bf2337cca --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createuserrolesinvitationlink.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateUserRolesInvitationLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserInvitationResponseResource +} + +// CreateUserRolesInvitationLink ... +func (c StaticSitesClient) CreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (result CreateUserRolesInvitationLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/createUserInvitation", 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 + } + + var model StaticSiteUserInvitationResponseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsite.go new file mode 100644 index 00000000000..6dddfe32ead --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSite ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteThenPoll performs CreateZipDeploymentForStaticSite then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsitebuild.go new file mode 100644 index 00000000000..4b1ac38f9e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_createzipdeploymentforstaticsitebuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSiteBuild ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteBuildThenPoll performs CreateZipDeploymentForStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuildThenPoll(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSiteBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletebuilddatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_deletebuilddatabaseconnection.go new file mode 100644 index 00000000000..5a80028d137 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletebuilddatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBuildDatabaseConnection ... +func (c StaticSitesClient) DeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletedatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_deletedatabaseconnection.go new file mode 100644 index 00000000000..7f0d6cc94aa --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletedatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDatabaseConnection ... +func (c StaticSitesClient) DeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result DeleteDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..d632f3899b4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package staticsites + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c StaticSitesClient) DeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletestaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsite.go new file mode 100644 index 00000000000..78d3bd0abf4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSite ... +func (c StaticSitesClient) DeleteStaticSite(ctx context.Context, id StaticSiteId) (result DeleteStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteThenPoll performs DeleteStaticSite then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DeleteStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitebuild.go new file mode 100644 index 00000000000..a3fdbf84900 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitebuild.go @@ -0,0 +1,71 @@ +package staticsites + +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 DeleteStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteBuild ... +func (c StaticSitesClient) DeleteStaticSiteBuild(ctx context.Context, id BuildId) (result DeleteStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteBuildThenPoll performs DeleteStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteBuildThenPoll(ctx context.Context, id BuildId) error { + result, err := c.DeleteStaticSiteBuild(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitecustomdomain.go b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitecustomdomain.go new file mode 100644 index 00000000000..471bf713f5d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsitecustomdomain.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteCustomDomain ... +func (c StaticSitesClient) DeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result DeleteStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteCustomDomainThenPoll performs DeleteStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.DeleteStaticSiteCustomDomain(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_deletestaticsiteuser.go b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsiteuser.go new file mode 100644 index 00000000000..e4799c87ddb --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_deletestaticsiteuser.go @@ -0,0 +1,46 @@ +package staticsites + +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 DeleteStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteUser ... +func (c StaticSitesClient) DeleteStaticSiteUser(ctx context.Context, id UserId) (result DeleteStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_detachstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_detachstaticsite.go new file mode 100644 index 00000000000..00fa4ac9dd0 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_detachstaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DetachStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DetachStaticSite ... +func (c StaticSitesClient) DetachStaticSite(ctx context.Context, id StaticSiteId) (result DetachStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/detach", 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 +} + +// DetachStaticSiteThenPoll performs DetachStaticSite then polls until it's completed +func (c StaticSitesClient) DetachStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DetachStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DetachStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DetachStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go new file mode 100644 index 00000000000..b9a68ba826d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSite ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go new file mode 100644 index 00000000000..305f4802b1d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSiteBuild ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getbasicauth.go b/resource-manager/web/2024-04-01/staticsites/method_getbasicauth.go new file mode 100644 index 00000000000..860b9bdbfd2 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getbasicauth.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// GetBasicAuth ... +func (c StaticSitesClient) GetBasicAuth(ctx context.Context, id StaticSiteId) (result GetBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth/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 + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnection.go new file mode 100644 index 00000000000..6d90dfd9ae3 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnection.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnection ... +func (c StaticSitesClient) GetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionOperationResponse, 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnections.go b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnections.go new file mode 100644 index 00000000000..7b74f18507d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnections.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetBuildDatabaseConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBuildDatabaseConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBuildDatabaseConnections ... +func (c StaticSitesClient) GetBuildDatabaseConnections(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetBuildDatabaseConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/databaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetBuildDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..dca1df6d320 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBuildDatabaseConnectionsWithDetailsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBuildDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetBuildDatabaseConnectionsWithDetailsCustomPager{}, + Path: fmt.Sprintf("%s/showDatabaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetBuildDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..c035b26d729 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnection.go new file mode 100644 index 00000000000..ad1f59b58d4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnection.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnection ... +func (c StaticSitesClient) GetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionOperationResponse, 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnections.go b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnections.go new file mode 100644 index 00000000000..47dcec6884d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnections.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetDatabaseConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetDatabaseConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetDatabaseConnections ... +func (c StaticSitesClient) GetDatabaseConnections(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetDatabaseConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/databaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsCompleteResult, error) { + return c.GetDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionswithdetails.go b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..4b57d3116ee --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionswithdetails.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetDatabaseConnectionsWithDetailsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetDatabaseConnectionsWithDetailsCustomPager{}, + Path: fmt.Sprintf("%s/showDatabaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionwithdetails.go b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..349897ee72d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getdatabaseconnectionwithdetails.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackend.go b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackend.go new file mode 100644 index 00000000000..553c375e975 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackend.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetLinkedBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackend ... +func (c StaticSitesClient) GetLinkedBackend(ctx context.Context, id LinkedBackendId) (result GetLinkedBackendOperationResponse, 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 + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendforbuild.go b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendforbuild.go new file mode 100644 index 00000000000..5761fa2c83b --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendforbuild.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetLinkedBackendForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendForBuild ... +func (c StaticSitesClient) GetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (result GetLinkedBackendForBuildOperationResponse, 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 + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackends.go b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackends.go new file mode 100644 index 00000000000..8b45e6df96b --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackends.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetLinkedBackendsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetLinkedBackendsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetLinkedBackends ... +func (c StaticSitesClient) GetLinkedBackends(ctx context.Context, id StaticSiteId) (result GetLinkedBackendsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetLinkedBackendsCustomPager{}, + Path: fmt.Sprintf("%s/linkedBackends", 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 *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsComplete(ctx context.Context, id StaticSiteId) (GetLinkedBackendsCompleteResult, error) { + return c.GetLinkedBackendsCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackends(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetLinkedBackendsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendsforbuild.go b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendsforbuild.go new file mode 100644 index 00000000000..78d17e5d639 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getlinkedbackendsforbuild.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetLinkedBackendsForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetLinkedBackendsForBuildCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetLinkedBackendsForBuild ... +func (c StaticSitesClient) GetLinkedBackendsForBuild(ctx context.Context, id BuildId) (result GetLinkedBackendsForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetLinkedBackendsForBuildCustomPager{}, + Path: fmt.Sprintf("%s/linkedBackends", 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 *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsForBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsForBuildComplete(ctx context.Context, id BuildId) (GetLinkedBackendsForBuildCompleteResult, error) { + return c.GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsForBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsForBuildCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackendsForBuild(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetLinkedBackendsForBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..0d198e2c428 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c StaticSitesClient) GetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, 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 + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..7de0a9af9fb --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getprivateendpointconnectionlist.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c StaticSitesClient) GetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c StaticSitesClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id StaticSiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getprivatelinkresources.go b/resource-manager/web/2024-04-01/staticsites/method_getprivatelinkresources.go new file mode 100644 index 00000000000..0234f35567a --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getprivatelinkresources.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c StaticSitesClient) GetPrivateLinkResources(ctx context.Context, id StaticSiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_getstaticsite.go new file mode 100644 index 00000000000..f1a5134adf8 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getstaticsite.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// GetStaticSite ... +func (c StaticSitesClient) GetStaticSite(ctx context.Context, id StaticSiteId) (result GetStaticSiteOperationResponse, 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 + } + + var model StaticSiteARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuild.go new file mode 100644 index 00000000000..980e9844cd4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuild.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBuildARMResource +} + +// GetStaticSiteBuild ... +func (c StaticSitesClient) GetStaticSiteBuild(ctx context.Context, id BuildId) (result GetStaticSiteBuildOperationResponse, 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 + } + + var model StaticSiteBuildARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuilds.go b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuilds.go new file mode 100644 index 00000000000..b3a188507cf --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitebuilds.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetStaticSiteBuildsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetStaticSiteBuildsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetStaticSiteBuilds ... +func (c StaticSitesClient) GetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (result GetStaticSiteBuildsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetStaticSiteBuildsCustomPager{}, + Path: fmt.Sprintf("%s/builds", 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 *[]StaticSiteBuildARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSiteBuildsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSiteBuildsComplete(ctx context.Context, id StaticSiteId) (GetStaticSiteBuildsCompleteResult, error) { + return c.GetStaticSiteBuildsCompleteMatchingPredicate(ctx, id, StaticSiteBuildARMResourceOperationPredicate{}) +} + +// GetStaticSiteBuildsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSiteBuildsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBuildARMResourceOperationPredicate) (result GetStaticSiteBuildsCompleteResult, err error) { + items := make([]StaticSiteBuildARMResource, 0) + + resp, err := c.GetStaticSiteBuilds(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetStaticSiteBuildsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getstaticsitecustomdomain.go b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitecustomdomain.go new file mode 100644 index 00000000000..4f067b9c862 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitecustomdomain.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetStaticSiteCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// GetStaticSiteCustomDomain ... +func (c StaticSitesClient) GetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result GetStaticSiteCustomDomainOperationResponse, 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 + } + + var model StaticSiteCustomDomainOverviewARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getstaticsitesbyresourcegroup.go b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitesbyresourcegroup.go new file mode 100644 index 00000000000..6c479510d72 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getstaticsitesbyresourcegroup.go @@ -0,0 +1,106 @@ +package staticsites + +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 GetStaticSitesByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetStaticSitesByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetStaticSitesByResourceGroup ... +func (c StaticSitesClient) GetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetStaticSitesByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetStaticSitesByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", 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 *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSitesByResourceGroupComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSitesByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetStaticSitesByResourceGroupCompleteResult, error) { + return c.GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// GetStaticSitesByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StaticSiteARMResourceOperationPredicate) (result GetStaticSitesByResourceGroupCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.GetStaticSitesByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetStaticSitesByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go new file mode 100644 index 00000000000..0407b757d73 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, 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 + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go new file mode 100644 index 00000000000..6c737d6cde7 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go @@ -0,0 +1,53 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, 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 + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go new file mode 100644 index 00000000000..800d5ab1d72 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetUserProvidedFunctionAppsForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUserProvidedFunctionAppsForStaticSiteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUserProvidedFunctionAppsForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUserProvidedFunctionAppsForStaticSiteCustomPager{}, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", 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 *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteComplete(ctx context.Context, id StaticSiteId) (GetUserProvidedFunctionAppsForStaticSiteCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSite(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetUserProvidedFunctionAppsForStaticSiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go new file mode 100644 index 00000000000..b86539d1801 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUserProvidedFunctionAppsForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager{}, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", 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 *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx context.Context, id BuildId) (GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_linkbackend.go b/resource-manager/web/2024-04-01/staticsites/method_linkbackend.go new file mode 100644 index 00000000000..a36f96d86fa --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_linkbackend.go @@ -0,0 +1,74 @@ +package staticsites + +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 LinkBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackend ... +func (c StaticSitesClient) LinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 +} + +// LinkBackendThenPoll performs LinkBackend then polls until it's completed +func (c StaticSitesClient) LinkBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_linkbackendtobuild.go b/resource-manager/web/2024-04-01/staticsites/method_linkbackendtobuild.go new file mode 100644 index 00000000000..5e187571493 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_linkbackendtobuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 LinkBackendToBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackendToBuild ... +func (c StaticSitesClient) LinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendToBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 +} + +// LinkBackendToBuildThenPoll performs LinkBackendToBuild then polls until it's completed +func (c StaticSitesClient) LinkBackendToBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackendToBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackendToBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackendToBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_list.go b/resource-manager/web/2024-04-01/staticsites/method_list.go new file mode 100644 index 00000000000..e071040c10d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_list.go @@ -0,0 +1,106 @@ +package staticsites + +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 *[]StaticSiteARMResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c StaticSitesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", 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 *[]StaticSiteARMResource `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 StaticSitesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StaticSiteARMResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/staticsites/method_listbasicauth.go b/resource-manager/web/2024-04-01/staticsites/method_listbasicauth.go new file mode 100644 index 00000000000..3c466f4f588 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_listbasicauth.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicAuthCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicAuth ... +func (c StaticSitesClient) ListBasicAuth(ctx context.Context, id StaticSiteId) (result ListBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicAuthCustomPager{}, + Path: fmt.Sprintf("%s/basicAuth", 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 *[]StaticSiteBasicAuthPropertiesARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicAuthComplete retrieves all the results into a single object +func (c StaticSitesClient) ListBasicAuthComplete(ctx context.Context, id StaticSiteId) (ListBasicAuthCompleteResult, error) { + return c.ListBasicAuthCompleteMatchingPredicate(ctx, id, StaticSiteBasicAuthPropertiesARMResourceOperationPredicate{}) +} + +// ListBasicAuthCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListBasicAuthCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) (result ListBasicAuthCompleteResult, err error) { + items := make([]StaticSiteBasicAuthPropertiesARMResource, 0) + + resp, err := c.ListBasicAuth(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBasicAuthCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteappsettings.go new file mode 100644 index 00000000000..af3f94e29fc --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteAppSettings ... +func (c StaticSitesClient) ListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildappsettings.go new file mode 100644 index 00000000000..b23b85384c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctionappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..220b09e2518 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctionappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctions.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctions.go new file mode 100644 index 00000000000..3f2f7d75e25 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitebuildfunctions.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteBuildFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteBuildFunctions ... +func (c StaticSitesClient) ListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteBuildFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", 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 *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteBuildFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteBuildFunctionsComplete(ctx context.Context, id BuildId) (ListStaticSiteBuildFunctionsCompleteResult, error) { + return c.ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteBuildFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteBuildFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteBuildFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListStaticSiteBuildFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteconfiguredroles.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteconfiguredroles.go new file mode 100644 index 00000000000..ad252bdfded --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteconfiguredroles.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteConfiguredRolesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringList +} + +// ListStaticSiteConfiguredRoles ... +func (c StaticSitesClient) ListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConfiguredRoles", 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 + } + + var model StringList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitecustomdomains.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitecustomdomains.go new file mode 100644 index 00000000000..da0d6cea4e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitecustomdomains.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteCustomDomainsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteCustomDomainsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteCustomDomains ... +func (c StaticSitesClient) ListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (result ListStaticSiteCustomDomainsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteCustomDomainsCustomPager{}, + Path: fmt.Sprintf("%s/customDomains", 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 *[]StaticSiteCustomDomainOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteCustomDomainsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteCustomDomainsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteCustomDomainsCompleteResult, error) { + return c.ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx, id, StaticSiteCustomDomainOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteCustomDomainsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteCustomDomainOverviewARMResourceOperationPredicate) (result ListStaticSiteCustomDomainsCompleteResult, err error) { + items := make([]StaticSiteCustomDomainOverviewARMResource, 0) + + resp, err := c.ListStaticSiteCustomDomains(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListStaticSiteCustomDomainsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctionappsettings.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctionappsettings.go new file mode 100644 index 00000000000..9c4a10a187f --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctionappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctions.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctions.go new file mode 100644 index 00000000000..625443d50b3 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitefunctions.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteFunctions ... +func (c StaticSitesClient) ListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", 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 *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteFunctionsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteFunctionsCompleteResult, error) { + return c.ListStaticSiteFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteFunctionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListStaticSiteFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsitesecrets.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitesecrets.go new file mode 100644 index 00000000000..f9ed5192106 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsitesecrets.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteSecrets ... +func (c StaticSitesClient) ListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (result ListStaticSiteSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteusers.go b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteusers.go new file mode 100644 index 00000000000..d711c5393b9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_liststaticsiteusers.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteUsersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserARMResource +} + +type ListStaticSiteUsersCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserARMResource +} + +type ListStaticSiteUsersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteUsersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteUsers ... +func (c StaticSitesClient) ListStaticSiteUsers(ctx context.Context, id AuthProviderId) (result ListStaticSiteUsersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListStaticSiteUsersCustomPager{}, + Path: fmt.Sprintf("%s/listUsers", 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 *[]StaticSiteUserARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteUsersComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteUsersComplete(ctx context.Context, id AuthProviderId) (ListStaticSiteUsersCompleteResult, error) { + return c.ListStaticSiteUsersCompleteMatchingPredicate(ctx, id, StaticSiteUserARMResourceOperationPredicate{}) +} + +// ListStaticSiteUsersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteUsersCompleteMatchingPredicate(ctx context.Context, id AuthProviderId, predicate StaticSiteUserARMResourceOperationPredicate) (result ListStaticSiteUsersCompleteResult, err error) { + items := make([]StaticSiteUserARMResource, 0) + + resp, err := c.ListStaticSiteUsers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListStaticSiteUsersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_previewworkflow.go b/resource-manager/web/2024-04-01/staticsites/method_previewworkflow.go new file mode 100644 index 00000000000..2a34e3a3c41 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_previewworkflow.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "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 PreviewWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSitesWorkflowPreview +} + +// PreviewWorkflow ... +func (c StaticSitesClient) PreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (result PreviewWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/previewStaticSiteWorkflowFile", 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 + } + + var model StaticSitesWorkflowPreview + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go new file mode 100644 index 00000000000..c210993e945 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go @@ -0,0 +1,104 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSite ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteThenPoll performs RegisterUserProvidedFunctionAppWithStaticSite then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go b/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go new file mode 100644 index 00000000000..2d4f13d5c79 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go @@ -0,0 +1,104 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuild ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll performs RegisterUserProvidedFunctionAppWithStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_resetstaticsiteapikey.go b/resource-manager/web/2024-04-01/staticsites/method_resetstaticsiteapikey.go new file mode 100644 index 00000000000..722e36f78c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_resetstaticsiteapikey.go @@ -0,0 +1,51 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ResetStaticSiteApiKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetStaticSiteApiKey ... +func (c StaticSitesClient) ResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (result ResetStaticSiteApiKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetapikey", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_unlinkbackend.go b/resource-manager/web/2024-04-01/staticsites/method_unlinkbackend.go new file mode 100644 index 00000000000..27575e98684 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_unlinkbackend.go @@ -0,0 +1,77 @@ +package staticsites + +import ( + "context" + "fmt" + "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 UnlinkBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendOperationOptions() UnlinkBackendOperationOptions { + return UnlinkBackendOperationOptions{} +} + +func (o UnlinkBackendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackend ... +func (c StaticSitesClient) UnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (result UnlinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_unlinkbackendfrombuild.go b/resource-manager/web/2024-04-01/staticsites/method_unlinkbackendfrombuild.go new file mode 100644 index 00000000000..f6055b15e30 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_unlinkbackendfrombuild.go @@ -0,0 +1,77 @@ +package staticsites + +import ( + "context" + "fmt" + "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 UnlinkBackendFromBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendFromBuildOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendFromBuildOperationOptions() UnlinkBackendFromBuildOperationOptions { + return UnlinkBackendFromBuildOperationOptions{} +} + +func (o UnlinkBackendFromBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackendFromBuild ... +func (c StaticSitesClient) UnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (result UnlinkBackendFromBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_updatebuilddatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_updatebuilddatabaseconnection.go new file mode 100644 index 00000000000..2c78c742cf3 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_updatebuilddatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +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 UpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateBuildDatabaseConnection ... +func (c StaticSitesClient) UpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_updatedatabaseconnection.go b/resource-manager/web/2024-04-01/staticsites/method_updatedatabaseconnection.go new file mode 100644 index 00000000000..c2bab9a13a3 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_updatedatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +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 UpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateDatabaseConnection ... +func (c StaticSitesClient) UpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_updatestaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_updatestaticsite.go new file mode 100644 index 00000000000..c1706e09ddb --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_updatestaticsite.go @@ -0,0 +1,58 @@ +package staticsites + +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 UpdateStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// UpdateStaticSite ... +func (c StaticSitesClient) UpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (result UpdateStaticSiteOperationResponse, 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 + } + + var model StaticSiteARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_updatestaticsiteuser.go b/resource-manager/web/2024-04-01/staticsites/method_updatestaticsiteuser.go new file mode 100644 index 00000000000..7741cafbf21 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_updatestaticsiteuser.go @@ -0,0 +1,57 @@ +package staticsites + +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 UpdateStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserARMResource +} + +// UpdateStaticSiteUser ... +func (c StaticSitesClient) UpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (result UpdateStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model StaticSiteUserARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_validatebackend.go b/resource-manager/web/2024-04-01/staticsites/method_validatebackend.go new file mode 100644 index 00000000000..12aa25c2202 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_validatebackend.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackend ... +func (c StaticSitesClient) ValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendThenPoll performs ValidateBackend then polls until it's completed +func (c StaticSitesClient) ValidateBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_validatebackendforbuild.go b/resource-manager/web/2024-04-01/staticsites/method_validatebackendforbuild.go new file mode 100644 index 00000000000..d703ff84c0b --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_validatebackendforbuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendForBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackendForBuild ... +func (c StaticSitesClient) ValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendForBuildThenPoll performs ValidateBackendForBuild then polls until it's completed +func (c StaticSitesClient) ValidateBackendForBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackendForBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackendForBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackendForBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go b/resource-manager/web/2024-04-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go new file mode 100644 index 00000000000..deda3155c42 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateCustomDomainCanBeAddedToStaticSite ... +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateCustomDomainCanBeAddedToStaticSiteThenPoll performs ValidateCustomDomainCanBeAddedToStaticSite then polls until it's completed +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.ValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_armidwrapper.go b/resource-manager/web/2024-04-01/staticsites/model_armidwrapper.go new file mode 100644 index 00000000000..c9987651a5f --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_armidwrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_armplan.go b/resource-manager/web/2024-04-01/staticsites/model_armplan.go new file mode 100644 index 00000000000..2cb5352de6e --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_armplan.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmPlan struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_capability.go b/resource-manager/web/2024-04-01/staticsites/model_capability.go new file mode 100644 index 00000000000..300bf980489 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_capability.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_databaseconnection.go b/resource-manager/web/2024-04-01/staticsites/model_databaseconnection.go new file mode 100644 index 00000000000..cd069f365d4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_databaseconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabaseConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionoverview.go b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionoverview.go new file mode 100644 index 00000000000..8597c4ff8b4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionoverview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOverview struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + Name *string `json:"name,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequest.go b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequest.go new file mode 100644 index 00000000000..493e3509268 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequest.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequest struct { + Properties *DatabaseConnectionPatchRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequestproperties.go b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequestproperties.go new file mode 100644 index 00000000000..2b5eb824c26 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionpatchrequestproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequestProperties struct { + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionproperties.go b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionproperties.go new file mode 100644 index 00000000000..81aee01e533 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_databaseconnectionproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionProperties struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region string `json:"region"` + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_errorentity.go b/resource-manager/web/2024-04-01/staticsites/model_errorentity.go new file mode 100644 index 00000000000..6b726cb5492 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_errorentity.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_privatelinkconnectionstate.go b/resource-manager/web/2024-04-01/staticsites/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..bdfe81e8a98 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_privatelinkresource.go b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresource.go new file mode 100644 index 00000000000..975df70d5c7 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..8dacfc8b182 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..2890dfe9e4a --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnection.go new file mode 100644 index 00000000000..2456e6e1d5b --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..708bf563a7f --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..75f3ef6233d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionproperties.go b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..23d098fcaa6 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_remoteprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go b/resource-manager/web/2024-04-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go new file mode 100644 index 00000000000..54a231b3460 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go @@ -0,0 +1,24 @@ +package staticsites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMessageEnvelopeRemotePrivateEndpointConnection struct { + Error *ErrorEntity `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Plan *ArmPlan `json:"plan,omitempty"` + Properties *RemotePrivateEndpointConnection `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Status *string `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_skucapacity.go b/resource-manager/web/2024-04-01/staticsites/model_skucapacity.go new file mode 100644 index 00000000000..d8cd9de7ec4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_skucapacity.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_skudescription.go b/resource-manager/web/2024-04-01/staticsites/model_skudescription.go new file mode 100644 index 00000000000..2e1e0cde311 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_skudescription.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsite.go b/resource-manager/web/2024-04-01/staticsites/model_staticsite.go new file mode 100644 index 00000000000..04ffe0c1027 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsite.go @@ -0,0 +1,25 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSite struct { + AllowConfigFileUpdates *bool `json:"allowConfigFileUpdates,omitempty"` + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + ContentDistributionEndpoint *string `json:"contentDistributionEndpoint,omitempty"` + CustomDomains *[]string `json:"customDomains,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + DefaultHostname *string `json:"defaultHostname,omitempty"` + EnterpriseGradeCdnStatus *EnterpriseGradeCdnStatus `json:"enterpriseGradeCdnStatus,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PrivateEndpointConnections *[]ResponseMessageEnvelopeRemotePrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + Provider *string `json:"provider,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RepositoryToken *string `json:"repositoryToken,omitempty"` + RepositoryURL *string `json:"repositoryUrl,omitempty"` + StagingEnvironmentPolicy *StagingEnvironmentPolicy `json:"stagingEnvironmentPolicy,omitempty"` + TemplateProperties *StaticSiteTemplateOptions `json:"templateProperties,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitearmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitearmresource.go new file mode 100644 index 00000000000..a54aa2362bb --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitearmresource.go @@ -0,0 +1,20 @@ +package staticsites + +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 StaticSiteARMResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go new file mode 100644 index 00000000000..bf58faf53d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBasicAuthPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..e413aa4a9c5 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResourceProperties struct { + ApplicableEnvironmentsMode string `json:"applicableEnvironmentsMode"` + Environments *[]string `json:"environments,omitempty"` + Password *string `json:"password,omitempty"` + SecretState *string `json:"secretState,omitempty"` + SecretURL *string `json:"secretUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresource.go new file mode 100644 index 00000000000..332e5334386 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBuildARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresourceproperties.go new file mode 100644 index 00000000000..50bbe9e5443 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildarmresourceproperties.go @@ -0,0 +1,47 @@ +package staticsites + +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 StaticSiteBuildARMResourceProperties struct { + BuildId *string `json:"buildId,omitempty"` + CreatedTimeUtc *string `json:"createdTimeUtc,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + Hostname *string `json:"hostname,omitempty"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PullRequestTitle *string `json:"pullRequestTitle,omitempty"` + SourceBranch *string `json:"sourceBranch,omitempty"` + Status *BuildStatus `json:"status,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} + +func (o *StaticSiteBuildARMResourceProperties) GetCreatedTimeUtcAsTime() (*time.Time, error) { + if o.CreatedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetCreatedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimeUtc = &formatted +} + +func (o *StaticSiteBuildARMResourceProperties) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildproperties.go new file mode 100644 index 00000000000..9dbe72ed06c --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitebuildproperties.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildProperties struct { + ApiBuildCommand *string `json:"apiBuildCommand,omitempty"` + ApiLocation *string `json:"apiLocation,omitempty"` + AppArtifactLocation *string `json:"appArtifactLocation,omitempty"` + AppBuildCommand *string `json:"appBuildCommand,omitempty"` + AppLocation *string `json:"appLocation,omitempty"` + GitHubActionSecretNameOverride *string `json:"githubActionSecretNameOverride,omitempty"` + OutputLocation *string `json:"outputLocation,omitempty"` + SkipGithubActionWorkflowGeneration *bool `json:"skipGithubActionWorkflowGeneration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go new file mode 100644 index 00000000000..95f00a98762 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go new file mode 100644 index 00000000000..cc0b5c99274 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go @@ -0,0 +1,30 @@ +package staticsites + +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 StaticSiteCustomDomainOverviewARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + DomainName *string `json:"domainName,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Status *CustomDomainStatus `json:"status,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go new file mode 100644 index 00000000000..b790fc90f5d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainRequestPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..e4510ee8855 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResourceProperties struct { + ValidationMethod *string `json:"validationMethod,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go new file mode 100644 index 00000000000..0389a6f704c --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteDatabaseConnectionConfigurationFileOverview struct { + Contents *string `json:"contents,omitempty"` + FileName *string `json:"fileName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresource.go new file mode 100644 index 00000000000..fa8ca3288d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteFunctionOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go new file mode 100644 index 00000000000..46eeb330774 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResourceProperties struct { + FunctionName *string `json:"functionName,omitempty"` + TriggerType *TriggerTypes `json:"triggerType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackend.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackend.go new file mode 100644 index 00000000000..52b103d13bc --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackend.go @@ -0,0 +1,29 @@ +package staticsites + +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 StaticSiteLinkedBackend struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackend) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackend) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresource.go new file mode 100644 index 00000000000..97ddc7ab2ac --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteLinkedBackendARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteLinkedBackendARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go new file mode 100644 index 00000000000..5ec2c55c393 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go @@ -0,0 +1,29 @@ +package staticsites + +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 StaticSiteLinkedBackendARMResourceProperties struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitepatchresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitepatchresource.go new file mode 100644 index 00000000000..6969a6ebae4 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitepatchresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresource.go new file mode 100644 index 00000000000..53a0c64632a --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteResetPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..87a927d3952 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResourceProperties struct { + RepositoryToken *string `json:"repositoryToken,omitempty"` + ShouldUpdateRepository *bool `json:"shouldUpdateRepository,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreview.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreview.go new file mode 100644 index 00000000000..01cca8f1d47 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreview struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewproperties.go new file mode 100644 index 00000000000..4e0aa482c92 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewProperties struct { + Contents *string `json:"contents,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequest.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequest.go new file mode 100644 index 00000000000..c255ba00697 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequest.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go new file mode 100644 index 00000000000..c3d04f76a6d --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequestProperties struct { + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + RepositoryURL *string `json:"repositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitetemplateoptions.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitetemplateoptions.go new file mode 100644 index 00000000000..1f957ada652 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitetemplateoptions.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteTemplateOptions struct { + Description *string `json:"description,omitempty"` + IsPrivate *bool `json:"isPrivate,omitempty"` + Owner *string `json:"owner,omitempty"` + RepositoryName *string `json:"repositoryName,omitempty"` + TemplateRepositoryURL *string `json:"templateRepositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresource.go new file mode 100644 index 00000000000..296cf30c6f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresourceproperties.go new file mode 100644 index 00000000000..1ee310fa773 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResourceProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserId *string `json:"userId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresource.go new file mode 100644 index 00000000000..d9d5ae47bdc --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationRequestResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go new file mode 100644 index 00000000000..744a01b8f56 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResourceProperties struct { + Domain *string `json:"domain,omitempty"` + NumHoursToExpiration *int64 `json:"numHoursToExpiration,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserDetails *string `json:"userDetails,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresource.go new file mode 100644 index 00000000000..1c89e5056c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationResponseResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationResponseResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go new file mode 100644 index 00000000000..57c9a2fb872 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go @@ -0,0 +1,27 @@ +package staticsites + +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 StaticSiteUserInvitationResponseResourceProperties struct { + ExpiresOn *string `json:"expiresOn,omitempty"` + InvitationURL *string `json:"invitationUrl,omitempty"` +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) GetExpiresOnAsTime() (*time.Time, error) { + if o.ExpiresOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiresOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) SetExpiresOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiresOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapp.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapp.go new file mode 100644 index 00000000000..08c7d23a344 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapp.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionApp struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go new file mode 100644 index 00000000000..c3a983f8eea --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionAppARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go new file mode 100644 index 00000000000..5c3f5f4b629 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go @@ -0,0 +1,28 @@ +package staticsites + +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 StaticSiteUserProvidedFunctionAppARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go new file mode 100644 index 00000000000..d1aa33d93e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go @@ -0,0 +1,28 @@ +package staticsites + +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 StaticSiteUserProvidedFunctionAppProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeployment.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeployment.go new file mode 100644 index 00000000000..e91994bd766 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeployment.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeployment struct { + ApiZipURL *string `json:"apiZipUrl,omitempty"` + AppZipURL *string `json:"appZipUrl,omitempty"` + DeploymentTitle *string `json:"deploymentTitle,omitempty"` + FunctionLanguage *string `json:"functionLanguage,omitempty"` + Provider *string `json:"provider,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeploymentarmresource.go b/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeploymentarmresource.go new file mode 100644 index 00000000000..f842a2730dc --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_staticsitezipdeploymentarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeploymentARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteZipDeployment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_stringdictionary.go b/resource-manager/web/2024-04-01/staticsites/model_stringdictionary.go new file mode 100644 index 00000000000..71965903614 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_stringdictionary.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/model_stringlist.go b/resource-manager/web/2024-04-01/staticsites/model_stringlist.go new file mode 100644 index 00000000000..79987b1ea84 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/model_stringlist.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringList struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *[]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/staticsites/predicates.go b/resource-manager/web/2024-04-01/staticsites/predicates.go new file mode 100644 index 00000000000..b27ed7b5388 --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/predicates.go @@ -0,0 +1,289 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DatabaseConnectionOperationPredicate) Matches(input DatabaseConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteARMResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p StaticSiteARMResourceOperationPredicate) Matches(input StaticSiteARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteBasicAuthPropertiesARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) Matches(input StaticSiteBasicAuthPropertiesARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteBuildARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBuildARMResourceOperationPredicate) Matches(input StaticSiteBuildARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteCustomDomainOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteCustomDomainOverviewARMResourceOperationPredicate) Matches(input StaticSiteCustomDomainOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteFunctionOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteFunctionOverviewARMResourceOperationPredicate) Matches(input StaticSiteFunctionOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteLinkedBackendARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteLinkedBackendARMResourceOperationPredicate) Matches(input StaticSiteLinkedBackendARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteUserARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserARMResourceOperationPredicate) Matches(input StaticSiteUserARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) Matches(input StaticSiteUserProvidedFunctionAppARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/staticsites/version.go b/resource-manager/web/2024-04-01/staticsites/version.go new file mode 100644 index 00000000000..a8fecb74cda --- /dev/null +++ b/resource-manager/web/2024-04-01/staticsites/version.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/staticsites/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/README.md b/resource-manager/web/2024-04-01/topleveldomains/README.md new file mode 100644 index 00000000000..1d1267af3e7 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/README.md @@ -0,0 +1,76 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/topleveldomains` Documentation + +The `topleveldomains` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/topleveldomains" +``` + + +### Client Initialization + +```go +client := topleveldomains.NewTopLevelDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TopLevelDomainsClient.Get` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + +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: `TopLevelDomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `TopLevelDomainsClient.ListAgreements` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + +payload := topleveldomains.TopLevelDomainAgreementOption{ + // ... +} + + +// alternatively `client.ListAgreements(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListAgreementsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/topleveldomains/client.go b/resource-manager/web/2024-04-01/topleveldomains/client.go new file mode 100644 index 00000000000..73312d38791 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/client.go @@ -0,0 +1,26 @@ +package topleveldomains + +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 TopLevelDomainsClient struct { + Client *resourcemanager.Client +} + +func NewTopLevelDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*TopLevelDomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "topleveldomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TopLevelDomainsClient: %+v", err) + } + + return &TopLevelDomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain.go b/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain.go new file mode 100644 index 00000000000..de4d3235874 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain.go @@ -0,0 +1,121 @@ +package topleveldomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TopLevelDomainId{}) +} + +var _ resourceids.ResourceId = &TopLevelDomainId{} + +// TopLevelDomainId is a struct representing the Resource ID for a Top Level Domain +type TopLevelDomainId struct { + SubscriptionId string + TopLevelDomainName string +} + +// NewTopLevelDomainID returns a new TopLevelDomainId struct +func NewTopLevelDomainID(subscriptionId string, topLevelDomainName string) TopLevelDomainId { + return TopLevelDomainId{ + SubscriptionId: subscriptionId, + TopLevelDomainName: topLevelDomainName, + } +} + +// ParseTopLevelDomainID parses 'input' into a TopLevelDomainId +func ParseTopLevelDomainID(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTopLevelDomainIDInsensitively parses 'input' case-insensitively into a TopLevelDomainId +// note: this method should only be used for API response data and not user input +func ParseTopLevelDomainIDInsensitively(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TopLevelDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.TopLevelDomainName, ok = input.Parsed["topLevelDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "topLevelDomainName", input) + } + + return nil +} + +// ValidateTopLevelDomainID checks that 'input' can be parsed as a Top Level Domain ID +func ValidateTopLevelDomainID(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 := ParseTopLevelDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Top Level Domain ID +func (id TopLevelDomainId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DomainRegistration/topLevelDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.TopLevelDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Top Level Domain ID +func (id TopLevelDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticTopLevelDomains", "topLevelDomains", "topLevelDomains"), + resourceids.UserSpecifiedSegment("topLevelDomainName", "topLevelDomainName"), + } +} + +// String returns a human-readable description of this Top Level Domain ID +func (id TopLevelDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Top Level Domain Name: %q", id.TopLevelDomainName), + } + return fmt.Sprintf("Top Level Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain_test.go b/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain_test.go new file mode 100644 index 00000000000..11f286ac04e --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/id_topleveldomain_test.go @@ -0,0 +1,237 @@ +package topleveldomains + +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 = &TopLevelDomainId{} + +func TestNewTopLevelDomainID(t *testing.T) { + id := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + + 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.TopLevelDomainName != "topLevelDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'TopLevelDomainName'", id.TopLevelDomainName, "topLevelDomainName") + } +} + +func TestFormatTopLevelDomainID(t *testing.T) { + actual := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTopLevelDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainID(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.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestParseTopLevelDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNnAmE", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "tOpLeVeLdOmAiNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainIDInsensitively(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.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestSegmentsForTopLevelDomainId(t *testing.T) { + segments := TopLevelDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TopLevelDomainId 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/web/2024-04-01/topleveldomains/method_get.go b/resource-manager/web/2024-04-01/topleveldomains/method_get.go new file mode 100644 index 00000000000..b9320d14b1f --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/method_get.go @@ -0,0 +1,53 @@ +package topleveldomains + +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 *TopLevelDomain +} + +// Get ... +func (c TopLevelDomainsClient) Get(ctx context.Context, id TopLevelDomainId) (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 + } + + var model TopLevelDomain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/method_list.go b/resource-manager/web/2024-04-01/topleveldomains/method_list.go new file mode 100644 index 00000000000..3047b40a525 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/method_list.go @@ -0,0 +1,106 @@ +package topleveldomains + +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 *[]TopLevelDomain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TopLevelDomain +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c TopLevelDomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/topLevelDomains", 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 *[]TopLevelDomain `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 TopLevelDomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, TopLevelDomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TopLevelDomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]TopLevelDomain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/topleveldomains/method_listagreements.go b/resource-manager/web/2024-04-01/topleveldomains/method_listagreements.go new file mode 100644 index 00000000000..aef7718cae9 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/method_listagreements.go @@ -0,0 +1,105 @@ +package topleveldomains + +import ( + "context" + "fmt" + "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 ListAgreementsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TldLegalAgreement +} + +type ListAgreementsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TldLegalAgreement +} + +type ListAgreementsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAgreementsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAgreements ... +func (c TopLevelDomainsClient) ListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (result ListAgreementsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAgreementsCustomPager{}, + Path: fmt.Sprintf("%s/listAgreements", 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 *[]TldLegalAgreement `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAgreementsComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListAgreementsComplete(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (ListAgreementsCompleteResult, error) { + return c.ListAgreementsCompleteMatchingPredicate(ctx, id, input, TldLegalAgreementOperationPredicate{}) +} + +// ListAgreementsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListAgreementsCompleteMatchingPredicate(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption, predicate TldLegalAgreementOperationPredicate) (result ListAgreementsCompleteResult, err error) { + items := make([]TldLegalAgreement, 0) + + resp, err := c.ListAgreements(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListAgreementsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/model_tldlegalagreement.go b/resource-manager/web/2024-04-01/topleveldomains/model_tldlegalagreement.go new file mode 100644 index 00000000000..7efd744d882 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/model_tldlegalagreement.go @@ -0,0 +1,11 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreement struct { + AgreementKey string `json:"agreementKey"` + Content string `json:"content"` + Title string `json:"title"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomain.go b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomain.go new file mode 100644 index 00000000000..88855d8e294 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomain.go @@ -0,0 +1,12 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TopLevelDomainProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainagreementoption.go b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainagreementoption.go new file mode 100644 index 00000000000..f39158b5cbc --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainagreementoption.go @@ -0,0 +1,9 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainAgreementOption struct { + ForTransfer *bool `json:"forTransfer,omitempty"` + IncludePrivacy *bool `json:"includePrivacy,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainproperties.go b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainproperties.go new file mode 100644 index 00000000000..9e205230463 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/model_topleveldomainproperties.go @@ -0,0 +1,8 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainProperties struct { + Privacy *bool `json:"privacy,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/topleveldomains/predicates.go b/resource-manager/web/2024-04-01/topleveldomains/predicates.go new file mode 100644 index 00000000000..a85c5378eeb --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/predicates.go @@ -0,0 +1,60 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreementOperationPredicate struct { + AgreementKey *string + Content *string + Title *string + Url *string +} + +func (p TldLegalAgreementOperationPredicate) Matches(input TldLegalAgreement) bool { + + if p.AgreementKey != nil && *p.AgreementKey != input.AgreementKey { + return false + } + + if p.Content != nil && *p.Content != input.Content { + return false + } + + if p.Title != nil && *p.Title != input.Title { + return false + } + + if p.Url != nil && (input.Url == nil || *p.Url != *input.Url) { + return false + } + + return true +} + +type TopLevelDomainOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TopLevelDomainOperationPredicate) Matches(input TopLevelDomain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2024-04-01/topleveldomains/version.go b/resource-manager/web/2024-04-01/topleveldomains/version.go new file mode 100644 index 00000000000..60295d672b8 --- /dev/null +++ b/resource-manager/web/2024-04-01/topleveldomains/version.go @@ -0,0 +1,10 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/topleveldomains/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/webapps/README.md b/resource-manager/web/2024-04-01/webapps/README.md new file mode 100644 index 00000000000..444a22e9d96 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/README.md @@ -0,0 +1,7069 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/webapps` Documentation + +The `webapps` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/webapps" +``` + + +### Client Initialization + +```go +client := webapps.NewWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostname` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.AnalyzeCustomHostname(ctx, id, webapps.DefaultAnalyzeCustomHostnameOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostnameSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.AnalyzeCustomHostnameSlot(ctx, id, webapps.DefaultAnalyzeCustomHostnameSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigToProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigToProduction(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.Backup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.Backup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.BackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.BackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeployment(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeploymentSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateFunctionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateInstanceFunctionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperation` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOneDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.CreateOneDeployOperation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBinding(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBindingSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainer(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainerSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Delete(ctx, id, webapps.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackup` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +read, err := client.DeleteBackup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +read, err := client.DeleteBackupSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.DeleteContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.DeleteContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.DeleteDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.DeleteDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +read, err := client.DeleteDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +read, err := client.DeleteDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.DeleteFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + +read, err := client.DeleteFunctionSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + +read, err := client.DeleteFunctionSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +read, err := client.DeleteHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +read, err := client.DeleteHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + +read, err := client.DeleteHostSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + +read, err := client.DeleteHostSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.DeleteInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.DeleteInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.DeleteInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +read, err := client.DeletePremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +read, err := client.DeletePremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.DeleteProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.DeleteProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +read, err := client.DeletePublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +read, err := client.DeletePublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +read, err := client.DeleteRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +read, err := client.DeleteRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +read, err := client.DeleteSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +read, err := client.DeleteSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +read, err := client.DeleteSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +read, err := client.DeleteSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSlot(ctx, id, webapps.DefaultDeleteSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteSourceControl(ctx, id, webapps.DefaultDeleteSourceControlOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSourceControlSlot(ctx, id, webapps.DefaultDeleteSourceControlSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetwork` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteSwiftVirtualNetwork(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetworkSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSwiftVirtualNetworkSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.DeleteTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.DeleteTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +read, err := client.DeleteVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +read, err := client.DeleteVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifacts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifacts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifactsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifactsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPassword` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GenerateNewSitePublishingPassword(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPasswordSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GenerateNewSitePublishingPasswordSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +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: `WebAppsClient.GetAppSettingKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey") + +read, err := client.GetAppSettingKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey") + +read, err := client.GetAppSettingKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetAppSettingsKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetAppSettingsKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettingsV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsV2Slot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettingsV2WithoutSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsV2WithoutSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatus` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +read, err := client.GetBackupStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +read, err := client.GetBackupStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + +read, err := client.GetConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + +read, err := client.GetConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZip` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetContainerLogsZip(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZipSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetContainerLogsZipSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.GetContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.GetContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.GetDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.GetDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetDiagnosticLogsConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetDiagnosticLogsConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +read, err := client.GetDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +read, err := client.GetDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetFtpAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetFtpAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.GetFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminToken` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetFunctionsAdminToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminTokenSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetFunctionsAdminTokenSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +read, err := client.GetHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +read, err := client.GetHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.GetInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfo` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceInfoSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLog` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatus` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceMsDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceMsDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.GetInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.GetInstanceProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.GetInstanceProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName") + +read, err := client.GetInstanceProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName") + +read, err := client.GetInstanceProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.GetInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceWorkflowSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName") + +read, err := client.GetInstanceWorkflowSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLog` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMSDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMSDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMigrateMySqlStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMigrateMySqlStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTraces` + +```go +ctx := context.TODO() +id := webapps.NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + +read, err := client.GetNetworkTraces(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + +read, err := client.GetNetworkTracesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlotV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + +read, err := client.GetNetworkTracesSlotV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + +read, err := client.GetNetworkTracesV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetOneDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetOneDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +read, err := client.GetPremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +read, err := client.GetPremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccess` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetPrivateAccess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetPrivateAccessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionListSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetPrivateEndpointConnectionListSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResourcesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetPrivateLinkResourcesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.GetProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.GetProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.GetProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName") + +read, err := client.GetProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName") + +read, err := client.GetProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.GetProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +read, err := client.GetPublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +read, err := client.GetPublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +read, err := client.GetRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +read, err := client.GetRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetScmAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetScmAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey") + +read, err := client.GetSiteConnectionStringKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey") + +read, err := client.GetSiteConnectionStringKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +read, err := client.GetSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +read, err := client.GetSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +read, err := client.GetSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +read, err := client.GetSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlag` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSitePhpErrorLogFlag(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlagSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSitePhpErrorLogFlagSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSourceControlSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnection` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSwiftVirtualNetworkConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.GetTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName") + +read, err := client.GetTriggeredWebJobHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName") + +read, err := client.GetTriggeredWebJobHistorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.GetTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +read, err := client.GetVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetConnectionGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetConnectionGatewaySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +read, err := client.GetVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJob` + +```go +ctx := context.TODO() +id := webapps.NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName") + +read, err := client.GetWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName") + +read, err := client.GetWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetWebSiteContainerLogs(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetWebSiteContainerLogsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWorkflow` + +```go +ctx := context.TODO() +id := webapps.NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +read, err := client.GetWorkflow(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +if err := client.InstallSiteExtensionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +if err := client.InstallSiteExtensionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.IsCloneable` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.IsCloneable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.IsCloneableSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.IsCloneableSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `WebAppsClient.ListApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListApplicationSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListApplicationSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListAzureStorageAccounts(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListAzureStorageAccountsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecrets` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPolicies` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBasicPublishingCredentialsPolicies(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPoliciesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBasicPublishingCredentialsPoliciesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, webapps.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, webapps.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListConfigurationSnapshotInfo(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListConfigurationSnapshotInfoSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListConfigurations(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListConfigurationsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListConnectionStrings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListConnectionStringsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListContinuousWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListContinuousWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLog` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.ListDeploymentLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.ListDeploymentLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeployments` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListDeployments(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListDeploymentsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListDomainOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListDomainOwnershipIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeys` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.ListFunctionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.ListFunctionKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecrets` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.ListFunctionSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.ListFunctionSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeys` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListHostKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListHostKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListHostNameBindings(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListHostNameBindingsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListHybridConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListHybridConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceFunctionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceFunctionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListInstanceIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcesses` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +// alternatively `client.ListInstanceProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +// alternatively `client.ListInstanceProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceWorkflowsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceWorkflowsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceWorkflowsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListMetadata(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListMetadataSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeatures` + +```go +ctx := context.TODO() +id := webapps.NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName") + +read, err := client.ListNetworkFeatures(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeaturesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName") + +read, err := client.ListNetworkFeaturesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCounters` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListPerfMonCounters(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersComplete(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCountersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListPerfMonCountersSlot(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersSlotComplete(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOns` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListPremierAddOns(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOnsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListPremierAddOnsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +// alternatively `client.ListProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +// alternatively `client.ListProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +// alternatively `client.ListProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +// alternatively `client.ListProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcesses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProductionSiteDeploymentStatuses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListProductionSiteDeploymentStatuses(ctx, id)` can be used to do batched pagination +items, err := client.ListProductionSiteDeploymentStatusesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificates` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListPublicCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificatesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListPublicCertificatesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentials` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.ListPublishingCredentialsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentialsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.ListPublishingCredentialsSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListRelayServiceConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListRelayServiceConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteContainersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteExtensions(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteExtensionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSitePushSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSitePushSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSlotConfigurationNames(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesFromProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesFromProduction(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesFromProductionComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesSlot(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesSlotComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotSiteDeploymentStatusesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSlotSiteDeploymentStatusesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotSiteDeploymentStatusesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSlots(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSnapshots(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondary` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSnapshotsFromDRSecondary(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondaryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondarySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSnapshotsFromDRSecondarySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondarySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSnapshotsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSyncStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSyncStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +// alternatively `client.ListTriggeredWebJobHistory(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistoryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +// alternatively `client.ListTriggeredWebJobHistorySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistorySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListTriggeredWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListTriggeredWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListUsages(ctx, id, webapps.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, webapps.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsagesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListUsagesSlot(ctx, id, webapps.DefaultListUsagesSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesSlotComplete(ctx, id, webapps.DefaultListUsagesSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListVnetConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListVnetConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflows` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListWorkflows(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkflowsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListWorkflowsConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListWorkflowsConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.MigrateMySql` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.MigrateMySqlRequest{ + // ... +} + + +if err := client.MigrateMySqlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.MigrateStorage` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StorageMigrationOptions{ + // ... +} + + +if err := client.MigrateStorageThenPoll(ctx, id, payload, webapps.DefaultMigrateStorageOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnetSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + +read, err := client.RecoverSiteConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + +read, err := client.RecoverSiteConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetProductionSlotConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ResetProductionSlotConfig(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetSlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ResetSlotConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restart` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Restart(ctx, id, webapps.DefaultRestartOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RestartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.RestartSlot(ctx, id, webapps.DefaultRestartSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restore` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlob` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedAppSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.RunTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.RunTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Start(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.StartContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.StartContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.StartNetworkTraceThenPoll(ctx, id, webapps.DefaultStartNetworkTraceOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.StartNetworkTraceSlotThenPoll(ctx, id, webapps.DefaultStartNetworkTraceSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StartSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StartWebSiteNetworkTrace(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.StartWebSiteNetworkTraceOperationThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.StartWebSiteNetworkTraceOperationSlotThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StartWebSiteNetworkTraceSlot(ctx, id, webapps.DefaultStartWebSiteNetworkTraceSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Stop(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.StopContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.StopContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StopNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StopWebSiteNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopWebSiteNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotWithProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotWithProductionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncFunctions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncFunctionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepository` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncRepository(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepositorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncRepositorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2Slot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccounts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccountsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStrings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStringsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfig(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfigSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfigSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMachineKey` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.UpdateMachineKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadata(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadataSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.UpdateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SlotConfigNamesResource{ + // ... +} + + +read, err := client.UpdateSlotConfigurationNames(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControlSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/webapps/client.go b/resource-manager/web/2024-04-01/webapps/client.go new file mode 100644 index 00000000000..cfd22cd9b25 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/client.go @@ -0,0 +1,26 @@ +package webapps + +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 WebAppsClient struct { + Client *resourcemanager.Client +} + +func NewWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*WebAppsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebAppsClient: %+v", err) + } + + return &WebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/webapps/constants.go b/resource-manager/web/2024-04-01/webapps/constants.go new file mode 100644 index 00000000000..53593142f69 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/constants.go @@ -0,0 +1,2819 @@ +package webapps + +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 AuthType string + +const ( + AuthTypeAnonymous AuthType = "Anonymous" + AuthTypeSystemIdentity AuthType = "SystemIdentity" + AuthTypeUserAssigned AuthType = "UserAssigned" + AuthTypeUserCredentials AuthType = "UserCredentials" +) + +func PossibleValuesForAuthType() []string { + return []string{ + string(AuthTypeAnonymous), + string(AuthTypeSystemIdentity), + string(AuthTypeUserAssigned), + string(AuthTypeUserCredentials), + } +} + +func (s *AuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthType(input string) (*AuthType, error) { + vals := map[string]AuthType{ + "anonymous": AuthTypeAnonymous, + "systemidentity": AuthTypeSystemIdentity, + "userassigned": AuthTypeUserAssigned, + "usercredentials": AuthTypeUserCredentials, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthType(input) + return &out, nil +} + +type AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type BackupItemStatus string + +const ( + BackupItemStatusCreated BackupItemStatus = "Created" + BackupItemStatusDeleteFailed BackupItemStatus = "DeleteFailed" + BackupItemStatusDeleteInProgress BackupItemStatus = "DeleteInProgress" + BackupItemStatusDeleted BackupItemStatus = "Deleted" + BackupItemStatusFailed BackupItemStatus = "Failed" + BackupItemStatusInProgress BackupItemStatus = "InProgress" + BackupItemStatusPartiallySucceeded BackupItemStatus = "PartiallySucceeded" + BackupItemStatusSkipped BackupItemStatus = "Skipped" + BackupItemStatusSucceeded BackupItemStatus = "Succeeded" + BackupItemStatusTimedOut BackupItemStatus = "TimedOut" +) + +func PossibleValuesForBackupItemStatus() []string { + return []string{ + string(BackupItemStatusCreated), + string(BackupItemStatusDeleteFailed), + string(BackupItemStatusDeleteInProgress), + string(BackupItemStatusDeleted), + string(BackupItemStatusFailed), + string(BackupItemStatusInProgress), + string(BackupItemStatusPartiallySucceeded), + string(BackupItemStatusSkipped), + string(BackupItemStatusSucceeded), + string(BackupItemStatusTimedOut), + } +} + +func (s *BackupItemStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupItemStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupItemStatus(input string) (*BackupItemStatus, error) { + vals := map[string]BackupItemStatus{ + "created": BackupItemStatusCreated, + "deletefailed": BackupItemStatusDeleteFailed, + "deleteinprogress": BackupItemStatusDeleteInProgress, + "deleted": BackupItemStatusDeleted, + "failed": BackupItemStatusFailed, + "inprogress": BackupItemStatusInProgress, + "partiallysucceeded": BackupItemStatusPartiallySucceeded, + "skipped": BackupItemStatusSkipped, + "succeeded": BackupItemStatusSucceeded, + "timedout": BackupItemStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemStatus(input) + return &out, nil +} + +type BackupRestoreOperationType string + +const ( + BackupRestoreOperationTypeClone BackupRestoreOperationType = "Clone" + BackupRestoreOperationTypeCloudFS BackupRestoreOperationType = "CloudFS" + BackupRestoreOperationTypeDefault BackupRestoreOperationType = "Default" + BackupRestoreOperationTypeRelocation BackupRestoreOperationType = "Relocation" + BackupRestoreOperationTypeSnapshot BackupRestoreOperationType = "Snapshot" +) + +func PossibleValuesForBackupRestoreOperationType() []string { + return []string{ + string(BackupRestoreOperationTypeClone), + string(BackupRestoreOperationTypeCloudFS), + string(BackupRestoreOperationTypeDefault), + string(BackupRestoreOperationTypeRelocation), + string(BackupRestoreOperationTypeSnapshot), + } +} + +func (s *BackupRestoreOperationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationType(input string) (*BackupRestoreOperationType, error) { + vals := map[string]BackupRestoreOperationType{ + "clone": BackupRestoreOperationTypeClone, + "cloudfs": BackupRestoreOperationTypeCloudFS, + "default": BackupRestoreOperationTypeDefault, + "relocation": BackupRestoreOperationTypeRelocation, + "snapshot": BackupRestoreOperationTypeSnapshot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationType(input) + return &out, nil +} + +type BuiltInAuthenticationProvider string + +const ( + BuiltInAuthenticationProviderAzureActiveDirectory BuiltInAuthenticationProvider = "AzureActiveDirectory" + BuiltInAuthenticationProviderFacebook BuiltInAuthenticationProvider = "Facebook" + BuiltInAuthenticationProviderGithub BuiltInAuthenticationProvider = "Github" + BuiltInAuthenticationProviderGoogle BuiltInAuthenticationProvider = "Google" + BuiltInAuthenticationProviderMicrosoftAccount BuiltInAuthenticationProvider = "MicrosoftAccount" + BuiltInAuthenticationProviderTwitter BuiltInAuthenticationProvider = "Twitter" +) + +func PossibleValuesForBuiltInAuthenticationProvider() []string { + return []string{ + string(BuiltInAuthenticationProviderAzureActiveDirectory), + string(BuiltInAuthenticationProviderFacebook), + string(BuiltInAuthenticationProviderGithub), + string(BuiltInAuthenticationProviderGoogle), + string(BuiltInAuthenticationProviderMicrosoftAccount), + string(BuiltInAuthenticationProviderTwitter), + } +} + +func (s *BuiltInAuthenticationProvider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuiltInAuthenticationProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuiltInAuthenticationProvider(input string) (*BuiltInAuthenticationProvider, error) { + vals := map[string]BuiltInAuthenticationProvider{ + "azureactivedirectory": BuiltInAuthenticationProviderAzureActiveDirectory, + "facebook": BuiltInAuthenticationProviderFacebook, + "github": BuiltInAuthenticationProviderGithub, + "google": BuiltInAuthenticationProviderGoogle, + "microsoftaccount": BuiltInAuthenticationProviderMicrosoftAccount, + "twitter": BuiltInAuthenticationProviderTwitter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuiltInAuthenticationProvider(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ClientCredentialMethod string + +const ( + ClientCredentialMethodClientSecretPost ClientCredentialMethod = "ClientSecretPost" +) + +func PossibleValuesForClientCredentialMethod() []string { + return []string{ + string(ClientCredentialMethodClientSecretPost), + } +} + +func (s *ClientCredentialMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCredentialMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCredentialMethod(input string) (*ClientCredentialMethod, error) { + vals := map[string]ClientCredentialMethod{ + "clientsecretpost": ClientCredentialMethodClientSecretPost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCredentialMethod(input) + return &out, nil +} + +type CloneAbilityResult string + +const ( + CloneAbilityResultCloneable CloneAbilityResult = "Cloneable" + CloneAbilityResultNotCloneable CloneAbilityResult = "NotCloneable" + CloneAbilityResultPartiallyCloneable CloneAbilityResult = "PartiallyCloneable" +) + +func PossibleValuesForCloneAbilityResult() []string { + return []string{ + string(CloneAbilityResultCloneable), + string(CloneAbilityResultNotCloneable), + string(CloneAbilityResultPartiallyCloneable), + } +} + +func (s *CloneAbilityResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloneAbilityResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloneAbilityResult(input string) (*CloneAbilityResult, error) { + vals := map[string]CloneAbilityResult{ + "cloneable": CloneAbilityResultCloneable, + "notcloneable": CloneAbilityResultNotCloneable, + "partiallycloneable": CloneAbilityResultPartiallyCloneable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloneAbilityResult(input) + return &out, nil +} + +type ConfigReferenceSource string + +const ( + ConfigReferenceSourceKeyVault ConfigReferenceSource = "KeyVault" +) + +func PossibleValuesForConfigReferenceSource() []string { + return []string{ + string(ConfigReferenceSourceKeyVault), + } +} + +func (s *ConfigReferenceSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigReferenceSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConfigReferenceSource(input string) (*ConfigReferenceSource, error) { + vals := map[string]ConfigReferenceSource{ + "keyvault": ConfigReferenceSourceKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConfigReferenceSource(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type ContinuousWebJobStatus string + +const ( + ContinuousWebJobStatusInitializing ContinuousWebJobStatus = "Initializing" + ContinuousWebJobStatusPendingRestart ContinuousWebJobStatus = "PendingRestart" + ContinuousWebJobStatusRunning ContinuousWebJobStatus = "Running" + ContinuousWebJobStatusStarting ContinuousWebJobStatus = "Starting" + ContinuousWebJobStatusStopped ContinuousWebJobStatus = "Stopped" +) + +func PossibleValuesForContinuousWebJobStatus() []string { + return []string{ + string(ContinuousWebJobStatusInitializing), + string(ContinuousWebJobStatusPendingRestart), + string(ContinuousWebJobStatusRunning), + string(ContinuousWebJobStatusStarting), + string(ContinuousWebJobStatusStopped), + } +} + +func (s *ContinuousWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContinuousWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContinuousWebJobStatus(input string) (*ContinuousWebJobStatus, error) { + vals := map[string]ContinuousWebJobStatus{ + "initializing": ContinuousWebJobStatusInitializing, + "pendingrestart": ContinuousWebJobStatusPendingRestart, + "running": ContinuousWebJobStatusRunning, + "starting": ContinuousWebJobStatusStarting, + "stopped": ContinuousWebJobStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContinuousWebJobStatus(input) + return &out, nil +} + +type CookieExpirationConvention string + +const ( + CookieExpirationConventionFixedTime CookieExpirationConvention = "FixedTime" + CookieExpirationConventionIdentityProviderDerived CookieExpirationConvention = "IdentityProviderDerived" +) + +func PossibleValuesForCookieExpirationConvention() []string { + return []string{ + string(CookieExpirationConventionFixedTime), + string(CookieExpirationConventionIdentityProviderDerived), + } +} + +func (s *CookieExpirationConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookieExpirationConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookieExpirationConvention(input string) (*CookieExpirationConvention, error) { + vals := map[string]CookieExpirationConvention{ + "fixedtime": CookieExpirationConventionFixedTime, + "identityproviderderived": CookieExpirationConventionIdentityProviderDerived, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookieExpirationConvention(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DatabaseType string + +const ( + DatabaseTypeLocalMySql DatabaseType = "LocalMySql" + DatabaseTypeMySql DatabaseType = "MySql" + DatabaseTypePostgreSql DatabaseType = "PostgreSql" + DatabaseTypeSqlAzure DatabaseType = "SqlAzure" +) + +func PossibleValuesForDatabaseType() []string { + return []string{ + string(DatabaseTypeLocalMySql), + string(DatabaseTypeMySql), + string(DatabaseTypePostgreSql), + string(DatabaseTypeSqlAzure), + } +} + +func (s *DatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseType(input string) (*DatabaseType, error) { + vals := map[string]DatabaseType{ + "localmysql": DatabaseTypeLocalMySql, + "mysql": DatabaseTypeMySql, + "postgresql": DatabaseTypePostgreSql, + "sqlazure": DatabaseTypeSqlAzure, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseType(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type DeploymentBuildStatus string + +const ( + DeploymentBuildStatusBuildAborted DeploymentBuildStatus = "BuildAborted" + DeploymentBuildStatusBuildFailed DeploymentBuildStatus = "BuildFailed" + DeploymentBuildStatusBuildInProgress DeploymentBuildStatus = "BuildInProgress" + DeploymentBuildStatusBuildPending DeploymentBuildStatus = "BuildPending" + DeploymentBuildStatusBuildRequestReceived DeploymentBuildStatus = "BuildRequestReceived" + DeploymentBuildStatusBuildSuccessful DeploymentBuildStatus = "BuildSuccessful" + DeploymentBuildStatusPostBuildRestartRequired DeploymentBuildStatus = "PostBuildRestartRequired" + DeploymentBuildStatusRuntimeFailed DeploymentBuildStatus = "RuntimeFailed" + DeploymentBuildStatusRuntimeStarting DeploymentBuildStatus = "RuntimeStarting" + DeploymentBuildStatusRuntimeSuccessful DeploymentBuildStatus = "RuntimeSuccessful" + DeploymentBuildStatusStartPolling DeploymentBuildStatus = "StartPolling" + DeploymentBuildStatusStartPollingWithRestart DeploymentBuildStatus = "StartPollingWithRestart" + DeploymentBuildStatusTimedOut DeploymentBuildStatus = "TimedOut" +) + +func PossibleValuesForDeploymentBuildStatus() []string { + return []string{ + string(DeploymentBuildStatusBuildAborted), + string(DeploymentBuildStatusBuildFailed), + string(DeploymentBuildStatusBuildInProgress), + string(DeploymentBuildStatusBuildPending), + string(DeploymentBuildStatusBuildRequestReceived), + string(DeploymentBuildStatusBuildSuccessful), + string(DeploymentBuildStatusPostBuildRestartRequired), + string(DeploymentBuildStatusRuntimeFailed), + string(DeploymentBuildStatusRuntimeStarting), + string(DeploymentBuildStatusRuntimeSuccessful), + string(DeploymentBuildStatusStartPolling), + string(DeploymentBuildStatusStartPollingWithRestart), + string(DeploymentBuildStatusTimedOut), + } +} + +func (s *DeploymentBuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentBuildStatus(input string) (*DeploymentBuildStatus, error) { + vals := map[string]DeploymentBuildStatus{ + "buildaborted": DeploymentBuildStatusBuildAborted, + "buildfailed": DeploymentBuildStatusBuildFailed, + "buildinprogress": DeploymentBuildStatusBuildInProgress, + "buildpending": DeploymentBuildStatusBuildPending, + "buildrequestreceived": DeploymentBuildStatusBuildRequestReceived, + "buildsuccessful": DeploymentBuildStatusBuildSuccessful, + "postbuildrestartrequired": DeploymentBuildStatusPostBuildRestartRequired, + "runtimefailed": DeploymentBuildStatusRuntimeFailed, + "runtimestarting": DeploymentBuildStatusRuntimeStarting, + "runtimesuccessful": DeploymentBuildStatusRuntimeSuccessful, + "startpolling": DeploymentBuildStatusStartPolling, + "startpollingwithrestart": DeploymentBuildStatusStartPollingWithRestart, + "timedout": DeploymentBuildStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentBuildStatus(input) + return &out, nil +} + +type DnsVerificationTestResult string + +const ( + DnsVerificationTestResultFailed DnsVerificationTestResult = "Failed" + DnsVerificationTestResultPassed DnsVerificationTestResult = "Passed" + DnsVerificationTestResultSkipped DnsVerificationTestResult = "Skipped" +) + +func PossibleValuesForDnsVerificationTestResult() []string { + return []string{ + string(DnsVerificationTestResultFailed), + string(DnsVerificationTestResultPassed), + string(DnsVerificationTestResultSkipped), + } +} + +func (s *DnsVerificationTestResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsVerificationTestResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsVerificationTestResult(input string) (*DnsVerificationTestResult, error) { + vals := map[string]DnsVerificationTestResult{ + "failed": DnsVerificationTestResultFailed, + "passed": DnsVerificationTestResultPassed, + "skipped": DnsVerificationTestResultSkipped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsVerificationTestResult(input) + return &out, nil +} + +type ForwardProxyConvention string + +const ( + ForwardProxyConventionCustom ForwardProxyConvention = "Custom" + ForwardProxyConventionNoProxy ForwardProxyConvention = "NoProxy" + ForwardProxyConventionStandard ForwardProxyConvention = "Standard" +) + +func PossibleValuesForForwardProxyConvention() []string { + return []string{ + string(ForwardProxyConventionCustom), + string(ForwardProxyConventionNoProxy), + string(ForwardProxyConventionStandard), + } +} + +func (s *ForwardProxyConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardProxyConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardProxyConvention(input string) (*ForwardProxyConvention, error) { + vals := map[string]ForwardProxyConvention{ + "custom": ForwardProxyConventionCustom, + "noproxy": ForwardProxyConventionNoProxy, + "standard": ForwardProxyConventionStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardProxyConvention(input) + return &out, nil +} + +type FrequencyUnit string + +const ( + FrequencyUnitDay FrequencyUnit = "Day" + FrequencyUnitHour FrequencyUnit = "Hour" +) + +func PossibleValuesForFrequencyUnit() []string { + return []string{ + string(FrequencyUnitDay), + string(FrequencyUnitHour), + } +} + +func (s *FrequencyUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrequencyUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrequencyUnit(input string) (*FrequencyUnit, error) { + vals := map[string]FrequencyUnit{ + "day": FrequencyUnitDay, + "hour": FrequencyUnitHour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrequencyUnit(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type LogLevel string + +const ( + LogLevelError LogLevel = "Error" + LogLevelInformation LogLevel = "Information" + LogLevelOff LogLevel = "Off" + LogLevelVerbose LogLevel = "Verbose" + LogLevelWarning LogLevel = "Warning" +) + +func PossibleValuesForLogLevel() []string { + return []string{ + string(LogLevelError), + string(LogLevelInformation), + string(LogLevelOff), + string(LogLevelVerbose), + string(LogLevelWarning), + } +} + +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogLevel(input string) (*LogLevel, error) { + vals := map[string]LogLevel{ + "error": LogLevelError, + "information": LogLevelInformation, + "off": LogLevelOff, + "verbose": LogLevelVerbose, + "warning": LogLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogLevel(input) + return &out, nil +} + +type MSDeployLogEntryType string + +const ( + MSDeployLogEntryTypeError MSDeployLogEntryType = "Error" + MSDeployLogEntryTypeMessage MSDeployLogEntryType = "Message" + MSDeployLogEntryTypeWarning MSDeployLogEntryType = "Warning" +) + +func PossibleValuesForMSDeployLogEntryType() []string { + return []string{ + string(MSDeployLogEntryTypeError), + string(MSDeployLogEntryTypeMessage), + string(MSDeployLogEntryTypeWarning), + } +} + +func (s *MSDeployLogEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployLogEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployLogEntryType(input string) (*MSDeployLogEntryType, error) { + vals := map[string]MSDeployLogEntryType{ + "error": MSDeployLogEntryTypeError, + "message": MSDeployLogEntryTypeMessage, + "warning": MSDeployLogEntryTypeWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployLogEntryType(input) + return &out, nil +} + +type MSDeployProvisioningState string + +const ( + MSDeployProvisioningStateAccepted MSDeployProvisioningState = "accepted" + MSDeployProvisioningStateCanceled MSDeployProvisioningState = "canceled" + MSDeployProvisioningStateFailed MSDeployProvisioningState = "failed" + MSDeployProvisioningStateRunning MSDeployProvisioningState = "running" + MSDeployProvisioningStateSucceeded MSDeployProvisioningState = "succeeded" +) + +func PossibleValuesForMSDeployProvisioningState() []string { + return []string{ + string(MSDeployProvisioningStateAccepted), + string(MSDeployProvisioningStateCanceled), + string(MSDeployProvisioningStateFailed), + string(MSDeployProvisioningStateRunning), + string(MSDeployProvisioningStateSucceeded), + } +} + +func (s *MSDeployProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployProvisioningState(input string) (*MSDeployProvisioningState, error) { + vals := map[string]MSDeployProvisioningState{ + "accepted": MSDeployProvisioningStateAccepted, + "canceled": MSDeployProvisioningStateCanceled, + "failed": MSDeployProvisioningStateFailed, + "running": MSDeployProvisioningStateRunning, + "succeeded": MSDeployProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployProvisioningState(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type MySqlMigrationType string + +const ( + MySqlMigrationTypeLocalToRemote MySqlMigrationType = "LocalToRemote" + MySqlMigrationTypeRemoteToLocal MySqlMigrationType = "RemoteToLocal" +) + +func PossibleValuesForMySqlMigrationType() []string { + return []string{ + string(MySqlMigrationTypeLocalToRemote), + string(MySqlMigrationTypeRemoteToLocal), + } +} + +func (s *MySqlMigrationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMySqlMigrationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMySqlMigrationType(input string) (*MySqlMigrationType, error) { + vals := map[string]MySqlMigrationType{ + "localtoremote": MySqlMigrationTypeLocalToRemote, + "remotetolocal": MySqlMigrationTypeRemoteToLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MySqlMigrationType(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type PublicCertificateLocation string + +const ( + PublicCertificateLocationCurrentUserMy PublicCertificateLocation = "CurrentUserMy" + PublicCertificateLocationLocalMachineMy PublicCertificateLocation = "LocalMachineMy" + PublicCertificateLocationUnknown PublicCertificateLocation = "Unknown" +) + +func PossibleValuesForPublicCertificateLocation() []string { + return []string{ + string(PublicCertificateLocationCurrentUserMy), + string(PublicCertificateLocationLocalMachineMy), + string(PublicCertificateLocationUnknown), + } +} + +func (s *PublicCertificateLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicCertificateLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicCertificateLocation(input string) (*PublicCertificateLocation, error) { + vals := map[string]PublicCertificateLocation{ + "currentusermy": PublicCertificateLocationCurrentUserMy, + "localmachinemy": PublicCertificateLocationLocalMachineMy, + "unknown": PublicCertificateLocationUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicCertificateLocation(input) + return &out, nil +} + +type PublishingProfileFormat string + +const ( + PublishingProfileFormatFileZillaThree PublishingProfileFormat = "FileZilla3" + PublishingProfileFormatFtp PublishingProfileFormat = "Ftp" + PublishingProfileFormatWebDeploy PublishingProfileFormat = "WebDeploy" +) + +func PossibleValuesForPublishingProfileFormat() []string { + return []string{ + string(PublishingProfileFormatFileZillaThree), + string(PublishingProfileFormatFtp), + string(PublishingProfileFormatWebDeploy), + } +} + +func (s *PublishingProfileFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublishingProfileFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublishingProfileFormat(input string) (*PublishingProfileFormat, error) { + vals := map[string]PublishingProfileFormat{ + "filezilla3": PublishingProfileFormatFileZillaThree, + "ftp": PublishingProfileFormatFtp, + "webdeploy": PublishingProfileFormatWebDeploy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublishingProfileFormat(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type ResolveStatus string + +const ( + ResolveStatusAccessToKeyVaultDenied ResolveStatus = "AccessToKeyVaultDenied" + ResolveStatusFetchTimedOut ResolveStatus = "FetchTimedOut" + ResolveStatusInitialized ResolveStatus = "Initialized" + ResolveStatusInvalidSyntax ResolveStatus = "InvalidSyntax" + ResolveStatusMSINotEnabled ResolveStatus = "MSINotEnabled" + ResolveStatusOtherReasons ResolveStatus = "OtherReasons" + ResolveStatusResolved ResolveStatus = "Resolved" + ResolveStatusSecretNotFound ResolveStatus = "SecretNotFound" + ResolveStatusSecretVersionNotFound ResolveStatus = "SecretVersionNotFound" + ResolveStatusUnauthorizedClient ResolveStatus = "UnauthorizedClient" + ResolveStatusVaultNotFound ResolveStatus = "VaultNotFound" +) + +func PossibleValuesForResolveStatus() []string { + return []string{ + string(ResolveStatusAccessToKeyVaultDenied), + string(ResolveStatusFetchTimedOut), + string(ResolveStatusInitialized), + string(ResolveStatusInvalidSyntax), + string(ResolveStatusMSINotEnabled), + string(ResolveStatusOtherReasons), + string(ResolveStatusResolved), + string(ResolveStatusSecretNotFound), + string(ResolveStatusSecretVersionNotFound), + string(ResolveStatusUnauthorizedClient), + string(ResolveStatusVaultNotFound), + } +} + +func (s *ResolveStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResolveStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResolveStatus(input string) (*ResolveStatus, error) { + vals := map[string]ResolveStatus{ + "accesstokeyvaultdenied": ResolveStatusAccessToKeyVaultDenied, + "fetchtimedout": ResolveStatusFetchTimedOut, + "initialized": ResolveStatusInitialized, + "invalidsyntax": ResolveStatusInvalidSyntax, + "msinotenabled": ResolveStatusMSINotEnabled, + "otherreasons": ResolveStatusOtherReasons, + "resolved": ResolveStatusResolved, + "secretnotfound": ResolveStatusSecretNotFound, + "secretversionnotfound": ResolveStatusSecretVersionNotFound, + "unauthorizedclient": ResolveStatusUnauthorizedClient, + "vaultnotfound": ResolveStatusVaultNotFound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResolveStatus(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteExtensionType string + +const ( + SiteExtensionTypeGallery SiteExtensionType = "Gallery" + SiteExtensionTypeWebRoot SiteExtensionType = "WebRoot" +) + +func PossibleValuesForSiteExtensionType() []string { + return []string{ + string(SiteExtensionTypeGallery), + string(SiteExtensionTypeWebRoot), + } +} + +func (s *SiteExtensionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteExtensionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteExtensionType(input string) (*SiteExtensionType, error) { + vals := map[string]SiteExtensionType{ + "gallery": SiteExtensionTypeGallery, + "webroot": SiteExtensionTypeWebRoot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteExtensionType(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SiteRuntimeState string + +const ( + SiteRuntimeStateREADY SiteRuntimeState = "READY" + SiteRuntimeStateSTOPPED SiteRuntimeState = "STOPPED" + SiteRuntimeStateUNKNOWN SiteRuntimeState = "UNKNOWN" +) + +func PossibleValuesForSiteRuntimeState() []string { + return []string{ + string(SiteRuntimeStateREADY), + string(SiteRuntimeStateSTOPPED), + string(SiteRuntimeStateUNKNOWN), + } +} + +func (s *SiteRuntimeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteRuntimeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteRuntimeState(input string) (*SiteRuntimeState, error) { + vals := map[string]SiteRuntimeState{ + "ready": SiteRuntimeStateREADY, + "stopped": SiteRuntimeStateSTOPPED, + "unknown": SiteRuntimeStateUNKNOWN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteRuntimeState(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type TriggeredWebJobStatus string + +const ( + TriggeredWebJobStatusError TriggeredWebJobStatus = "Error" + TriggeredWebJobStatusFailed TriggeredWebJobStatus = "Failed" + TriggeredWebJobStatusSuccess TriggeredWebJobStatus = "Success" +) + +func PossibleValuesForTriggeredWebJobStatus() []string { + return []string{ + string(TriggeredWebJobStatusError), + string(TriggeredWebJobStatusFailed), + string(TriggeredWebJobStatusSuccess), + } +} + +func (s *TriggeredWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggeredWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggeredWebJobStatus(input string) (*TriggeredWebJobStatus, error) { + vals := map[string]TriggeredWebJobStatus{ + "error": TriggeredWebJobStatusError, + "failed": TriggeredWebJobStatusFailed, + "success": TriggeredWebJobStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggeredWebJobStatus(input) + return &out, nil +} + +type UnauthenticatedClientAction string + +const ( + UnauthenticatedClientActionAllowAnonymous UnauthenticatedClientAction = "AllowAnonymous" + UnauthenticatedClientActionRedirectToLoginPage UnauthenticatedClientAction = "RedirectToLoginPage" +) + +func PossibleValuesForUnauthenticatedClientAction() []string { + return []string{ + string(UnauthenticatedClientActionAllowAnonymous), + string(UnauthenticatedClientActionRedirectToLoginPage), + } +} + +func (s *UnauthenticatedClientAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientAction(input string) (*UnauthenticatedClientAction, error) { + vals := map[string]UnauthenticatedClientAction{ + "allowanonymous": UnauthenticatedClientActionAllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionRedirectToLoginPage, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientAction(input) + return &out, nil +} + +type UnauthenticatedClientActionV2 string + +const ( + UnauthenticatedClientActionV2AllowAnonymous UnauthenticatedClientActionV2 = "AllowAnonymous" + UnauthenticatedClientActionV2RedirectToLoginPage UnauthenticatedClientActionV2 = "RedirectToLoginPage" + UnauthenticatedClientActionV2ReturnFourZeroOne UnauthenticatedClientActionV2 = "Return401" + UnauthenticatedClientActionV2ReturnFourZeroThree UnauthenticatedClientActionV2 = "Return403" +) + +func PossibleValuesForUnauthenticatedClientActionV2() []string { + return []string{ + string(UnauthenticatedClientActionV2AllowAnonymous), + string(UnauthenticatedClientActionV2RedirectToLoginPage), + string(UnauthenticatedClientActionV2ReturnFourZeroOne), + string(UnauthenticatedClientActionV2ReturnFourZeroThree), + } +} + +func (s *UnauthenticatedClientActionV2) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientActionV2(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientActionV2(input string) (*UnauthenticatedClientActionV2, error) { + vals := map[string]UnauthenticatedClientActionV2{ + "allowanonymous": UnauthenticatedClientActionV2AllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionV2RedirectToLoginPage, + "return401": UnauthenticatedClientActionV2ReturnFourZeroOne, + "return403": UnauthenticatedClientActionV2ReturnFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientActionV2(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WebJobType string + +const ( + WebJobTypeContinuous WebJobType = "Continuous" + WebJobTypeTriggered WebJobType = "Triggered" +) + +func PossibleValuesForWebJobType() []string { + return []string{ + string(WebJobTypeContinuous), + string(WebJobTypeTriggered), + } +} + +func (s *WebJobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebJobType(input string) (*WebJobType, error) { + vals := map[string]WebJobType{ + "continuous": WebJobTypeContinuous, + "triggered": WebJobTypeTriggered, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebJobType(input) + return &out, nil +} + +type WorkflowHealthState string + +const ( + WorkflowHealthStateHealthy WorkflowHealthState = "Healthy" + WorkflowHealthStateNotSpecified WorkflowHealthState = "NotSpecified" + WorkflowHealthStateUnhealthy WorkflowHealthState = "Unhealthy" + WorkflowHealthStateUnknown WorkflowHealthState = "Unknown" +) + +func PossibleValuesForWorkflowHealthState() []string { + return []string{ + string(WorkflowHealthStateHealthy), + string(WorkflowHealthStateNotSpecified), + string(WorkflowHealthStateUnhealthy), + string(WorkflowHealthStateUnknown), + } +} + +func (s *WorkflowHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowHealthState(input string) (*WorkflowHealthState, error) { + vals := map[string]WorkflowHealthState{ + "healthy": WorkflowHealthStateHealthy, + "notspecified": WorkflowHealthStateNotSpecified, + "unhealthy": WorkflowHealthStateUnhealthy, + "unknown": WorkflowHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowHealthState(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/webapps/id_appsetting.go b/resource-manager/web/2024-04-01/webapps/id_appsetting.go new file mode 100644 index 00000000000..ecd9386b62d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_appsetting.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&AppSettingId{}) +} + +var _ resourceids.ResourceId = &AppSettingId{} + +// AppSettingId is a struct representing the Resource ID for a App Setting +type AppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + AppSettingKey string +} + +// NewAppSettingID returns a new AppSettingId struct +func NewAppSettingID(subscriptionId string, resourceGroupName string, siteName string, appSettingKey string) AppSettingId { + return AppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + AppSettingKey: appSettingKey, + } +} + +// ParseAppSettingID parses 'input' into a AppSettingId +func ParseAppSettingID(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAppSettingIDInsensitively parses 'input' case-insensitively into a AppSettingId +// note: this method should only be used for API response data and not user input +func ParseAppSettingIDInsensitively(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AppSettingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateAppSettingID checks that 'input' can be parsed as a App Setting ID +func ValidateAppSettingID(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 := ParseAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted App Setting ID +func (id AppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this App Setting ID +func (id AppSettingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKey"), + } +} + +// String returns a human-readable description of this App Setting ID +func (id AppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_appsetting_test.go b/resource-manager/web/2024-04-01/webapps/id_appsetting_test.go new file mode 100644 index 00000000000..b7bbe12fe12 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_appsetting_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &AppSettingId{} + +func TestNewAppSettingID(t *testing.T) { + id := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.AppSettingKey != "appSettingKey" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKey") + } +} + +func TestFormatAppSettingID(t *testing.T) { + actual := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + AppSettingKey: "aPpSeTtInGkEy", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForAppSettingId(t *testing.T) { + segments := AppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AppSettingId 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/web/2024-04-01/webapps/id_backup.go b/resource-manager/web/2024-04-01/webapps/id_backup.go new file mode 100644 index 00000000000..84ecf422bfb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_backup.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&BackupId{}) +} + +var _ resourceids.ResourceId = &BackupId{} + +// BackupId is a struct representing the Resource ID for a Backup +type BackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + BackupId string +} + +// NewBackupID returns a new BackupId struct +func NewBackupID(subscriptionId string, resourceGroupName string, siteName string, backupId string) BackupId { + return BackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + BackupId: backupId, + } +} + +// ParseBackupID parses 'input' into a BackupId +func ParseBackupID(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupIDInsensitively parses 'input' case-insensitively into a BackupId +// note: this method should only be used for API response data and not user input +func ParseBackupIDInsensitively(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateBackupID checks that 'input' can be parsed as a Backup ID +func ValidateBackupID(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 := ParseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup ID +func (id BackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup ID +func (id BackupId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupId"), + } +} + +// String returns a human-readable description of this Backup ID +func (id BackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_backup_test.go b/resource-manager/web/2024-04-01/webapps/id_backup_test.go new file mode 100644 index 00000000000..5e0f8fc3dab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_backup_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &BackupId{} + +func TestNewBackupID(t *testing.T) { + id := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.BackupId != "backupId" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupId") + } +} + +func TestFormatBackupID(t *testing.T) { + actual := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/bAcKuPs/bAcKuPiD", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + BackupId: "bAcKuPiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/bAcKuPs/bAcKuPiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForBackupId(t *testing.T) { + segments := BackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupId 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/web/2024-04-01/webapps/id_configreferenceappsetting.go b/resource-manager/web/2024-04-01/webapps/id_configreferenceappsetting.go new file mode 100644 index 00000000000..0be15f20c3d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_configreferenceappsetting.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceAppSettingId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceAppSettingId{} + +// ConfigReferenceAppSettingId is a struct representing the Resource ID for a Config Reference App Setting +type ConfigReferenceAppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + AppSettingKey string +} + +// NewConfigReferenceAppSettingID returns a new ConfigReferenceAppSettingId struct +func NewConfigReferenceAppSettingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, appSettingKey string) ConfigReferenceAppSettingId { + return ConfigReferenceAppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + AppSettingKey: appSettingKey, + } +} + +// ParseConfigReferenceAppSettingID parses 'input' into a ConfigReferenceAppSettingId +func ParseConfigReferenceAppSettingID(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceAppSettingIDInsensitively parses 'input' case-insensitively into a ConfigReferenceAppSettingId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceAppSettingIDInsensitively(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceAppSettingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateConfigReferenceAppSettingID checks that 'input' can be parsed as a Config Reference App Setting ID +func ValidateConfigReferenceAppSettingID(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 := ParseConfigReferenceAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKey"), + } +} + +// String returns a human-readable description of this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("Config Reference App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_configreferenceappsetting_test.go b/resource-manager/web/2024-04-01/webapps/id_configreferenceappsetting_test.go new file mode 100644 index 00000000000..1b5073a3b78 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_configreferenceappsetting_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &ConfigReferenceAppSettingId{} + +func TestNewConfigReferenceAppSettingID(t *testing.T) { + id := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.AppSettingKey != "appSettingKey" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKey") + } +} + +func TestFormatConfigReferenceAppSettingID(t *testing.T) { + actual := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseConfigReferenceAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + AppSettingKey: "aPpSeTtInGkEy", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForConfigReferenceAppSettingId(t *testing.T) { + segments := ConfigReferenceAppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceAppSettingId 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/web/2024-04-01/webapps/id_configreferenceconnectionstring.go b/resource-manager/web/2024-04-01/webapps/id_configreferenceconnectionstring.go new file mode 100644 index 00000000000..63353893f7d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_configreferenceconnectionstring.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceConnectionStringId{} + +// ConfigReferenceConnectionStringId is a struct representing the Resource ID for a Config Reference Connection String +type ConfigReferenceConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ConnectionStringKey string +} + +// NewConfigReferenceConnectionStringID returns a new ConfigReferenceConnectionStringId struct +func NewConfigReferenceConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, slotName string, connectionStringKey string) ConfigReferenceConnectionStringId { + return ConfigReferenceConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConfigReferenceConnectionStringID parses 'input' into a ConfigReferenceConnectionStringId +func ParseConfigReferenceConnectionStringID(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceConnectionStringIDInsensitively parses 'input' case-insensitively into a ConfigReferenceConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceConnectionStringIDInsensitively(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceConnectionStringId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConfigReferenceConnectionStringID checks that 'input' can be parsed as a Config Reference Connection String ID +func ValidateConfigReferenceConnectionStringID(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 := ParseConfigReferenceConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKey"), + } +} + +// String returns a human-readable description of this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Config Reference Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_configreferenceconnectionstring_test.go b/resource-manager/web/2024-04-01/webapps/id_configreferenceconnectionstring_test.go new file mode 100644 index 00000000000..a18b81f139f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_configreferenceconnectionstring_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &ConfigReferenceConnectionStringId{} + +func TestNewConfigReferenceConnectionStringID(t *testing.T) { + id := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ConnectionStringKey != "connectionStringKey" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKey") + } +} + +func TestFormatConfigReferenceConnectionStringID(t *testing.T) { + actual := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConfigReferenceConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEy", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConfigReferenceConnectionStringId(t *testing.T) { + segments := ConfigReferenceConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceConnectionStringId 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/web/2024-04-01/webapps/id_connectionstring.go b/resource-manager/web/2024-04-01/webapps/id_connectionstring.go new file mode 100644 index 00000000000..5282e76e282 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_connectionstring.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConnectionStringId{} + +// ConnectionStringId is a struct representing the Resource ID for a Connection String +type ConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ConnectionStringKey string +} + +// NewConnectionStringID returns a new ConnectionStringId struct +func NewConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, connectionStringKey string) ConnectionStringId { + return ConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConnectionStringID parses 'input' into a ConnectionStringId +func ParseConnectionStringID(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionStringIDInsensitively parses 'input' case-insensitively into a ConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConnectionStringIDInsensitively(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionStringId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConnectionStringID checks that 'input' can be parsed as a Connection String ID +func ValidateConnectionStringID(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 := ParseConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection String ID +func (id ConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection String ID +func (id ConnectionStringId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKey"), + } +} + +// String returns a human-readable description of this Connection String ID +func (id ConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_connectionstring_test.go b/resource-manager/web/2024-04-01/webapps/id_connectionstring_test.go new file mode 100644 index 00000000000..c4310a2bd0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_connectionstring_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &ConnectionStringId{} + +func TestNewConnectionStringID(t *testing.T) { + id := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ConnectionStringKey != "connectionStringKey" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKey") + } +} + +func TestFormatConnectionStringID(t *testing.T) { + actual := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEy", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConnectionStringId(t *testing.T) { + segments := ConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionStringId 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/web/2024-04-01/webapps/id_continuouswebjob.go b/resource-manager/web/2024-04-01/webapps/id_continuouswebjob.go new file mode 100644 index 00000000000..b25215a56ac --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_continuouswebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &ContinuousWebJobId{} + +// ContinuousWebJobId is a struct representing the Resource ID for a Continuous Web Job +type ContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ContinuousWebJobName string +} + +// NewContinuousWebJobID returns a new ContinuousWebJobId struct +func NewContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, continuousWebJobName string) ContinuousWebJobId { + return ContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseContinuousWebJobID parses 'input' into a ContinuousWebJobId +func ParseContinuousWebJobID(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContinuousWebJobIDInsensitively parses 'input' case-insensitively into a ContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseContinuousWebJobIDInsensitively(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContinuousWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateContinuousWebJobID checks that 'input' can be parsed as a Continuous Web Job ID +func ValidateContinuousWebJobID(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 := ParseContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Continuous Web Job ID +func (id ContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Continuous Web Job ID +func (id ContinuousWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobName"), + } +} + +// String returns a human-readable description of this Continuous Web Job ID +func (id ContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_continuouswebjob_test.go b/resource-manager/web/2024-04-01/webapps/id_continuouswebjob_test.go new file mode 100644 index 00000000000..9dbfdc97ffc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_continuouswebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &ContinuousWebJobId{} + +func TestNewContinuousWebJobID(t *testing.T) { + id := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ContinuousWebJobName != "continuousWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobName") + } +} + +func TestFormatContinuousWebJobID(t *testing.T) { + actual := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForContinuousWebJobId(t *testing.T) { + segments := ContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContinuousWebJobId 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/web/2024-04-01/webapps/id_default.go b/resource-manager/web/2024-04-01/webapps/id_default.go new file mode 100644 index 00000000000..82b1628663d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_default.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DefaultId{}) +} + +var _ resourceids.ResourceId = &DefaultId{} + +// DefaultId is a struct representing the Resource ID for a Default +type DefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DefaultName string + KeyName string +} + +// NewDefaultID returns a new DefaultId struct +func NewDefaultID(subscriptionId string, resourceGroupName string, siteName string, defaultName string, keyName string) DefaultId { + return DefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseDefaultID parses 'input' into a DefaultId +func ParseDefaultID(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultIDInsensitively parses 'input' case-insensitively into a DefaultId +// note: this method should only be used for API response data and not user input +func ParseDefaultIDInsensitively(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateDefaultID checks that 'input' can be parsed as a Default ID +func ValidateDefaultID(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 := ParseDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default ID +func (id DefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default ID +func (id DefaultId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultName"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Default ID +func (id DefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_default_test.go b/resource-manager/web/2024-04-01/webapps/id_default_test.go new file mode 100644 index 00000000000..fb8f07676f0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_default_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &DefaultId{} + +func TestNewDefaultID(t *testing.T) { + id := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DefaultName != "defaultName" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatDefaultID(t *testing.T) { + actual := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DefaultName: "dEfAuLtNaMe", + KeyName: "kEyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForDefaultId(t *testing.T) { + segments := DefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultId 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/web/2024-04-01/webapps/id_deployment.go b/resource-manager/web/2024-04-01/webapps/id_deployment.go new file mode 100644 index 00000000000..6b9e4f1fdf3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_deployment.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DeploymentId{}) +} + +var _ resourceids.ResourceId = &DeploymentId{} + +// DeploymentId is a struct representing the Resource ID for a Deployment +type DeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DeploymentName string +} + +// NewDeploymentID returns a new DeploymentId struct +func NewDeploymentID(subscriptionId string, resourceGroupName string, siteName string, deploymentName string) DeploymentId { + return DeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DeploymentName: deploymentName, + } +} + +// ParseDeploymentID parses 'input' into a DeploymentId +func ParseDeploymentID(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeploymentIDInsensitively parses 'input' case-insensitively into a DeploymentId +// note: this method should only be used for API response data and not user input +func ParseDeploymentIDInsensitively(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeploymentId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateDeploymentID checks that 'input' can be parsed as a Deployment ID +func ValidateDeploymentID(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 := ParseDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deployment ID +func (id DeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deployment ID +func (id DeploymentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Deployment ID +func (id DeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_deployment_test.go b/resource-manager/web/2024-04-01/webapps/id_deployment_test.go new file mode 100644 index 00000000000..01e80a6d68b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_deployment_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &DeploymentId{} + +func TestNewDeploymentID(t *testing.T) { + id := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatDeploymentID(t *testing.T) { + actual := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForDeploymentId(t *testing.T) { + segments := DeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeploymentId 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/web/2024-04-01/webapps/id_function.go b/resource-manager/web/2024-04-01/webapps/id_function.go new file mode 100644 index 00000000000..f616aeae83a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_function.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FunctionId{}) +} + +var _ resourceids.ResourceId = &FunctionId{} + +// FunctionId is a struct representing the Resource ID for a Function +type FunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string +} + +// NewFunctionID returns a new FunctionId struct +func NewFunctionID(subscriptionId string, resourceGroupName string, siteName string, functionName string) FunctionId { + return FunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + } +} + +// ParseFunctionID parses 'input' into a FunctionId +func ParseFunctionID(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionIDInsensitively parses 'input' case-insensitively into a FunctionId +// note: this method should only be used for API response data and not user input +func ParseFunctionIDInsensitively(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateFunctionID checks that 'input' can be parsed as a Function ID +func ValidateFunctionID(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 := ParseFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function ID +func (id FunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function ID +func (id FunctionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + } +} + +// String returns a human-readable description of this Function ID +func (id FunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_function_test.go b/resource-manager/web/2024-04-01/webapps/id_function_test.go new file mode 100644 index 00000000000..647ee45180b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_function_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &FunctionId{} + +func TestNewFunctionID(t *testing.T) { + id := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } +} + +func TestFormatFunctionID(t *testing.T) { + actual := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + FunctionName: "fUnCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForFunctionId(t *testing.T) { + segments := FunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionId 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/web/2024-04-01/webapps/id_functionkey.go b/resource-manager/web/2024-04-01/webapps/id_functionkey.go new file mode 100644 index 00000000000..2c5e6ac58da --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_functionkey.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&FunctionKeyId{}) +} + +var _ resourceids.ResourceId = &FunctionKeyId{} + +// FunctionKeyId is a struct representing the Resource ID for a Function Key +type FunctionKeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string + KeyName string +} + +// NewFunctionKeyID returns a new FunctionKeyId struct +func NewFunctionKeyID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string, keyName string) FunctionKeyId { + return FunctionKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseFunctionKeyID parses 'input' into a FunctionKeyId +func ParseFunctionKeyID(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionKeyIDInsensitively parses 'input' case-insensitively into a FunctionKeyId +// note: this method should only be used for API response data and not user input +func ParseFunctionKeyIDInsensitively(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionKeyId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateFunctionKeyID checks that 'input' can be parsed as a Function Key ID +func ValidateFunctionKeyID(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 := ParseFunctionKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function Key ID +func (id FunctionKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function Key ID +func (id FunctionKeyId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Function Key ID +func (id FunctionKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Function Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_functionkey_test.go b/resource-manager/web/2024-04-01/webapps/id_functionkey_test.go new file mode 100644 index 00000000000..d5c2d17970d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_functionkey_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &FunctionKeyId{} + +func TestNewFunctionKeyID(t *testing.T) { + id := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatFunctionKeyID(t *testing.T) { + actual := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseFunctionKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + FunctionName: "fUnCtIoNnAmE", + KeyName: "kEyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForFunctionKeyId(t *testing.T) { + segments := FunctionKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionKeyId 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/web/2024-04-01/webapps/id_gateway.go b/resource-manager/web/2024-04-01/webapps/id_gateway.go new file mode 100644 index 00000000000..0d5dc900e0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_gateway.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&GatewayId{}) +} + +var _ resourceids.ResourceId = &GatewayId{} + +// GatewayId is a struct representing the Resource ID for a Gateway +type GatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewGatewayID returns a new GatewayId struct +func NewGatewayID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string, gatewayName string) GatewayId { + return GatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseGatewayID parses 'input' into a GatewayId +func ParseGatewayID(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGatewayIDInsensitively parses 'input' case-insensitively into a GatewayId +// note: this method should only be used for API response data and not user input +func ParseGatewayIDInsensitively(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GatewayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateGatewayID checks that 'input' can be parsed as a Gateway ID +func ValidateGatewayID(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 := ParseGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gateway ID +func (id GatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gateway ID +func (id GatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Gateway ID +func (id GatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_gateway_test.go b/resource-manager/web/2024-04-01/webapps/id_gateway_test.go new file mode 100644 index 00000000000..7bbd4aac0a9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_gateway_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &GatewayId{} + +func TestNewGatewayID(t *testing.T) { + id := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatGatewayID(t *testing.T) { + actual := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForGatewayId(t *testing.T) { + segments := GatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GatewayId 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/web/2024-04-01/webapps/id_history.go b/resource-manager/web/2024-04-01/webapps/id_history.go new file mode 100644 index 00000000000..c1cc260d497 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_history.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HistoryId{}) +} + +var _ resourceids.ResourceId = &HistoryId{} + +// HistoryId is a struct representing the Resource ID for a History +type HistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string + HistoryName string +} + +// NewHistoryID returns a new HistoryId struct +func NewHistoryID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string, historyName string) HistoryId { + return HistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseHistoryID parses 'input' into a HistoryId +func ParseHistoryID(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHistoryIDInsensitively parses 'input' case-insensitively into a HistoryId +// note: this method should only be used for API response data and not user input +func ParseHistoryIDInsensitively(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateHistoryID checks that 'input' can be parsed as a History ID +func ValidateHistoryID(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 := ParseHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted History ID +func (id HistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this History ID +func (id HistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this History ID +func (id HistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_history_test.go b/resource-manager/web/2024-04-01/webapps/id_history_test.go new file mode 100644 index 00000000000..d3d2ed22f07 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_history_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &HistoryId{} + +func TestNewHistoryID(t *testing.T) { + id := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatHistoryID(t *testing.T) { + actual := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForHistoryId(t *testing.T) { + segments := HistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HistoryId 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/web/2024-04-01/webapps/id_hostdefault.go b/resource-manager/web/2024-04-01/webapps/id_hostdefault.go new file mode 100644 index 00000000000..d02b1ff58fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hostdefault.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostDefaultId{}) +} + +var _ resourceids.ResourceId = &HostDefaultId{} + +// HostDefaultId is a struct representing the Resource ID for a Host Default +type HostDefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DefaultName string + KeyName string +} + +// NewHostDefaultID returns a new HostDefaultId struct +func NewHostDefaultID(subscriptionId string, resourceGroupName string, siteName string, slotName string, defaultName string, keyName string) HostDefaultId { + return HostDefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseHostDefaultID parses 'input' into a HostDefaultId +func ParseHostDefaultID(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostDefaultIDInsensitively parses 'input' case-insensitively into a HostDefaultId +// note: this method should only be used for API response data and not user input +func ParseHostDefaultIDInsensitively(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostDefaultId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateHostDefaultID checks that 'input' can be parsed as a Host Default ID +func ValidateHostDefaultID(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 := ParseHostDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Default ID +func (id HostDefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Default ID +func (id HostDefaultId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultName"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Host Default ID +func (id HostDefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Host Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_hostdefault_test.go b/resource-manager/web/2024-04-01/webapps/id_hostdefault_test.go new file mode 100644 index 00000000000..4f3bb7c417c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hostdefault_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &HostDefaultId{} + +func TestNewHostDefaultID(t *testing.T) { + id := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DefaultName != "defaultName" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatHostDefaultID(t *testing.T) { + actual := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseHostDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DefaultName: "dEfAuLtNaMe", + KeyName: "kEyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForHostDefaultId(t *testing.T) { + segments := HostDefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostDefaultId 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/web/2024-04-01/webapps/id_hostnamebinding.go b/resource-manager/web/2024-04-01/webapps/id_hostnamebinding.go new file mode 100644 index 00000000000..56a4b8e3fba --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hostnamebinding.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HostNameBindingId{}) +} + +var _ resourceids.ResourceId = &HostNameBindingId{} + +// HostNameBindingId is a struct representing the Resource ID for a Host Name Binding +type HostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HostNameBindingName string +} + +// NewHostNameBindingID returns a new HostNameBindingId struct +func NewHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, hostNameBindingName string) HostNameBindingId { + return HostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseHostNameBindingID parses 'input' into a HostNameBindingId +func ParseHostNameBindingID(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostNameBindingIDInsensitively parses 'input' case-insensitively into a HostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseHostNameBindingIDInsensitively(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostNameBindingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateHostNameBindingID checks that 'input' can be parsed as a Host Name Binding ID +func ValidateHostNameBindingID(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 := ParseHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Name Binding ID +func (id HostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Name Binding ID +func (id HostNameBindingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingName"), + } +} + +// String returns a human-readable description of this Host Name Binding ID +func (id HostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_hostnamebinding_test.go b/resource-manager/web/2024-04-01/webapps/id_hostnamebinding_test.go new file mode 100644 index 00000000000..a3b55f6e522 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hostnamebinding_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &HostNameBindingId{} + +func TestNewHostNameBindingID(t *testing.T) { + id := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HostNameBindingName != "hostNameBindingName" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingName") + } +} + +func TestFormatHostNameBindingID(t *testing.T) { + actual := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HostNameBindingName: "hOsTnAmEbInDiNgNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForHostNameBindingId(t *testing.T) { + segments := HostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostNameBindingId 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/web/2024-04-01/webapps/id_hybridconnection.go b/resource-manager/web/2024-04-01/webapps/id_hybridconnection.go new file mode 100644 index 00000000000..643e1f811d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hybridconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&HybridConnectionId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionId{} + +// HybridConnectionId is a struct representing the Resource ID for a Hybrid Connection +type HybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionName string +} + +// NewHybridConnectionID returns a new HybridConnectionId struct +func NewHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionName string) HybridConnectionId { + return HybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseHybridConnectionID parses 'input' into a HybridConnectionId +func ParseHybridConnectionID(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionIDInsensitively parses 'input' case-insensitively into a HybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionIDInsensitively(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateHybridConnectionID checks that 'input' can be parsed as a Hybrid Connection ID +func ValidateHybridConnectionID(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 := ParseHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection ID +func (id HybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection ID +func (id HybridConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionName"), + } +} + +// String returns a human-readable description of this Hybrid Connection ID +func (id HybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_hybridconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_hybridconnection_test.go new file mode 100644 index 00000000000..db79679c1a3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_hybridconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &HybridConnectionId{} + +func TestNewHybridConnectionID(t *testing.T) { + id := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HybridConnectionName != "hybridConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionName") + } +} + +func TestFormatHybridConnectionID(t *testing.T) { + actual := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HybridConnectionName: "hYbRiDcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForHybridConnectionId(t *testing.T) { + segments := HybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionId 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/web/2024-04-01/webapps/id_instance.go b/resource-manager/web/2024-04-01/webapps/id_instance.go new file mode 100644 index 00000000000..f43fc67da55 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instance.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&InstanceId{}) +} + +var _ resourceids.ResourceId = &InstanceId{} + +// InstanceId is a struct representing the Resource ID for a Instance +type InstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string +} + +// NewInstanceID returns a new InstanceId struct +func NewInstanceID(subscriptionId string, resourceGroupName string, siteName string, instanceId string) InstanceId { + return InstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + } +} + +// ParseInstanceID parses 'input' into a InstanceId +func ParseInstanceID(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceIDInsensitively parses 'input' case-insensitively into a InstanceId +// note: this method should only be used for API response data and not user input +func ParseInstanceIDInsensitively(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateInstanceID checks that 'input' can be parsed as a Instance ID +func ValidateInstanceID(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 := ParseInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance ID +func (id InstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance ID +func (id InstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + } +} + +// String returns a human-readable description of this Instance ID +func (id InstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_instance_test.go b/resource-manager/web/2024-04-01/webapps/id_instance_test.go new file mode 100644 index 00000000000..34b663d63cc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instance_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &InstanceId{} + +func TestNewInstanceID(t *testing.T) { + id := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } +} + +func TestFormatInstanceID(t *testing.T) { + actual := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForInstanceId(t *testing.T) { + segments := InstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceId 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/web/2024-04-01/webapps/id_instanceprocess.go b/resource-manager/web/2024-04-01/webapps/id_instanceprocess.go new file mode 100644 index 00000000000..86610e6df3c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instanceprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&InstanceProcessId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessId{} + +// InstanceProcessId is a struct representing the Resource ID for a Instance Process +type InstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string +} + +// NewInstanceProcessID returns a new InstanceProcessId struct +func NewInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string) InstanceProcessId { + return InstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseInstanceProcessID parses 'input' into a InstanceProcessId +func ParseInstanceProcessID(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessIDInsensitively parses 'input' case-insensitively into a InstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessIDInsensitively(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateInstanceProcessID checks that 'input' can be parsed as a Instance Process ID +func ValidateInstanceProcessID(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 := ParseInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process ID +func (id InstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process ID +func (id InstanceProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Instance Process ID +func (id InstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_instanceprocess_test.go b/resource-manager/web/2024-04-01/webapps/id_instanceprocess_test.go new file mode 100644 index 00000000000..dbfed807250 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instanceprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &InstanceProcessId{} + +func TestNewInstanceProcessID(t *testing.T) { + id := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatInstanceProcessID(t *testing.T) { + actual := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForInstanceProcessId(t *testing.T) { + segments := InstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessId 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/web/2024-04-01/webapps/id_instanceprocessmodule.go b/resource-manager/web/2024-04-01/webapps/id_instanceprocessmodule.go new file mode 100644 index 00000000000..28225e030f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instanceprocessmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&InstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessModuleId{} + +// InstanceProcessModuleId is a struct representing the Resource ID for a Instance Process Module +type InstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewInstanceProcessModuleID returns a new InstanceProcessModuleId struct +func NewInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string, moduleName string) InstanceProcessModuleId { + return InstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseInstanceProcessModuleID parses 'input' into a InstanceProcessModuleId +func ParseInstanceProcessModuleID(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a InstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessModuleIDInsensitively(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateInstanceProcessModuleID checks that 'input' can be parsed as a Instance Process Module ID +func ValidateInstanceProcessModuleID(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 := ParseInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process Module ID +func (id InstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process Module ID +func (id InstanceProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Instance Process Module ID +func (id InstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_instanceprocessmodule_test.go b/resource-manager/web/2024-04-01/webapps/id_instanceprocessmodule_test.go new file mode 100644 index 00000000000..7e118c5f387 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_instanceprocessmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &InstanceProcessModuleId{} + +func TestNewInstanceProcessModuleID(t *testing.T) { + id := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatInstanceProcessModuleID(t *testing.T) { + actual := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForInstanceProcessModuleId(t *testing.T) { + segments := InstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessModuleId 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/web/2024-04-01/webapps/id_key.go b/resource-manager/web/2024-04-01/webapps/id_key.go new file mode 100644 index 00000000000..ca9170618d4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_key.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&KeyId{}) +} + +var _ resourceids.ResourceId = &KeyId{} + +// KeyId is a struct representing the Resource ID for a Key +type KeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string + KeyName string +} + +// NewKeyID returns a new KeyId struct +func NewKeyID(subscriptionId string, resourceGroupName string, siteName string, functionName string, keyName string) KeyId { + return KeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseKeyID parses 'input' into a KeyId +func ParseKeyID(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKeyIDInsensitively parses 'input' case-insensitively into a KeyId +// note: this method should only be used for API response data and not user input +func ParseKeyIDInsensitively(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KeyId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateKeyID checks that 'input' can be parsed as a Key ID +func ValidateKeyID(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 := ParseKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Key ID +func (id KeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Key ID +func (id KeyId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Key ID +func (id KeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_key_test.go b/resource-manager/web/2024-04-01/webapps/id_key_test.go new file mode 100644 index 00000000000..0d951499006 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_key_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &KeyId{} + +func TestNewKeyID(t *testing.T) { + id := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatKeyID(t *testing.T) { + actual := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + FunctionName: "fUnCtIoNnAmE", + KeyName: "kEyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForKeyId(t *testing.T) { + segments := KeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KeyId 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/web/2024-04-01/webapps/id_module.go b/resource-manager/web/2024-04-01/webapps/id_module.go new file mode 100644 index 00000000000..88421388b85 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_module.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ModuleId{}) +} + +var _ resourceids.ResourceId = &ModuleId{} + +// ModuleId is a struct representing the Resource ID for a Module +type ModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string + ModuleName string +} + +// NewModuleID returns a new ModuleId struct +func NewModuleID(subscriptionId string, resourceGroupName string, siteName string, processId string, moduleName string) ModuleId { + return ModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseModuleID parses 'input' into a ModuleId +func ParseModuleID(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModuleIDInsensitively parses 'input' case-insensitively into a ModuleId +// note: this method should only be used for API response data and not user input +func ParseModuleIDInsensitively(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateModuleID checks that 'input' can be parsed as a Module ID +func ValidateModuleID(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 := ParseModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Module ID +func (id ModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Module ID +func (id ModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Module ID +func (id ModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_module_test.go b/resource-manager/web/2024-04-01/webapps/id_module_test.go new file mode 100644 index 00000000000..d5e57223ef0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_module_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &ModuleId{} + +func TestNewModuleID(t *testing.T) { + id := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatModuleID(t *testing.T) { + actual := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForModuleId(t *testing.T) { + segments := ModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModuleId 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/web/2024-04-01/webapps/id_networkfeature.go b/resource-manager/web/2024-04-01/webapps/id_networkfeature.go new file mode 100644 index 00000000000..dc1966efd90 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_networkfeature.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &NetworkFeatureId{} + +// NetworkFeatureId is a struct representing the Resource ID for a Network Feature +type NetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + NetworkFeatureName string +} + +// NewNetworkFeatureID returns a new NetworkFeatureId struct +func NewNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, networkFeatureName string) NetworkFeatureId { + return NetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseNetworkFeatureID parses 'input' into a NetworkFeatureId +func ParseNetworkFeatureID(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkFeatureIDInsensitively parses 'input' case-insensitively into a NetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseNetworkFeatureIDInsensitively(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkFeatureId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateNetworkFeatureID checks that 'input' can be parsed as a Network Feature ID +func ValidateNetworkFeatureID(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 := ParseNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Feature ID +func (id NetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Feature ID +func (id NetworkFeatureId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureName"), + } +} + +// String returns a human-readable description of this Network Feature ID +func (id NetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_networkfeature_test.go b/resource-manager/web/2024-04-01/webapps/id_networkfeature_test.go new file mode 100644 index 00000000000..1c1bafc5113 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_networkfeature_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &NetworkFeatureId{} + +func TestNewNetworkFeatureID(t *testing.T) { + id := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.NetworkFeatureName != "networkFeatureName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureName") + } +} + +func TestFormatNetworkFeatureID(t *testing.T) { + actual := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + NetworkFeatureName: "nEtWoRkFeAtUrEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForNetworkFeatureId(t *testing.T) { + segments := NetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkFeatureId 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/web/2024-04-01/webapps/id_networktrace.go b/resource-manager/web/2024-04-01/webapps/id_networktrace.go new file mode 100644 index 00000000000..d7b89a69dd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_networktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&NetworkTraceId{}) +} + +var _ resourceids.ResourceId = &NetworkTraceId{} + +// NetworkTraceId is a struct representing the Resource ID for a Network Trace +type NetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewNetworkTraceID returns a new NetworkTraceId struct +func NewNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) NetworkTraceId { + return NetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseNetworkTraceID parses 'input' into a NetworkTraceId +func ParseNetworkTraceID(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkTraceIDInsensitively parses 'input' case-insensitively into a NetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseNetworkTraceIDInsensitively(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateNetworkTraceID checks that 'input' can be parsed as a Network Trace ID +func ValidateNetworkTraceID(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 := ParseNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Trace ID +func (id NetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Trace ID +func (id NetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Network Trace ID +func (id NetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_networktrace_test.go b/resource-manager/web/2024-04-01/webapps/id_networktrace_test.go new file mode 100644 index 00000000000..2ca9e11dd67 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_networktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &NetworkTraceId{} + +func TestNewNetworkTraceID(t *testing.T) { + id := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatNetworkTraceID(t *testing.T) { + actual := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE/oPeRaTiOnId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForNetworkTraceId(t *testing.T) { + segments := NetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkTraceId 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/web/2024-04-01/webapps/id_premieraddon.go b/resource-manager/web/2024-04-01/webapps/id_premieraddon.go new file mode 100644 index 00000000000..e2a7b5cf220 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_premieraddon.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PremierAddonId{}) +} + +var _ resourceids.ResourceId = &PremierAddonId{} + +// PremierAddonId is a struct representing the Resource ID for a Premier Addon +type PremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PremierAddonName string +} + +// NewPremierAddonID returns a new PremierAddonId struct +func NewPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, premierAddonName string) PremierAddonId { + return PremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PremierAddonName: premierAddonName, + } +} + +// ParsePremierAddonID parses 'input' into a PremierAddonId +func ParsePremierAddonID(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePremierAddonIDInsensitively parses 'input' case-insensitively into a PremierAddonId +// note: this method should only be used for API response data and not user input +func ParsePremierAddonIDInsensitively(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PremierAddonId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidatePremierAddonID checks that 'input' can be parsed as a Premier Addon ID +func ValidatePremierAddonID(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 := ParsePremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Premier Addon ID +func (id PremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Premier Addon ID +func (id PremierAddonId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonName"), + } +} + +// String returns a human-readable description of this Premier Addon ID +func (id PremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_premieraddon_test.go b/resource-manager/web/2024-04-01/webapps/id_premieraddon_test.go new file mode 100644 index 00000000000..2c292945ce2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_premieraddon_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &PremierAddonId{} + +func TestNewPremierAddonID(t *testing.T) { + id := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PremierAddonName != "premierAddonName" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonName") + } +} + +func TestFormatPremierAddonID(t *testing.T) { + actual := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParsePremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PremierAddonName: "pReMiErAdDoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForPremierAddonId(t *testing.T) { + segments := PremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PremierAddonId 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/web/2024-04-01/webapps/id_privateendpointconnection.go b/resource-manager/web/2024-04-01/webapps/id_privateendpointconnection.go new file mode 100644 index 00000000000..c7d9dfbd7e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_privateendpointconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..b8561c67c85 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId 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/web/2024-04-01/webapps/id_process.go b/resource-manager/web/2024-04-01/webapps/id_process.go new file mode 100644 index 00000000000..4bd04a2dc5a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_process.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProcessId{}) +} + +var _ resourceids.ResourceId = &ProcessId{} + +// ProcessId is a struct representing the Resource ID for a Process +type ProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string +} + +// NewProcessID returns a new ProcessId struct +func NewProcessID(subscriptionId string, resourceGroupName string, siteName string, processId string) ProcessId { + return ProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + } +} + +// ParseProcessID parses 'input' into a ProcessId +func ParseProcessID(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessIDInsensitively parses 'input' case-insensitively into a ProcessId +// note: this method should only be used for API response data and not user input +func ParseProcessIDInsensitively(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateProcessID checks that 'input' can be parsed as a Process ID +func ValidateProcessID(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 := ParseProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process ID +func (id ProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process ID +func (id ProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Process ID +func (id ProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_process_test.go b/resource-manager/web/2024-04-01/webapps/id_process_test.go new file mode 100644 index 00000000000..01626642762 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_process_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &ProcessId{} + +func TestNewProcessID(t *testing.T) { + id := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatProcessID(t *testing.T) { + actual := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ProcessId: "pRoCeSsId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForProcessId(t *testing.T) { + segments := ProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessId 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/web/2024-04-01/webapps/id_processmodule.go b/resource-manager/web/2024-04-01/webapps/id_processmodule.go new file mode 100644 index 00000000000..5219175f699 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_processmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ProcessModuleId{}) +} + +var _ resourceids.ResourceId = &ProcessModuleId{} + +// ProcessModuleId is a struct representing the Resource ID for a Process Module +type ProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string + ModuleName string +} + +// NewProcessModuleID returns a new ProcessModuleId struct +func NewProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string, moduleName string) ProcessModuleId { + return ProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseProcessModuleID parses 'input' into a ProcessModuleId +func ParseProcessModuleID(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessModuleIDInsensitively parses 'input' case-insensitively into a ProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseProcessModuleIDInsensitively(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateProcessModuleID checks that 'input' can be parsed as a Process Module ID +func ValidateProcessModuleID(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 := ParseProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process Module ID +func (id ProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process Module ID +func (id ProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Process Module ID +func (id ProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_processmodule_test.go b/resource-manager/web/2024-04-01/webapps/id_processmodule_test.go new file mode 100644 index 00000000000..de7af2c9000 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_processmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &ProcessModuleId{} + +func TestNewProcessModuleID(t *testing.T) { + id := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatProcessModuleID(t *testing.T) { + actual := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForProcessModuleId(t *testing.T) { + segments := ProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessModuleId 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/web/2024-04-01/webapps/id_publiccertificate.go b/resource-manager/web/2024-04-01/webapps/id_publiccertificate.go new file mode 100644 index 00000000000..ab810e6cab6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_publiccertificate.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&PublicCertificateId{}) +} + +var _ resourceids.ResourceId = &PublicCertificateId{} + +// PublicCertificateId is a struct representing the Resource ID for a Public Certificate +type PublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PublicCertificateName string +} + +// NewPublicCertificateID returns a new PublicCertificateId struct +func NewPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, publicCertificateName string) PublicCertificateId { + return PublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PublicCertificateName: publicCertificateName, + } +} + +// ParsePublicCertificateID parses 'input' into a PublicCertificateId +func ParsePublicCertificateID(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePublicCertificateIDInsensitively parses 'input' case-insensitively into a PublicCertificateId +// note: this method should only be used for API response data and not user input +func ParsePublicCertificateIDInsensitively(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PublicCertificateId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidatePublicCertificateID checks that 'input' can be parsed as a Public Certificate ID +func ValidatePublicCertificateID(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 := ParsePublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Public Certificate ID +func (id PublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Public Certificate ID +func (id PublicCertificateId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateName"), + } +} + +// String returns a human-readable description of this Public Certificate ID +func (id PublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_publiccertificate_test.go b/resource-manager/web/2024-04-01/webapps/id_publiccertificate_test.go new file mode 100644 index 00000000000..947dd952615 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_publiccertificate_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &PublicCertificateId{} + +func TestNewPublicCertificateID(t *testing.T) { + id := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PublicCertificateName != "publicCertificateName" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateName") + } +} + +func TestFormatPublicCertificateID(t *testing.T) { + actual := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParsePublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PublicCertificateName: "pUbLiCcErTiFiCaTeNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForPublicCertificateId(t *testing.T) { + segments := PublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PublicCertificateId 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/web/2024-04-01/webapps/id_relay.go b/resource-manager/web/2024-04-01/webapps/id_relay.go new file mode 100644 index 00000000000..4af77542a26 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_relay.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RelayId{}) +} + +var _ resourceids.ResourceId = &RelayId{} + +// RelayId is a struct representing the Resource ID for a Relay +type RelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewRelayID returns a new RelayId struct +func NewRelayID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionNamespaceName string, relayName string) RelayId { + return RelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseRelayID parses 'input' into a RelayId +func ParseRelayID(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRelayIDInsensitively parses 'input' case-insensitively into a RelayId +// note: this method should only be used for API response data and not user input +func ParseRelayIDInsensitively(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RelayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateRelayID checks that 'input' can be parsed as a Relay ID +func ValidateRelayID(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 := ParseRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Relay ID +func (id RelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Relay ID +func (id RelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Relay ID +func (id RelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_relay_test.go b/resource-manager/web/2024-04-01/webapps/id_relay_test.go new file mode 100644 index 00000000000..b0ca40050e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_relay_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &RelayId{} + +func TestNewRelayID(t *testing.T) { + id := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatRelayID(t *testing.T) { + actual := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForRelayId(t *testing.T) { + segments := RelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RelayId 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/web/2024-04-01/webapps/id_sitecontainer.go b/resource-manager/web/2024-04-01/webapps/id_sitecontainer.go new file mode 100644 index 00000000000..a6f2cf8a06c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitecontainer.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SitecontainerId{}) +} + +var _ resourceids.ResourceId = &SitecontainerId{} + +// SitecontainerId is a struct representing the Resource ID for a Sitecontainer +type SitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SitecontainerName string +} + +// NewSitecontainerID returns a new SitecontainerId struct +func NewSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, sitecontainerName string) SitecontainerId { + return SitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSitecontainerID parses 'input' into a SitecontainerId +func ParseSitecontainerID(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSitecontainerIDInsensitively parses 'input' case-insensitively into a SitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSitecontainerIDInsensitively(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SitecontainerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSitecontainerID checks that 'input' can be parsed as a Sitecontainer ID +func ValidateSitecontainerID(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 := ParseSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sitecontainer ID +func (id SitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sitecontainer ID +func (id SitecontainerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerName"), + } +} + +// String returns a human-readable description of this Sitecontainer ID +func (id SitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_sitecontainer_test.go b/resource-manager/web/2024-04-01/webapps/id_sitecontainer_test.go new file mode 100644 index 00000000000..cded30dec5d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitecontainer_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SitecontainerId{} + +func TestNewSitecontainerID(t *testing.T) { + id := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SitecontainerName != "sitecontainerName" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerName") + } +} + +func TestFormatSitecontainerID(t *testing.T) { + actual := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SitecontainerName: "sItEcOnTaInErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSitecontainerId(t *testing.T) { + segments := SitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SitecontainerId 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/web/2024-04-01/webapps/id_sitedomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/id_sitedomainownershipidentifier.go new file mode 100644 index 00000000000..ff59f8417f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitedomainownershipidentifier.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SiteDomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &SiteDomainOwnershipIdentifierId{} + +// SiteDomainOwnershipIdentifierId is a struct representing the Resource ID for a Site Domain Ownership Identifier +type SiteDomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DomainOwnershipIdentifierName string +} + +// NewSiteDomainOwnershipIdentifierID returns a new SiteDomainOwnershipIdentifierId struct +func NewSiteDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, domainOwnershipIdentifierName string) SiteDomainOwnershipIdentifierId { + return SiteDomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseSiteDomainOwnershipIdentifierID parses 'input' into a SiteDomainOwnershipIdentifierId +func ParseSiteDomainOwnershipIdentifierID(input string) (*SiteDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a SiteDomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseSiteDomainOwnershipIdentifierIDInsensitively(input string) (*SiteDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteDomainOwnershipIdentifierId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateSiteDomainOwnershipIdentifierID checks that 'input' can be parsed as a Site Domain Ownership Identifier ID +func ValidateSiteDomainOwnershipIdentifierID(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 := ParseSiteDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Site Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_sitedomainownershipidentifier_test.go b/resource-manager/web/2024-04-01/webapps/id_sitedomainownershipidentifier_test.go new file mode 100644 index 00000000000..db628c3f6c2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitedomainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SiteDomainOwnershipIdentifierId{} + +func TestNewSiteDomainOwnershipIdentifierID(t *testing.T) { + id := NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatSiteDomainOwnershipIdentifierID(t *testing.T) { + actual := NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteDomainOwnershipIdentifierID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseSiteDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteDomainOwnershipIdentifierIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForSiteDomainOwnershipIdentifierId(t *testing.T) { + segments := SiteDomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteDomainOwnershipIdentifierId 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/web/2024-04-01/webapps/id_siteextension.go b/resource-manager/web/2024-04-01/webapps/id_siteextension.go new file mode 100644 index 00000000000..40c85eb38fe --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_siteextension.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SiteExtensionId{} + +// SiteExtensionId is a struct representing the Resource ID for a Site Extension +type SiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SiteExtensionId string +} + +// NewSiteExtensionID returns a new SiteExtensionId struct +func NewSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, siteExtensionId string) SiteExtensionId { + return SiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSiteExtensionID parses 'input' into a SiteExtensionId +func ParseSiteExtensionID(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteExtensionIDInsensitively parses 'input' case-insensitively into a SiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSiteExtensionIDInsensitively(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteExtensionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSiteExtensionID checks that 'input' can be parsed as a Site Extension ID +func ValidateSiteExtensionID(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 := ParseSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Extension ID +func (id SiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Extension ID +func (id SiteExtensionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionId"), + } +} + +// String returns a human-readable description of this Site Extension ID +func (id SiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_siteextension_test.go b/resource-manager/web/2024-04-01/webapps/id_siteextension_test.go new file mode 100644 index 00000000000..32a89aa57ab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_siteextension_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SiteExtensionId{} + +func TestNewSiteExtensionID(t *testing.T) { + id := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SiteExtensionId != "siteExtensionId" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionId") + } +} + +func TestFormatSiteExtensionID(t *testing.T) { + actual := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SiteExtensionId: "sItEeXtEnSiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSiteExtensionId(t *testing.T) { + segments := SiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteExtensionId 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/web/2024-04-01/webapps/id_sitenetworktrace.go b/resource-manager/web/2024-04-01/webapps/id_sitenetworktrace.go new file mode 100644 index 00000000000..3274d10301d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitenetworktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SiteNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteNetworkTraceId{} + +// SiteNetworkTraceId is a struct representing the Resource ID for a Site Network Trace +type SiteNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewSiteNetworkTraceID returns a new SiteNetworkTraceId struct +func NewSiteNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) SiteNetworkTraceId { + return SiteNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseSiteNetworkTraceID parses 'input' into a SiteNetworkTraceId +func ParseSiteNetworkTraceID(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteNetworkTraceIDInsensitively(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteNetworkTraceID checks that 'input' can be parsed as a Site Network Trace ID +func ValidateSiteNetworkTraceID(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 := ParseSiteNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Network Trace ID +func (id SiteNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Network Trace ID +func (id SiteNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Site Network Trace ID +func (id SiteNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_sitenetworktrace_test.go b/resource-manager/web/2024-04-01/webapps/id_sitenetworktrace_test.go new file mode 100644 index 00000000000..92c51e2118f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_sitenetworktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SiteNetworkTraceId{} + +func TestNewSiteNetworkTraceID(t *testing.T) { + id := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSiteNetworkTraceID(t *testing.T) { + actual := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs/oPeRaTiOnId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteNetworkTraceId(t *testing.T) { + segments := SiteNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteNetworkTraceId 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/web/2024-04-01/webapps/id_siteslotnetworktrace.go b/resource-manager/web/2024-04-01/webapps/id_siteslotnetworktrace.go new file mode 100644 index 00000000000..23fbbbb9eab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_siteslotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SiteSlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteSlotNetworkTraceId{} + +// SiteSlotNetworkTraceId is a struct representing the Resource ID for a Site Slot Network Trace +type SiteSlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSiteSlotNetworkTraceID returns a new SiteSlotNetworkTraceId struct +func NewSiteSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SiteSlotNetworkTraceId { + return SiteSlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSiteSlotNetworkTraceID parses 'input' into a SiteSlotNetworkTraceId +func ParseSiteSlotNetworkTraceID(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteSlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteSlotNetworkTraceIDInsensitively(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteSlotNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteSlotNetworkTraceID checks that 'input' can be parsed as a Site Slot Network Trace ID +func ValidateSiteSlotNetworkTraceID(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 := ParseSiteSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_siteslotnetworktrace_test.go b/resource-manager/web/2024-04-01/webapps/id_siteslotnetworktrace_test.go new file mode 100644 index 00000000000..33e3ff66202 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_siteslotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SiteSlotNetworkTraceId{} + +func TestNewSiteSlotNetworkTraceID(t *testing.T) { + id := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSiteSlotNetworkTraceID(t *testing.T) { + actual := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs/oPeRaTiOnId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteSlotNetworkTraceId(t *testing.T) { + segments := SiteSlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteSlotNetworkTraceId 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/web/2024-04-01/webapps/id_slot.go b/resource-manager/web/2024-04-01/webapps/id_slot.go new file mode 100644 index 00000000000..620b8a931e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slot.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slot_test.go b/resource-manager/web/2024-04-01/webapps/id_slot_test.go new file mode 100644 index 00000000000..4ef0619f083 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slot_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2024-04-01/webapps/id_slotbackup.go b/resource-manager/web/2024-04-01/webapps/id_slotbackup.go new file mode 100644 index 00000000000..1aa5199ef05 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotbackup.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotBackupId{}) +} + +var _ resourceids.ResourceId = &SlotBackupId{} + +// SlotBackupId is a struct representing the Resource ID for a Slot Backup +type SlotBackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + BackupId string +} + +// NewSlotBackupID returns a new SlotBackupId struct +func NewSlotBackupID(subscriptionId string, resourceGroupName string, siteName string, slotName string, backupId string) SlotBackupId { + return SlotBackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + BackupId: backupId, + } +} + +// ParseSlotBackupID parses 'input' into a SlotBackupId +func ParseSlotBackupID(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotBackupIDInsensitively parses 'input' case-insensitively into a SlotBackupId +// note: this method should only be used for API response data and not user input +func ParseSlotBackupIDInsensitively(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotBackupId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateSlotBackupID checks that 'input' can be parsed as a Slot Backup ID +func ValidateSlotBackupID(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 := ParseSlotBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Backup ID +func (id SlotBackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Backup ID +func (id SlotBackupId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupId"), + } +} + +// String returns a human-readable description of this Slot Backup ID +func (id SlotBackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Slot Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotbackup_test.go b/resource-manager/web/2024-04-01/webapps/id_slotbackup_test.go new file mode 100644 index 00000000000..56eb5f5933f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotbackup_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotBackupId{} + +func TestNewSlotBackupID(t *testing.T) { + id := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.BackupId != "backupId" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupId") + } +} + +func TestFormatSlotBackupID(t *testing.T) { + actual := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseSlotBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs/bAcKuPiD", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + BackupId: "bAcKuPiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs/bAcKuPiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForSlotBackupId(t *testing.T) { + segments := SlotBackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotBackupId 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/web/2024-04-01/webapps/id_slotcontinuouswebjob.go b/resource-manager/web/2024-04-01/webapps/id_slotcontinuouswebjob.go new file mode 100644 index 00000000000..6ca39c98b2e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotcontinuouswebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotContinuousWebJobId{} + +// SlotContinuousWebJobId is a struct representing the Resource ID for a Slot Continuous Web Job +type SlotContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ContinuousWebJobName string +} + +// NewSlotContinuousWebJobID returns a new SlotContinuousWebJobId struct +func NewSlotContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, continuousWebJobName string) SlotContinuousWebJobId { + return SlotContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseSlotContinuousWebJobID parses 'input' into a SlotContinuousWebJobId +func ParseSlotContinuousWebJobID(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotContinuousWebJobIDInsensitively parses 'input' case-insensitively into a SlotContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotContinuousWebJobIDInsensitively(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotContinuousWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateSlotContinuousWebJobID checks that 'input' can be parsed as a Slot Continuous Web Job ID +func ValidateSlotContinuousWebJobID(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 := ParseSlotContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobName"), + } +} + +// String returns a human-readable description of this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Slot Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotcontinuouswebjob_test.go b/resource-manager/web/2024-04-01/webapps/id_slotcontinuouswebjob_test.go new file mode 100644 index 00000000000..94be6b075f1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotcontinuouswebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotContinuousWebJobId{} + +func TestNewSlotContinuousWebJobID(t *testing.T) { + id := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ContinuousWebJobName != "continuousWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobName") + } +} + +func TestFormatSlotContinuousWebJobID(t *testing.T) { + actual := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseSlotContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForSlotContinuousWebJobId(t *testing.T) { + segments := SlotContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotContinuousWebJobId 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/web/2024-04-01/webapps/id_slotdeployment.go b/resource-manager/web/2024-04-01/webapps/id_slotdeployment.go new file mode 100644 index 00000000000..fe789dce200 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotdeployment.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotDeploymentId{}) +} + +var _ resourceids.ResourceId = &SlotDeploymentId{} + +// SlotDeploymentId is a struct representing the Resource ID for a Slot Deployment +type SlotDeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DeploymentName string +} + +// NewSlotDeploymentID returns a new SlotDeploymentId struct +func NewSlotDeploymentID(subscriptionId string, resourceGroupName string, siteName string, slotName string, deploymentName string) SlotDeploymentId { + return SlotDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DeploymentName: deploymentName, + } +} + +// ParseSlotDeploymentID parses 'input' into a SlotDeploymentId +func ParseSlotDeploymentID(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDeploymentIDInsensitively parses 'input' case-insensitively into a SlotDeploymentId +// note: this method should only be used for API response data and not user input +func ParseSlotDeploymentIDInsensitively(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDeploymentId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateSlotDeploymentID checks that 'input' can be parsed as a Slot Deployment ID +func ValidateSlotDeploymentID(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 := ParseSlotDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Deployment ID +func (id SlotDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Deployment ID +func (id SlotDeploymentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Slot Deployment ID +func (id SlotDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Slot Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotdeployment_test.go b/resource-manager/web/2024-04-01/webapps/id_slotdeployment_test.go new file mode 100644 index 00000000000..2ddd1a03e78 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotdeployment_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotDeploymentId{} + +func TestNewSlotDeploymentID(t *testing.T) { + id := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatSlotDeploymentID(t *testing.T) { + actual := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseSlotDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForSlotDeploymentId(t *testing.T) { + segments := SlotDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDeploymentId 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/web/2024-04-01/webapps/id_slotdomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/id_slotdomainownershipidentifier.go new file mode 100644 index 00000000000..1dbb4307122 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotdomainownershipidentifier.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotDomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &SlotDomainOwnershipIdentifierId{} + +// SlotDomainOwnershipIdentifierId is a struct representing the Resource ID for a Slot Domain Ownership Identifier +type SlotDomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DomainOwnershipIdentifierName string +} + +// NewSlotDomainOwnershipIdentifierID returns a new SlotDomainOwnershipIdentifierId struct +func NewSlotDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, slotName string, domainOwnershipIdentifierName string) SlotDomainOwnershipIdentifierId { + return SlotDomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseSlotDomainOwnershipIdentifierID parses 'input' into a SlotDomainOwnershipIdentifierId +func ParseSlotDomainOwnershipIdentifierID(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a SlotDomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseSlotDomainOwnershipIdentifierIDInsensitively(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDomainOwnershipIdentifierId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateSlotDomainOwnershipIdentifierID checks that 'input' can be parsed as a Slot Domain Ownership Identifier ID +func ValidateSlotDomainOwnershipIdentifierID(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 := ParseSlotDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Slot Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotdomainownershipidentifier_test.go b/resource-manager/web/2024-04-01/webapps/id_slotdomainownershipidentifier_test.go new file mode 100644 index 00000000000..7be0f127472 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotdomainownershipidentifier_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotDomainOwnershipIdentifierId{} + +func TestNewSlotDomainOwnershipIdentifierID(t *testing.T) { + id := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatSlotDomainOwnershipIdentifierID(t *testing.T) { + actual := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseSlotDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForSlotDomainOwnershipIdentifierId(t *testing.T) { + segments := SlotDomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDomainOwnershipIdentifierId 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/web/2024-04-01/webapps/id_slotfunction.go b/resource-manager/web/2024-04-01/webapps/id_slotfunction.go new file mode 100644 index 00000000000..2f9cba6eccc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotfunction.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotFunctionId{}) +} + +var _ resourceids.ResourceId = &SlotFunctionId{} + +// SlotFunctionId is a struct representing the Resource ID for a Slot Function +type SlotFunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string +} + +// NewSlotFunctionID returns a new SlotFunctionId struct +func NewSlotFunctionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string) SlotFunctionId { + return SlotFunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + } +} + +// ParseSlotFunctionID parses 'input' into a SlotFunctionId +func ParseSlotFunctionID(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotFunctionIDInsensitively parses 'input' case-insensitively into a SlotFunctionId +// note: this method should only be used for API response data and not user input +func ParseSlotFunctionIDInsensitively(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotFunctionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateSlotFunctionID checks that 'input' can be parsed as a Slot Function ID +func ValidateSlotFunctionID(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 := ParseSlotFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Function ID +func (id SlotFunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Function ID +func (id SlotFunctionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + } +} + +// String returns a human-readable description of this Slot Function ID +func (id SlotFunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Slot Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotfunction_test.go b/resource-manager/web/2024-04-01/webapps/id_slotfunction_test.go new file mode 100644 index 00000000000..10315a35c83 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotfunction_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotFunctionId{} + +func TestNewSlotFunctionID(t *testing.T) { + id := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } +} + +func TestFormatSlotFunctionID(t *testing.T) { + actual := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseSlotFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + FunctionName: "fUnCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForSlotFunctionId(t *testing.T) { + segments := SlotFunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotFunctionId 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/web/2024-04-01/webapps/id_slothostnamebinding.go b/resource-manager/web/2024-04-01/webapps/id_slothostnamebinding.go new file mode 100644 index 00000000000..590d01a4bae --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothostnamebinding.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotHostNameBindingId{}) +} + +var _ resourceids.ResourceId = &SlotHostNameBindingId{} + +// SlotHostNameBindingId is a struct representing the Resource ID for a Slot Host Name Binding +type SlotHostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HostNameBindingName string +} + +// NewSlotHostNameBindingID returns a new SlotHostNameBindingId struct +func NewSlotHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hostNameBindingName string) SlotHostNameBindingId { + return SlotHostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseSlotHostNameBindingID parses 'input' into a SlotHostNameBindingId +func ParseSlotHostNameBindingID(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHostNameBindingIDInsensitively parses 'input' case-insensitively into a SlotHostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseSlotHostNameBindingIDInsensitively(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHostNameBindingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateSlotHostNameBindingID checks that 'input' can be parsed as a Slot Host Name Binding ID +func ValidateSlotHostNameBindingID(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 := ParseSlotHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Host Name Binding ID +func (id SlotHostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Host Name Binding ID +func (id SlotHostNameBindingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingName"), + } +} + +// String returns a human-readable description of this Slot Host Name Binding ID +func (id SlotHostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Slot Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slothostnamebinding_test.go b/resource-manager/web/2024-04-01/webapps/id_slothostnamebinding_test.go new file mode 100644 index 00000000000..d0e372c31e3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothostnamebinding_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotHostNameBindingId{} + +func TestNewSlotHostNameBindingID(t *testing.T) { + id := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HostNameBindingName != "hostNameBindingName" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingName") + } +} + +func TestFormatSlotHostNameBindingID(t *testing.T) { + actual := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseSlotHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HostNameBindingName: "hOsTnAmEbInDiNgNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForSlotHostNameBindingId(t *testing.T) { + segments := SlotHostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHostNameBindingId 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/web/2024-04-01/webapps/id_slothybridconnection.go b/resource-manager/web/2024-04-01/webapps/id_slothybridconnection.go new file mode 100644 index 00000000000..c5a95c89142 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothybridconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionId{} + +// SlotHybridConnectionId is a struct representing the Resource ID for a Slot Hybrid Connection +type SlotHybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionName string +} + +// NewSlotHybridConnectionID returns a new SlotHybridConnectionId struct +func NewSlotHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionName string) SlotHybridConnectionId { + return SlotHybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseSlotHybridConnectionID parses 'input' into a SlotHybridConnectionId +func ParseSlotHybridConnectionID(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionIDInsensitively(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionID checks that 'input' can be parsed as a Slot Hybrid Connection ID +func ValidateSlotHybridConnectionID(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 := ParseSlotHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection ID +func (id SlotHybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionName"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Slot Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slothybridconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_slothybridconnection_test.go new file mode 100644 index 00000000000..30653e42594 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothybridconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotHybridConnectionId{} + +func TestNewSlotHybridConnectionID(t *testing.T) { + id := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HybridConnectionName != "hybridConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionName") + } +} + +func TestFormatSlotHybridConnectionID(t *testing.T) { + actual := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseSlotHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HybridConnectionName: "hYbRiDcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionId(t *testing.T) { + segments := SlotHybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionId 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/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay.go b/resource-manager/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..f2a53e559e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionNamespaceRelayId{} + +// SlotHybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Slot Hybrid Connection Namespace Relay +type SlotHybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewSlotHybridConnectionNamespaceRelayID returns a new SlotHybridConnectionNamespaceRelayId struct +func NewSlotHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionNamespaceName string, relayName string) SlotHybridConnectionNamespaceRelayId { + return SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseSlotHybridConnectionNamespaceRelayID parses 'input' into a SlotHybridConnectionNamespaceRelayId +func ParseSlotHybridConnectionNamespaceRelayID(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionNamespaceRelayIDInsensitively(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionNamespaceRelayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Slot Hybrid Connection Namespace Relay ID +func ValidateSlotHybridConnectionNamespaceRelayID(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 := ParseSlotHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Slot Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay_test.go b/resource-manager/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..c668d1e93bc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slothybridconnectionnamespacerelay_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotHybridConnectionNamespaceRelayId{} + +func TestNewSlotHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatSlotHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseSlotHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionNamespaceRelayId(t *testing.T) { + segments := SlotHybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionNamespaceRelayId 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/web/2024-04-01/webapps/id_slotinstance.go b/resource-manager/web/2024-04-01/webapps/id_slotinstance.go new file mode 100644 index 00000000000..f6a4b514211 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstance.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotInstanceId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceId{} + +// SlotInstanceId is a struct representing the Resource ID for a Slot Instance +type SlotInstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string +} + +// NewSlotInstanceID returns a new SlotInstanceId struct +func NewSlotInstanceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string) SlotInstanceId { + return SlotInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + } +} + +// ParseSlotInstanceID parses 'input' into a SlotInstanceId +func ParseSlotInstanceID(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceIDInsensitively parses 'input' case-insensitively into a SlotInstanceId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceIDInsensitively(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateSlotInstanceID checks that 'input' can be parsed as a Slot Instance ID +func ValidateSlotInstanceID(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 := ParseSlotInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance ID +func (id SlotInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance ID +func (id SlotInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + } +} + +// String returns a human-readable description of this Slot Instance ID +func (id SlotInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Slot Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotinstance_test.go b/resource-manager/web/2024-04-01/webapps/id_slotinstance_test.go new file mode 100644 index 00000000000..2bd26deb6ee --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstance_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotInstanceId{} + +func TestNewSlotInstanceID(t *testing.T) { + id := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } +} + +func TestFormatSlotInstanceID(t *testing.T) { + actual := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseSlotInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForSlotInstanceId(t *testing.T) { + segments := SlotInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceId 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/web/2024-04-01/webapps/id_slotinstanceprocess.go b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocess.go new file mode 100644 index 00000000000..7459e303aab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocess.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessId{} + +// SlotInstanceProcessId is a struct representing the Resource ID for a Slot Instance Process +type SlotInstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string +} + +// NewSlotInstanceProcessID returns a new SlotInstanceProcessId struct +func NewSlotInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string) SlotInstanceProcessId { + return SlotInstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseSlotInstanceProcessID parses 'input' into a SlotInstanceProcessId +func ParseSlotInstanceProcessID(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessIDInsensitively(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotInstanceProcessID checks that 'input' can be parsed as a Slot Instance Process ID +func ValidateSlotInstanceProcessID(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 := ParseSlotInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process ID +func (id SlotInstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process ID +func (id SlotInstanceProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Slot Instance Process ID +func (id SlotInstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocess_test.go b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocess_test.go new file mode 100644 index 00000000000..c10bc2a0fc1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocess_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotInstanceProcessId{} + +func TestNewSlotInstanceProcessID(t *testing.T) { + id := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatSlotInstanceProcessID(t *testing.T) { + actual := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotInstanceProcessId(t *testing.T) { + segments := SlotInstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessId 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/web/2024-04-01/webapps/id_slotinstanceprocessmodule.go b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocessmodule.go new file mode 100644 index 00000000000..ec90a897094 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocessmodule.go @@ -0,0 +1,166 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessModuleId{} + +// SlotInstanceProcessModuleId is a struct representing the Resource ID for a Slot Instance Process Module +type SlotInstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewSlotInstanceProcessModuleID returns a new SlotInstanceProcessModuleId struct +func NewSlotInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string, moduleName string) SlotInstanceProcessModuleId { + return SlotInstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseSlotInstanceProcessModuleID parses 'input' into a SlotInstanceProcessModuleId +func ParseSlotInstanceProcessModuleID(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessModuleIDInsensitively(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateSlotInstanceProcessModuleID checks that 'input' can be parsed as a Slot Instance Process Module ID +func ValidateSlotInstanceProcessModuleID(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 := ParseSlotInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Slot Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocessmodule_test.go b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocessmodule_test.go new file mode 100644 index 00000000000..109eb72ff25 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotinstanceprocessmodule_test.go @@ -0,0 +1,462 @@ +package webapps + +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 = &SlotInstanceProcessModuleId{} + +func TestNewSlotInstanceProcessModuleID(t *testing.T) { + id := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatSlotInstanceProcessModuleID(t *testing.T) { + actual := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseSlotInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForSlotInstanceProcessModuleId(t *testing.T) { + segments := SlotInstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessModuleId 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/web/2024-04-01/webapps/id_slotnetworkfeature.go b/resource-manager/web/2024-04-01/webapps/id_slotnetworkfeature.go new file mode 100644 index 00000000000..507114a0bf1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotnetworkfeature.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotNetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkFeatureId{} + +// SlotNetworkFeatureId is a struct representing the Resource ID for a Slot Network Feature +type SlotNetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + NetworkFeatureName string +} + +// NewSlotNetworkFeatureID returns a new SlotNetworkFeatureId struct +func NewSlotNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, slotName string, networkFeatureName string) SlotNetworkFeatureId { + return SlotNetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseSlotNetworkFeatureID parses 'input' into a SlotNetworkFeatureId +func ParseSlotNetworkFeatureID(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkFeatureIDInsensitively parses 'input' case-insensitively into a SlotNetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkFeatureIDInsensitively(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkFeatureId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateSlotNetworkFeatureID checks that 'input' can be parsed as a Slot Network Feature ID +func ValidateSlotNetworkFeatureID(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 := ParseSlotNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Feature ID +func (id SlotNetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Feature ID +func (id SlotNetworkFeatureId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureName"), + } +} + +// String returns a human-readable description of this Slot Network Feature ID +func (id SlotNetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Slot Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotnetworkfeature_test.go b/resource-manager/web/2024-04-01/webapps/id_slotnetworkfeature_test.go new file mode 100644 index 00000000000..3b0cebea96b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotnetworkfeature_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotNetworkFeatureId{} + +func TestNewSlotNetworkFeatureID(t *testing.T) { + id := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.NetworkFeatureName != "networkFeatureName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureName") + } +} + +func TestFormatSlotNetworkFeatureID(t *testing.T) { + actual := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseSlotNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + NetworkFeatureName: "nEtWoRkFeAtUrEnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForSlotNetworkFeatureId(t *testing.T) { + segments := SlotNetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkFeatureId 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/web/2024-04-01/webapps/id_slotnetworktrace.go b/resource-manager/web/2024-04-01/webapps/id_slotnetworktrace.go new file mode 100644 index 00000000000..4e4dd73328e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkTraceId{} + +// SlotNetworkTraceId is a struct representing the Resource ID for a Slot Network Trace +type SlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSlotNetworkTraceID returns a new SlotNetworkTraceId struct +func NewSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SlotNetworkTraceId { + return SlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSlotNetworkTraceID parses 'input' into a SlotNetworkTraceId +func ParseSlotNetworkTraceID(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkTraceIDInsensitively(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSlotNetworkTraceID checks that 'input' can be parsed as a Slot Network Trace ID +func ValidateSlotNetworkTraceID(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 := ParseSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Trace ID +func (id SlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Trace ID +func (id SlotNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Slot Network Trace ID +func (id SlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotnetworktrace_test.go b/resource-manager/web/2024-04-01/webapps/id_slotnetworktrace_test.go new file mode 100644 index 00000000000..ef938f160c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotNetworkTraceId{} + +func TestNewSlotNetworkTraceID(t *testing.T) { + id := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSlotNetworkTraceID(t *testing.T) { + actual := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE/oPeRaTiOnId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSlotNetworkTraceId(t *testing.T) { + segments := SlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkTraceId 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/web/2024-04-01/webapps/id_slotpremieraddon.go b/resource-manager/web/2024-04-01/webapps/id_slotpremieraddon.go new file mode 100644 index 00000000000..ca4498c2e93 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotpremieraddon.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotPremierAddonId{}) +} + +var _ resourceids.ResourceId = &SlotPremierAddonId{} + +// SlotPremierAddonId is a struct representing the Resource ID for a Slot Premier Addon +type SlotPremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PremierAddonName string +} + +// NewSlotPremierAddonID returns a new SlotPremierAddonId struct +func NewSlotPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, slotName string, premierAddonName string) SlotPremierAddonId { + return SlotPremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PremierAddonName: premierAddonName, + } +} + +// ParseSlotPremierAddonID parses 'input' into a SlotPremierAddonId +func ParseSlotPremierAddonID(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPremierAddonIDInsensitively parses 'input' case-insensitively into a SlotPremierAddonId +// note: this method should only be used for API response data and not user input +func ParseSlotPremierAddonIDInsensitively(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPremierAddonId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidateSlotPremierAddonID checks that 'input' can be parsed as a Slot Premier Addon ID +func ValidateSlotPremierAddonID(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 := ParseSlotPremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Premier Addon ID +func (id SlotPremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Premier Addon ID +func (id SlotPremierAddonId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonName"), + } +} + +// String returns a human-readable description of this Slot Premier Addon ID +func (id SlotPremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Slot Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotpremieraddon_test.go b/resource-manager/web/2024-04-01/webapps/id_slotpremieraddon_test.go new file mode 100644 index 00000000000..c6094e0240f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotpremieraddon_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPremierAddonId{} + +func TestNewSlotPremierAddonID(t *testing.T) { + id := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PremierAddonName != "premierAddonName" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonName") + } +} + +func TestFormatSlotPremierAddonID(t *testing.T) { + actual := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParseSlotPremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PremierAddonName: "pReMiErAdDoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForSlotPremierAddonId(t *testing.T) { + segments := SlotPremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPremierAddonId 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/web/2024-04-01/webapps/id_slotprivateendpointconnection.go b/resource-manager/web/2024-04-01/webapps/id_slotprivateendpointconnection.go new file mode 100644 index 00000000000..7a29bd7cb8b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotprivateendpointconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotPrivateEndpointConnectionId{} + +// SlotPrivateEndpointConnectionId is a struct representing the Resource ID for a Slot Private Endpoint Connection +type SlotPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PrivateEndpointConnectionName string +} + +// NewSlotPrivateEndpointConnectionID returns a new SlotPrivateEndpointConnectionId struct +func NewSlotPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, privateEndpointConnectionName string) SlotPrivateEndpointConnectionId { + return SlotPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseSlotPrivateEndpointConnectionID parses 'input' into a SlotPrivateEndpointConnectionId +func ParseSlotPrivateEndpointConnectionID(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a SlotPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotPrivateEndpointConnectionIDInsensitively(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPrivateEndpointConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateSlotPrivateEndpointConnectionID checks that 'input' can be parsed as a Slot Private Endpoint Connection ID +func ValidateSlotPrivateEndpointConnectionID(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 := ParseSlotPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Slot Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotprivateendpointconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_slotprivateendpointconnection_test.go new file mode 100644 index 00000000000..b7c1bd2958c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotprivateendpointconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPrivateEndpointConnectionId{} + +func TestNewSlotPrivateEndpointConnectionID(t *testing.T) { + id := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatSlotPrivateEndpointConnectionID(t *testing.T) { + actual := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseSlotPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForSlotPrivateEndpointConnectionId(t *testing.T) { + segments := SlotPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPrivateEndpointConnectionId 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/web/2024-04-01/webapps/id_slotprocess.go b/resource-manager/web/2024-04-01/webapps/id_slotprocess.go new file mode 100644 index 00000000000..98487bec6fc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotProcessId{}) +} + +var _ resourceids.ResourceId = &SlotProcessId{} + +// SlotProcessId is a struct representing the Resource ID for a Slot Process +type SlotProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string +} + +// NewSlotProcessID returns a new SlotProcessId struct +func NewSlotProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string) SlotProcessId { + return SlotProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + } +} + +// ParseSlotProcessID parses 'input' into a SlotProcessId +func ParseSlotProcessID(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotProcessIDInsensitively parses 'input' case-insensitively into a SlotProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotProcessIDInsensitively(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotProcessID checks that 'input' can be parsed as a Slot Process ID +func ValidateSlotProcessID(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 := ParseSlotProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Process ID +func (id SlotProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Process ID +func (id SlotProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Slot Process ID +func (id SlotProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotprocess_test.go b/resource-manager/web/2024-04-01/webapps/id_slotprocess_test.go new file mode 100644 index 00000000000..79324e032ca --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotProcessId{} + +func TestNewSlotProcessID(t *testing.T) { + id := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatSlotProcessID(t *testing.T) { + actual := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ProcessId: "pRoCeSsId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotProcessId(t *testing.T) { + segments := SlotProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotProcessId 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/web/2024-04-01/webapps/id_slotpubliccertificate.go b/resource-manager/web/2024-04-01/webapps/id_slotpubliccertificate.go new file mode 100644 index 00000000000..45ded508c35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotpubliccertificate.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotPublicCertificateId{}) +} + +var _ resourceids.ResourceId = &SlotPublicCertificateId{} + +// SlotPublicCertificateId is a struct representing the Resource ID for a Slot Public Certificate +type SlotPublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PublicCertificateName string +} + +// NewSlotPublicCertificateID returns a new SlotPublicCertificateId struct +func NewSlotPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, slotName string, publicCertificateName string) SlotPublicCertificateId { + return SlotPublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PublicCertificateName: publicCertificateName, + } +} + +// ParseSlotPublicCertificateID parses 'input' into a SlotPublicCertificateId +func ParseSlotPublicCertificateID(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPublicCertificateIDInsensitively parses 'input' case-insensitively into a SlotPublicCertificateId +// note: this method should only be used for API response data and not user input +func ParseSlotPublicCertificateIDInsensitively(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPublicCertificateId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidateSlotPublicCertificateID checks that 'input' can be parsed as a Slot Public Certificate ID +func ValidateSlotPublicCertificateID(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 := ParseSlotPublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Public Certificate ID +func (id SlotPublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Public Certificate ID +func (id SlotPublicCertificateId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateName"), + } +} + +// String returns a human-readable description of this Slot Public Certificate ID +func (id SlotPublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Slot Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotpubliccertificate_test.go b/resource-manager/web/2024-04-01/webapps/id_slotpubliccertificate_test.go new file mode 100644 index 00000000000..31f3e81c0fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotpubliccertificate_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPublicCertificateId{} + +func TestNewSlotPublicCertificateID(t *testing.T) { + id := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PublicCertificateName != "publicCertificateName" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateName") + } +} + +func TestFormatSlotPublicCertificateID(t *testing.T) { + actual := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParseSlotPublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PublicCertificateName: "pUbLiCcErTiFiCaTeNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForSlotPublicCertificateId(t *testing.T) { + segments := SlotPublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPublicCertificateId 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/web/2024-04-01/webapps/id_slotsitecontainer.go b/resource-manager/web/2024-04-01/webapps/id_slotsitecontainer.go new file mode 100644 index 00000000000..b1b7bd75011 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotsitecontainer.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotSitecontainerId{}) +} + +var _ resourceids.ResourceId = &SlotSitecontainerId{} + +// SlotSitecontainerId is a struct representing the Resource ID for a Slot Sitecontainer +type SlotSitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SitecontainerName string +} + +// NewSlotSitecontainerID returns a new SlotSitecontainerId struct +func NewSlotSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, slotName string, sitecontainerName string) SlotSitecontainerId { + return SlotSitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSlotSitecontainerID parses 'input' into a SlotSitecontainerId +func ParseSlotSitecontainerID(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSitecontainerIDInsensitively parses 'input' case-insensitively into a SlotSitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSlotSitecontainerIDInsensitively(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSitecontainerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSlotSitecontainerID checks that 'input' can be parsed as a Slot Sitecontainer ID +func ValidateSlotSitecontainerID(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 := ParseSlotSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Sitecontainer ID +func (id SlotSitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Sitecontainer ID +func (id SlotSitecontainerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerName"), + } +} + +// String returns a human-readable description of this Slot Sitecontainer ID +func (id SlotSitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Slot Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotsitecontainer_test.go b/resource-manager/web/2024-04-01/webapps/id_slotsitecontainer_test.go new file mode 100644 index 00000000000..c09df8600ea --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotsitecontainer_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotSitecontainerId{} + +func TestNewSlotSitecontainerID(t *testing.T) { + id := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SitecontainerName != "sitecontainerName" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerName") + } +} + +func TestFormatSlotSitecontainerID(t *testing.T) { + actual := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSlotSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SitecontainerName: "sItEcOnTaInErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSlotSitecontainerId(t *testing.T) { + segments := SlotSitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSitecontainerId 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/web/2024-04-01/webapps/id_slotsiteextension.go b/resource-manager/web/2024-04-01/webapps/id_slotsiteextension.go new file mode 100644 index 00000000000..5df295c09ba --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotsiteextension.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotSiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SlotSiteExtensionId{} + +// SlotSiteExtensionId is a struct representing the Resource ID for a Slot Site Extension +type SlotSiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SiteExtensionId string +} + +// NewSlotSiteExtensionID returns a new SlotSiteExtensionId struct +func NewSlotSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, siteExtensionId string) SlotSiteExtensionId { + return SlotSiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSlotSiteExtensionID parses 'input' into a SlotSiteExtensionId +func ParseSlotSiteExtensionID(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSiteExtensionIDInsensitively parses 'input' case-insensitively into a SlotSiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSlotSiteExtensionIDInsensitively(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSiteExtensionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSlotSiteExtensionID checks that 'input' can be parsed as a Slot Site Extension ID +func ValidateSlotSiteExtensionID(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 := ParseSlotSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Site Extension ID +func (id SlotSiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Site Extension ID +func (id SlotSiteExtensionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionId"), + } +} + +// String returns a human-readable description of this Slot Site Extension ID +func (id SlotSiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Slot Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotsiteextension_test.go b/resource-manager/web/2024-04-01/webapps/id_slotsiteextension_test.go new file mode 100644 index 00000000000..732d09fb195 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotsiteextension_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotSiteExtensionId{} + +func TestNewSlotSiteExtensionID(t *testing.T) { + id := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SiteExtensionId != "siteExtensionId" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionId") + } +} + +func TestFormatSlotSiteExtensionID(t *testing.T) { + actual := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSlotSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SiteExtensionId: "sItEeXtEnSiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSlotSiteExtensionId(t *testing.T) { + segments := SlotSiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSiteExtensionId 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/web/2024-04-01/webapps/id_slottriggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/id_slottriggeredwebjob.go new file mode 100644 index 00000000000..48ba81d16d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slottriggeredwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotTriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotTriggeredWebJobId{} + +// SlotTriggeredWebJobId is a struct representing the Resource ID for a Slot Triggered Web Job +type SlotTriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string +} + +// NewSlotTriggeredWebJobID returns a new SlotTriggeredWebJobId struct +func NewSlotTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string) SlotTriggeredWebJobId { + return SlotTriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseSlotTriggeredWebJobID parses 'input' into a SlotTriggeredWebJobId +func ParseSlotTriggeredWebJobID(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a SlotTriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotTriggeredWebJobIDInsensitively(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotTriggeredWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateSlotTriggeredWebJobID checks that 'input' can be parsed as a Slot Triggered Web Job ID +func ValidateSlotTriggeredWebJobID(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 := ParseSlotTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + } +} + +// String returns a human-readable description of this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Slot Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slottriggeredwebjob_test.go b/resource-manager/web/2024-04-01/webapps/id_slottriggeredwebjob_test.go new file mode 100644 index 00000000000..c7f66afaa1e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slottriggeredwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotTriggeredWebJobId{} + +func TestNewSlotTriggeredWebJobID(t *testing.T) { + id := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } +} + +func TestFormatSlotTriggeredWebJobID(t *testing.T) { + actual := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseSlotTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForSlotTriggeredWebJobId(t *testing.T) { + segments := SlotTriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotTriggeredWebJobId 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/web/2024-04-01/webapps/id_slotvirtualnetworkconnection.go b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnection.go new file mode 100644 index 00000000000..637d36cce57 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionId{} + +// SlotVirtualNetworkConnectionId is a struct representing the Resource ID for a Slot Virtual Network Connection +type SlotVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string +} + +// NewSlotVirtualNetworkConnectionID returns a new SlotVirtualNetworkConnectionId struct +func NewSlotVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string) SlotVirtualNetworkConnectionId { + return SlotVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseSlotVirtualNetworkConnectionID parses 'input' into a SlotVirtualNetworkConnectionId +func ParseSlotVirtualNetworkConnectionID(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionIDInsensitively(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionID checks that 'input' can be parsed as a Slot Virtual Network Connection ID +func ValidateSlotVirtualNetworkConnectionID(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 := ParseSlotVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Slot Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..623d47d5691 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotVirtualNetworkConnectionId{} + +func TestNewSlotVirtualNetworkConnectionID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatSlotVirtualNetworkConnectionID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionId(t *testing.T) { + segments := SlotVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionId 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/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway.go b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..8f808a13188 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionGatewayId{} + +// SlotVirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Slot Virtual Network Connection Gateway +type SlotVirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewSlotVirtualNetworkConnectionGatewayID returns a new SlotVirtualNetworkConnectionGatewayId struct +func NewSlotVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string, gatewayName string) SlotVirtualNetworkConnectionGatewayId { + return SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseSlotVirtualNetworkConnectionGatewayID parses 'input' into a SlotVirtualNetworkConnectionGatewayId +func ParseSlotVirtualNetworkConnectionGatewayID(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionGatewayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Slot Virtual Network Connection Gateway ID +func ValidateSlotVirtualNetworkConnectionGatewayID(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 := ParseSlotVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Slot Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..34baec3c9ca --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotVirtualNetworkConnectionGatewayId{} + +func TestNewSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := SlotVirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionGatewayId 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/web/2024-04-01/webapps/id_slotwebjob.go b/resource-manager/web/2024-04-01/webapps/id_slotwebjob.go new file mode 100644 index 00000000000..e9ea5bb00fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotWebJobId{} + +// SlotWebJobId is a struct representing the Resource ID for a Slot Web Job +type SlotWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WebJobName string +} + +// NewSlotWebJobID returns a new SlotWebJobId struct +func NewSlotWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, webJobName string) SlotWebJobId { + return SlotWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WebJobName: webJobName, + } +} + +// ParseSlotWebJobID parses 'input' into a SlotWebJobId +func ParseSlotWebJobID(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWebJobIDInsensitively parses 'input' case-insensitively into a SlotWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotWebJobIDInsensitively(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateSlotWebJobID checks that 'input' can be parsed as a Slot Web Job ID +func ValidateSlotWebJobID(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 := ParseSlotWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Web Job ID +func (id SlotWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Web Job ID +func (id SlotWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobName"), + } +} + +// String returns a human-readable description of this Slot Web Job ID +func (id SlotWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Slot Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotwebjob_test.go b/resource-manager/web/2024-04-01/webapps/id_slotwebjob_test.go new file mode 100644 index 00000000000..66396ef164e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotWebJobId{} + +func TestNewSlotWebJobID(t *testing.T) { + id := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.WebJobName != "webJobName" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobName") + } +} + +func TestFormatSlotWebJobID(t *testing.T) { + actual := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseSlotWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs/wEbJoBnAmE", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + WebJobName: "wEbJoBnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs/wEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForSlotWebJobId(t *testing.T) { + segments := SlotWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWebJobId 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/web/2024-04-01/webapps/id_slotworkflow.go b/resource-manager/web/2024-04-01/webapps/id_slotworkflow.go new file mode 100644 index 00000000000..a14291749c9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotworkflow.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SlotWorkflowId{}) +} + +var _ resourceids.ResourceId = &SlotWorkflowId{} + +// SlotWorkflowId is a struct representing the Resource ID for a Slot Workflow +type SlotWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WorkflowName string +} + +// NewSlotWorkflowID returns a new SlotWorkflowId struct +func NewSlotWorkflowID(subscriptionId string, resourceGroupName string, siteName string, slotName string, workflowName string) SlotWorkflowId { + return SlotWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WorkflowName: workflowName, + } +} + +// ParseSlotWorkflowID parses 'input' into a SlotWorkflowId +func ParseSlotWorkflowID(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWorkflowIDInsensitively parses 'input' case-insensitively into a SlotWorkflowId +// note: this method should only be used for API response data and not user input +func ParseSlotWorkflowIDInsensitively(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateSlotWorkflowID checks that 'input' can be parsed as a Slot Workflow ID +func ValidateSlotWorkflowID(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 := ParseSlotWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Workflow ID +func (id SlotWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Workflow ID +func (id SlotWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Slot Workflow ID +func (id SlotWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Slot Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_slotworkflow_test.go b/resource-manager/web/2024-04-01/webapps/id_slotworkflow_test.go new file mode 100644 index 00000000000..dea7721f260 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_slotworkflow_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotWorkflowId{} + +func TestNewSlotWorkflowID(t *testing.T) { + id := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatSlotWorkflowID(t *testing.T) { + actual := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseSlotWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForSlotWorkflowId(t *testing.T) { + segments := SlotWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWorkflowId 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/web/2024-04-01/webapps/id_snapshot.go b/resource-manager/web/2024-04-01/webapps/id_snapshot.go new file mode 100644 index 00000000000..4d03d32a391 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_snapshot.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SnapshotId{}) +} + +var _ resourceids.ResourceId = &SnapshotId{} + +// SnapshotId is a struct representing the Resource ID for a Snapshot +type SnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SnapshotId string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, siteName string, snapshotId string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SnapshotId: snapshotId, + } +} + +// ParseSnapshotID parses 'input' into a SnapshotId +func ParseSnapshotID(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotIDInsensitively parses 'input' case-insensitively into a SnapshotId +// note: this method should only be used for API response data and not user input +func ParseSnapshotIDInsensitively(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateSnapshotID checks that 'input' can be parsed as a Snapshot ID +func ValidateSnapshotID(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 := ParseSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot ID +func (id SnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot ID +func (id SnapshotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotId"), + } +} + +// String returns a human-readable description of this Snapshot ID +func (id SnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_snapshot_test.go b/resource-manager/web/2024-04-01/webapps/id_snapshot_test.go new file mode 100644 index 00000000000..266ebd16516 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_snapshot_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &SnapshotId{} + +func TestNewSnapshotID(t *testing.T) { + id := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SnapshotId != "snapshotId" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotId") + } +} + +func TestFormatSnapshotID(t *testing.T) { + actual := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SnapshotId: "sNaPsHoTiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForSnapshotId(t *testing.T) { + segments := SnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotId 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/web/2024-04-01/webapps/id_triggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjob.go new file mode 100644 index 00000000000..54e4277f8e3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobId{} + +// TriggeredWebJobId is a struct representing the Resource ID for a Triggered Web Job +type TriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string +} + +// NewTriggeredWebJobID returns a new TriggeredWebJobId struct +func NewTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string) TriggeredWebJobId { + return TriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseTriggeredWebJobID parses 'input' into a TriggeredWebJobId +func ParseTriggeredWebJobID(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobIDInsensitively(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateTriggeredWebJobID checks that 'input' can be parsed as a Triggered Web Job ID +func ValidateTriggeredWebJobID(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 := ParseTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job ID +func (id TriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job ID +func (id TriggeredWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + } +} + +// String returns a human-readable description of this Triggered Web Job ID +func (id TriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_triggeredwebjob_test.go b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjob_test.go new file mode 100644 index 00000000000..f3a39e32c7e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &TriggeredWebJobId{} + +func TestNewTriggeredWebJobID(t *testing.T) { + id := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } +} + +func TestFormatTriggeredWebJobID(t *testing.T) { + actual := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForTriggeredWebJobId(t *testing.T) { + segments := TriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobId 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/web/2024-04-01/webapps/id_triggeredwebjobhistory.go b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjobhistory.go new file mode 100644 index 00000000000..d43eee154da --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjobhistory.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobHistoryId{} + +// TriggeredWebJobHistoryId is a struct representing the Resource ID for a Triggered Web Job History +type TriggeredWebJobHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string + HistoryName string +} + +// NewTriggeredWebJobHistoryID returns a new TriggeredWebJobHistoryId struct +func NewTriggeredWebJobHistoryID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string, historyName string) TriggeredWebJobHistoryId { + return TriggeredWebJobHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseTriggeredWebJobHistoryID parses 'input' into a TriggeredWebJobHistoryId +func ParseTriggeredWebJobHistoryID(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobHistoryIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobHistoryIDInsensitively(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggeredWebJobHistoryID checks that 'input' can be parsed as a Triggered Web Job History ID +func ValidateTriggeredWebJobHistoryID(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 := ParseTriggeredWebJobHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Triggered Web Job History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_triggeredwebjobhistory_test.go b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjobhistory_test.go new file mode 100644 index 00000000000..cf92a965a0a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_triggeredwebjobhistory_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &TriggeredWebJobHistoryId{} + +func TestNewTriggeredWebJobHistoryID(t *testing.T) { + id := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatTriggeredWebJobHistoryID(t *testing.T) { + actual := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggeredWebJobHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggeredWebJobHistoryId(t *testing.T) { + segments := TriggeredWebJobHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobHistoryId 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/web/2024-04-01/webapps/id_virtualnetworkconnection.go b/resource-manager/web/2024-04-01/webapps/id_virtualnetworkconnection.go new file mode 100644 index 00000000000..0ddc9e9dbc9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_virtualnetworkconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionId{} + +// VirtualNetworkConnectionId is a struct representing the Resource ID for a Virtual Network Connection +type VirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string +} + +// NewVirtualNetworkConnectionID returns a new VirtualNetworkConnectionId struct +func NewVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string) VirtualNetworkConnectionId { + return VirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseVirtualNetworkConnectionID parses 'input' into a VirtualNetworkConnectionId +func ParseVirtualNetworkConnectionID(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionIDInsensitively(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionID checks that 'input' can be parsed as a Virtual Network Connection ID +func ValidateVirtualNetworkConnectionID(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 := ParseVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection ID +func (id VirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_virtualnetworkconnection_test.go b/resource-manager/web/2024-04-01/webapps/id_virtualnetworkconnection_test.go new file mode 100644 index 00000000000..0696a175e00 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_virtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &VirtualNetworkConnectionId{} + +func TestNewVirtualNetworkConnectionID(t *testing.T) { + id := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatVirtualNetworkConnectionID(t *testing.T) { + actual := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionId(t *testing.T) { + segments := VirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionId 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/web/2024-04-01/webapps/id_webjob.go b/resource-manager/web/2024-04-01/webapps/id_webjob.go new file mode 100644 index 00000000000..b79bed51622 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_webjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WebJobId{}) +} + +var _ resourceids.ResourceId = &WebJobId{} + +// WebJobId is a struct representing the Resource ID for a Web Job +type WebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WebJobName string +} + +// NewWebJobID returns a new WebJobId struct +func NewWebJobID(subscriptionId string, resourceGroupName string, siteName string, webJobName string) WebJobId { + return WebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WebJobName: webJobName, + } +} + +// ParseWebJobID parses 'input' into a WebJobId +func ParseWebJobID(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebJobIDInsensitively parses 'input' case-insensitively into a WebJobId +// note: this method should only be used for API response data and not user input +func ParseWebJobIDInsensitively(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateWebJobID checks that 'input' can be parsed as a Web Job ID +func ValidateWebJobID(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 := ParseWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Job ID +func (id WebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Job ID +func (id WebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobName"), + } +} + +// String returns a human-readable description of this Web Job ID +func (id WebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_webjob_test.go b/resource-manager/web/2024-04-01/webapps/id_webjob_test.go new file mode 100644 index 00000000000..092af0c8a38 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_webjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &WebJobId{} + +func TestNewWebJobID(t *testing.T) { + id := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WebJobName != "webJobName" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobName") + } +} + +func TestFormatWebJobID(t *testing.T) { + actual := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wEbJoBs/wEbJoBnAmE", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WebJobName: "wEbJoBnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/wEbJoBs/wEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForWebJobId(t *testing.T) { + segments := WebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebJobId 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/web/2024-04-01/webapps/id_websnapshot.go b/resource-manager/web/2024-04-01/webapps/id_websnapshot.go new file mode 100644 index 00000000000..f878f0869f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_websnapshot.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WebSnapshotId{}) +} + +var _ resourceids.ResourceId = &WebSnapshotId{} + +// WebSnapshotId is a struct representing the Resource ID for a Web Snapshot +type WebSnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SnapshotId string +} + +// NewWebSnapshotID returns a new WebSnapshotId struct +func NewWebSnapshotID(subscriptionId string, resourceGroupName string, siteName string, slotName string, snapshotId string) WebSnapshotId { + return WebSnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SnapshotId: snapshotId, + } +} + +// ParseWebSnapshotID parses 'input' into a WebSnapshotId +func ParseWebSnapshotID(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebSnapshotIDInsensitively parses 'input' case-insensitively into a WebSnapshotId +// note: this method should only be used for API response data and not user input +func ParseWebSnapshotIDInsensitively(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebSnapshotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateWebSnapshotID checks that 'input' can be parsed as a Web Snapshot ID +func ValidateWebSnapshotID(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 := ParseWebSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Snapshot ID +func (id WebSnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Snapshot ID +func (id WebSnapshotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotId"), + } +} + +// String returns a human-readable description of this Web Snapshot ID +func (id WebSnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Web Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_websnapshot_test.go b/resource-manager/web/2024-04-01/webapps/id_websnapshot_test.go new file mode 100644 index 00000000000..b63a5759cb5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_websnapshot_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &WebSnapshotId{} + +func TestNewWebSnapshotID(t *testing.T) { + id := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SnapshotId != "snapshotId" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotId") + } +} + +func TestFormatWebSnapshotID(t *testing.T) { + actual := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseWebSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SnapshotId: "sNaPsHoTiD", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForWebSnapshotId(t *testing.T) { + segments := WebSnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebSnapshotId 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/web/2024-04-01/webapps/id_workflow.go b/resource-manager/web/2024-04-01/webapps/id_workflow.go new file mode 100644 index 00000000000..b0bd85b2a72 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_workflow.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&WorkflowId{}) +} + +var _ resourceids.ResourceId = &WorkflowId{} + +// WorkflowId is a struct representing the Resource ID for a Workflow +type WorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewWorkflowID returns a new WorkflowId struct +func NewWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) WorkflowId { + return WorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseWorkflowID parses 'input' into a WorkflowId +func ParseWorkflowID(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkflowIDInsensitively parses 'input' case-insensitively into a WorkflowId +// note: this method should only be used for API response data and not user input +func ParseWorkflowIDInsensitively(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateWorkflowID checks that 'input' can be parsed as a Workflow ID +func ValidateWorkflowID(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 := ParseWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workflow ID +func (id WorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workflow ID +func (id WorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Workflow ID +func (id WorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/webapps/id_workflow_test.go b/resource-manager/web/2024-04-01/webapps/id_workflow_test.go new file mode 100644 index 00000000000..c687bb8ce0f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/id_workflow_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &WorkflowId{} + +func TestNewWorkflowID(t *testing.T) { + id := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatWorkflowID(t *testing.T) { + actual := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForWorkflowId(t *testing.T) { + segments := WorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkflowId 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/web/2024-04-01/webapps/method_addpremieraddon.go b/resource-manager/web/2024-04-01/webapps/method_addpremieraddon.go new file mode 100644 index 00000000000..cfb57af1bf6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_addpremieraddon.go @@ -0,0 +1,57 @@ +package webapps + +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 AddPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOn ... +func (c WebAppsClient) AddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (result AddPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_addpremieraddonslot.go b/resource-manager/web/2024-04-01/webapps/method_addpremieraddonslot.go new file mode 100644 index 00000000000..aeafde304bb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_addpremieraddonslot.go @@ -0,0 +1,57 @@ +package webapps + +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 AddPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOnSlot ... +func (c WebAppsClient) AddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (result AddPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostname.go b/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostname.go new file mode 100644 index 00000000000..11970d2903f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostname.go @@ -0,0 +1,84 @@ +package webapps + +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 AnalyzeCustomHostnameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameOperationOptions() AnalyzeCustomHostnameOperationOptions { + return AnalyzeCustomHostnameOperationOptions{} +} + +func (o AnalyzeCustomHostnameOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostname ... +func (c WebAppsClient) AnalyzeCustomHostname(ctx context.Context, id commonids.AppServiceId, options AnalyzeCustomHostnameOperationOptions) (result AnalyzeCustomHostnameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/analyzeCustomHostname", 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 + } + + var model CustomHostnameAnalysisResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostnameslot.go b/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostnameslot.go new file mode 100644 index 00000000000..b2430c9f9ba --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_analyzecustomhostnameslot.go @@ -0,0 +1,83 @@ +package webapps + +import ( + "context" + "fmt" + "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 AnalyzeCustomHostnameSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameSlotOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameSlotOperationOptions() AnalyzeCustomHostnameSlotOperationOptions { + return AnalyzeCustomHostnameSlotOperationOptions{} +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostnameSlot ... +func (c WebAppsClient) AnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/analyzeCustomHostname", 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 + } + + var model CustomHostnameAnalysisResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_applyslotconfigtoproduction.go b/resource-manager/web/2024-04-01/webapps/method_applyslotconfigtoproduction.go new file mode 100644 index 00000000000..8a4030be7ce --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_applyslotconfigtoproduction.go @@ -0,0 +1,52 @@ +package webapps + +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 ApplySlotConfigToProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigToProduction ... +func (c WebAppsClient) ApplySlotConfigToProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ApplySlotConfigToProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_applyslotconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_applyslotconfigurationslot.go new file mode 100644 index 00000000000..a17a32e4ddb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_applyslotconfigurationslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 ApplySlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigurationSlot ... +func (c WebAppsClient) ApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ApplySlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..11c42e04fc1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnectionslot.go new file mode 100644 index 00000000000..92ad203c214 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_approveorrejectprivateendpointconnectionslot.go @@ -0,0 +1,75 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnectionSlot ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionSlotThenPoll performs ApproveOrRejectPrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_backup.go b/resource-manager/web/2024-04-01/webapps/method_backup.go new file mode 100644 index 00000000000..c1c49689e19 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_backup.go @@ -0,0 +1,59 @@ +package webapps + +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 BackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// Backup ... +func (c WebAppsClient) Backup(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_backupslot.go b/resource-manager/web/2024-04-01/webapps/method_backupslot.go new file mode 100644 index 00000000000..bb5f136eda5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_backupslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 BackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// BackupSlot ... +func (c WebAppsClient) BackupSlot(ctx context.Context, id SlotId, input BackupRequest) (result BackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createdeployment.go b/resource-manager/web/2024-04-01/webapps/method_createdeployment.go new file mode 100644 index 00000000000..942b704fb67 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createdeployment.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeployment ... +func (c WebAppsClient) CreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (result CreateDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createdeploymentslot.go b/resource-manager/web/2024-04-01/webapps/method_createdeploymentslot.go new file mode 100644 index 00000000000..69c846f798e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createdeploymentslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeploymentSlot ... +func (c WebAppsClient) CreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (result CreateDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createfunction.go b/resource-manager/web/2024-04-01/webapps/method_createfunction.go new file mode 100644 index 00000000000..43f93d7412e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createfunction.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateFunction ... +func (c WebAppsClient) CreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (result CreateFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateFunctionThenPoll performs CreateFunction then polls until it's completed +func (c WebAppsClient) CreateFunctionThenPoll(ctx context.Context, id FunctionId, input FunctionEnvelope) error { + result, err := c.CreateFunction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createinstancefunctionslot.go b/resource-manager/web/2024-04-01/webapps/method_createinstancefunctionslot.go new file mode 100644 index 00000000000..7a4fc6b316e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createinstancefunctionslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceFunctionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateInstanceFunctionSlot ... +func (c WebAppsClient) CreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (result CreateInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateInstanceFunctionSlotThenPoll performs CreateInstanceFunctionSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceFunctionSlotThenPoll(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) error { + result, err := c.CreateInstanceFunctionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceFunctionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceFunctionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperation.go b/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperation.go new file mode 100644 index 00000000000..f2335f4f87d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperation.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperation ... +func (c WebAppsClient) CreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationThenPoll performs CreateInstanceMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationThenPoll(ctx context.Context, id InstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperationslot.go b/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperationslot.go new file mode 100644 index 00000000000..3688efbb8d8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createinstancemsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperationSlot ... +func (c WebAppsClient) CreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationSlotThenPoll performs CreateInstanceMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationSlotThenPoll(ctx context.Context, id SlotInstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperation.go b/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperation.go new file mode 100644 index 00000000000..d6d6f41436d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperation.go @@ -0,0 +1,75 @@ +package webapps + +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 CreateMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperation ... +func (c WebAppsClient) CreateMSDeployOperation(ctx context.Context, id commonids.AppServiceId, input MSDeploy) (result CreateMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationThenPoll performs CreateMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationThenPoll(ctx context.Context, id commonids.AppServiceId, input MSDeploy) error { + result, err := c.CreateMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperationslot.go b/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperationslot.go new file mode 100644 index 00000000000..429022fa814 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createmsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperationSlot ... +func (c WebAppsClient) CreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (result CreateMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationSlotThenPoll performs CreateMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationSlotThenPoll(ctx context.Context, id SlotId, input MSDeploy) error { + result, err := c.CreateMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createonedeployoperation.go b/resource-manager/web/2024-04-01/webapps/method_createonedeployoperation.go new file mode 100644 index 00000000000..d313d5b7340 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createonedeployoperation.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOneDeployOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// CreateOneDeployOperation ... +func (c WebAppsClient) CreateOneDeployOperation(ctx context.Context, id commonids.AppServiceId) (result CreateOneDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/onedeploy", 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 + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdate.go b/resource-manager/web/2024-04-01/webapps/method_createorupdate.go new file mode 100644 index 00000000000..31581cafbd5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdate.go @@ -0,0 +1,76 @@ +package webapps + +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 + Model *Site +} + +// CreateOrUpdate ... +func (c WebAppsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceId, input Site) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 WebAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceId, input Site) 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/web/2024-04-01/webapps/method_createorupdateconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_createorupdateconfiguration.go new file mode 100644 index 00000000000..85500fcf708 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdateconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfiguration ... +func (c WebAppsClient) CreateOrUpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result CreateOrUpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdateconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdateconfigurationslot.go new file mode 100644 index 00000000000..b41a356aa13 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdateconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfigurationSlot ... +func (c WebAppsClient) CreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifier.go new file mode 100644 index 00000000000..cf70725a9a9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifier.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifierslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..001554898ac --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatedomainownershipidentifierslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecret.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecret.go new file mode 100644 index 00000000000..92497573560 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecret.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecret ... +func (c WebAppsClient) CreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretOperationResponse, 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 + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecretslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecretslot.go new file mode 100644 index 00000000000..0540fca8947 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatefunctionsecretslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecretSlot ... +func (c WebAppsClient) CreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretSlotOperationResponse, 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 + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebinding.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebinding.go new file mode 100644 index 00000000000..3a47a4207d0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebinding.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBinding ... +func (c WebAppsClient) CreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebindingslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebindingslot.go new file mode 100644 index 00000000000..f0746cde4e6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostnamebindingslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBindingSlot ... +func (c WebAppsClient) CreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecret.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecret.go new file mode 100644 index 00000000000..1b3b65509c9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecret.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecret ... +func (c WebAppsClient) CreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (result CreateOrUpdateHostSecretOperationResponse, 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 + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecretslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecretslot.go new file mode 100644 index 00000000000..f9bbc6bef55 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehostsecretslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecretSlot ... +func (c WebAppsClient) CreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (result CreateOrUpdateHostSecretSlotOperationResponse, 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 + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnection.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnection.go new file mode 100644 index 00000000000..5c7b767edf5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnection ... +func (c WebAppsClient) CreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnectionslot.go new file mode 100644 index 00000000000..480ee3d1593 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatehybridconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificate.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificate.go new file mode 100644 index 00000000000..b9aaaedb0d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificate.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdatePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificate ... +func (c WebAppsClient) CreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificateslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificateslot.go new file mode 100644 index 00000000000..b53ffdea524 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatepubliccertificateslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdatePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificateSlot ... +func (c WebAppsClient) CreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnection.go b/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnection.go new file mode 100644 index 00000000000..8cd02d31bd7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnection ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..ade59122646 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdaterelayserviceconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainer.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainer.go new file mode 100644 index 00000000000..dfcf5fb0bf7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainer.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainer ... +func (c WebAppsClient) CreateOrUpdateSiteContainer(ctx context.Context, id SitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerOperationResponse, 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 + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainerslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainerslot.go new file mode 100644 index 00000000000..d122bbc52da --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatesitecontainerslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainerSlot ... +func (c WebAppsClient) CreateOrUpdateSiteContainerSlot(ctx context.Context, id SlotSitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerSlotOperationResponse, 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 + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdateslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdateslot.go new file mode 100644 index 00000000000..3ab93dcea61 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdateslot.go @@ -0,0 +1,75 @@ +package webapps + +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 CreateOrUpdateSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdateSlot ... +func (c WebAppsClient) CreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (result CreateOrUpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateSlotThenPoll performs CreateOrUpdateSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSlotThenPoll(ctx context.Context, id SlotId, input Site) error { + result, err := c.CreateOrUpdateSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrol.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrol.go new file mode 100644 index 00000000000..6c883f15851 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrol.go @@ -0,0 +1,77 @@ +package webapps + +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 CreateOrUpdateSourceControlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControl ... +func (c WebAppsClient) CreateOrUpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result CreateOrUpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlThenPoll performs CreateOrUpdateSourceControl then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlThenPoll(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControl(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControl: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControl: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrolslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrolslot.go new file mode 100644 index 00000000000..aa82d5d4811 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatesourcecontrolslot.go @@ -0,0 +1,76 @@ +package webapps + +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 CreateOrUpdateSourceControlSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControlSlot ... +func (c WebAppsClient) CreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result CreateOrUpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlSlotThenPoll performs CreateOrUpdateSourceControlSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlSlotThenPoll(ctx context.Context, id SlotId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControlSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControlSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControlSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..fcc6949b431 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..d5f3050db94 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnection.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnection.go new file mode 100644 index 00000000000..2b041462b62 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnection ... +func (c WebAppsClient) CreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongateway.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongateway.go new file mode 100644 index 00000000000..0f1c95c3f39 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongateway.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGateway ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongatewayslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..d09166ca8e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectiongatewayslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectionslot.go new file mode 100644 index 00000000000..ca68e315257 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_createorupdatevnetconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 CreateOrUpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_delete.go b/resource-manager/web/2024-04-01/webapps/method_delete.go new file mode 100644 index 00000000000..9849348f6db --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_delete.go @@ -0,0 +1,82 @@ +package webapps + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// Delete ... +func (c WebAppsClient) Delete(ctx context.Context, id commonids.AppServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletebackup.go b/resource-manager/web/2024-04-01/webapps/method_deletebackup.go new file mode 100644 index 00000000000..b2335e64953 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletebackup.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackup ... +func (c WebAppsClient) DeleteBackup(ctx context.Context, id BackupId) (result DeleteBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletebackupconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_deletebackupconfiguration.go new file mode 100644 index 00000000000..fe9d53c8236 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletebackupconfiguration.go @@ -0,0 +1,48 @@ +package webapps + +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 DeleteBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfiguration ... +func (c WebAppsClient) DeleteBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result DeleteBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletebackupconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_deletebackupconfigurationslot.go new file mode 100644 index 00000000000..e417eec9042 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletebackupconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfigurationSlot ... +func (c WebAppsClient) DeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (result DeleteBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletebackupslot.go b/resource-manager/web/2024-04-01/webapps/method_deletebackupslot.go new file mode 100644 index 00000000000..42f5d96f9bb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletebackupslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupSlot ... +func (c WebAppsClient) DeleteBackupSlot(ctx context.Context, id SlotBackupId) (result DeleteBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjob.go b/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjob.go new file mode 100644 index 00000000000..291bdb8bdb2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJob ... +func (c WebAppsClient) DeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result DeleteContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjobslot.go new file mode 100644 index 00000000000..08d6fbcf7ce --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletecontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJobSlot ... +func (c WebAppsClient) DeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result DeleteContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletedeployment.go b/resource-manager/web/2024-04-01/webapps/method_deletedeployment.go new file mode 100644 index 00000000000..602496fecbe --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletedeployment.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeployment ... +func (c WebAppsClient) DeleteDeployment(ctx context.Context, id DeploymentId) (result DeleteDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletedeploymentslot.go b/resource-manager/web/2024-04-01/webapps/method_deletedeploymentslot.go new file mode 100644 index 00000000000..dcc3d21bbd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletedeploymentslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeploymentSlot ... +func (c WebAppsClient) DeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result DeleteDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifier.go new file mode 100644 index 00000000000..06a3c4983b6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifier.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifier ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifierslot.go b/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifierslot.go new file mode 100644 index 00000000000..28567f8ab9e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletedomainownershipidentifierslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletefunction.go b/resource-manager/web/2024-04-01/webapps/method_deletefunction.go new file mode 100644 index 00000000000..63c737693dd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletefunction.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunction ... +func (c WebAppsClient) DeleteFunction(ctx context.Context, id FunctionId) (result DeleteFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecret.go b/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecret.go new file mode 100644 index 00000000000..279dac44b09 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecret ... +func (c WebAppsClient) DeleteFunctionSecret(ctx context.Context, id KeyId) (result DeleteFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecretslot.go b/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecretslot.go new file mode 100644 index 00000000000..048a7322039 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletefunctionsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecretSlot ... +func (c WebAppsClient) DeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (result DeleteFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehostnamebinding.go b/resource-manager/web/2024-04-01/webapps/method_deletehostnamebinding.go new file mode 100644 index 00000000000..f41070632fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehostnamebinding.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBinding ... +func (c WebAppsClient) DeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (result DeleteHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehostnamebindingslot.go b/resource-manager/web/2024-04-01/webapps/method_deletehostnamebindingslot.go new file mode 100644 index 00000000000..f780f65c797 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehostnamebindingslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBindingSlot ... +func (c WebAppsClient) DeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result DeleteHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehostsecret.go b/resource-manager/web/2024-04-01/webapps/method_deletehostsecret.go new file mode 100644 index 00000000000..f7140877326 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehostsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecret ... +func (c WebAppsClient) DeleteHostSecret(ctx context.Context, id DefaultId) (result DeleteHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehostsecretslot.go b/resource-manager/web/2024-04-01/webapps/method_deletehostsecretslot.go new file mode 100644 index 00000000000..7b2feaf96f1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehostsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecretSlot ... +func (c WebAppsClient) DeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (result DeleteHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehybridconnection.go b/resource-manager/web/2024-04-01/webapps/method_deletehybridconnection.go new file mode 100644 index 00000000000..4c59c6746f2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehybridconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c WebAppsClient) DeleteHybridConnection(ctx context.Context, id RelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletehybridconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_deletehybridconnectionslot.go new file mode 100644 index 00000000000..e5cd0c8f8ef --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletehybridconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnectionSlot ... +func (c WebAppsClient) DeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result DeleteHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteinstancefunctionslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteinstancefunctionslot.go new file mode 100644 index 00000000000..b69048fa682 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteinstancefunctionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceFunctionSlot ... +func (c WebAppsClient) DeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result DeleteInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocess.go b/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocess.go new file mode 100644 index 00000000000..1f48c5d2ee7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcess ... +func (c WebAppsClient) DeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (result DeleteInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocessslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocessslot.go new file mode 100644 index 00000000000..4a86b938433 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteinstanceprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcessSlot ... +func (c WebAppsClient) DeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result DeleteInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletepremieraddon.go b/resource-manager/web/2024-04-01/webapps/method_deletepremieraddon.go new file mode 100644 index 00000000000..add6d111d1d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletepremieraddon.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOn ... +func (c WebAppsClient) DeletePremierAddOn(ctx context.Context, id PremierAddonId) (result DeletePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletepremieraddonslot.go b/resource-manager/web/2024-04-01/webapps/method_deletepremieraddonslot.go new file mode 100644 index 00000000000..e2e6333e3c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletepremieraddonslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOnSlot ... +func (c WebAppsClient) DeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result DeletePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f5b956958aa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package webapps + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c WebAppsClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnectionslot.go new file mode 100644 index 00000000000..61bbf74e21d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteprivateendpointconnectionslot.go @@ -0,0 +1,72 @@ +package webapps + +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 DeletePrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnectionSlot ... +func (c WebAppsClient) DeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionSlotThenPoll performs DeletePrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnectionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteprocess.go b/resource-manager/web/2024-04-01/webapps/method_deleteprocess.go new file mode 100644 index 00000000000..e925942300c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcess ... +func (c WebAppsClient) DeleteProcess(ctx context.Context, id ProcessId) (result DeleteProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteprocessslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteprocessslot.go new file mode 100644 index 00000000000..da7cb778e03 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcessSlot ... +func (c WebAppsClient) DeleteProcessSlot(ctx context.Context, id SlotProcessId) (result DeleteProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificate.go b/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificate.go new file mode 100644 index 00000000000..8b04d322801 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificate.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificate ... +func (c WebAppsClient) DeletePublicCertificate(ctx context.Context, id PublicCertificateId) (result DeletePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificateslot.go b/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificateslot.go new file mode 100644 index 00000000000..98fca6889bf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletepubliccertificateslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificateSlot ... +func (c WebAppsClient) DeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result DeletePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnection.go b/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnection.go new file mode 100644 index 00000000000..be9ded1355d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnection ... +func (c WebAppsClient) DeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result DeleteRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnectionslot.go new file mode 100644 index 00000000000..42eccd7e9f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleterelayserviceconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnectionSlot ... +func (c WebAppsClient) DeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesitecontainer.go b/resource-manager/web/2024-04-01/webapps/method_deletesitecontainer.go new file mode 100644 index 00000000000..ea860f567ef --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesitecontainer.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainer ... +func (c WebAppsClient) DeleteSiteContainer(ctx context.Context, id SitecontainerId) (result DeleteSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesitecontainerslot.go b/resource-manager/web/2024-04-01/webapps/method_deletesitecontainerslot.go new file mode 100644 index 00000000000..f3ad5aa1a72 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesitecontainerslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainerSlot ... +func (c WebAppsClient) DeleteSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result DeleteSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesiteextension.go b/resource-manager/web/2024-04-01/webapps/method_deletesiteextension.go new file mode 100644 index 00000000000..525f7419d0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesiteextension.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtension ... +func (c WebAppsClient) DeleteSiteExtension(ctx context.Context, id SiteExtensionId) (result DeleteSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesiteextensionslot.go b/resource-manager/web/2024-04-01/webapps/method_deletesiteextensionslot.go new file mode 100644 index 00000000000..cad4ab2271e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesiteextensionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtensionSlot ... +func (c WebAppsClient) DeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result DeleteSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteslot.go new file mode 100644 index 00000000000..67b4c2dcc06 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteslot.go @@ -0,0 +1,81 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSlotOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteSlotOperationOptions() DeleteSlotOperationOptions { + return DeleteSlotOperationOptions{} +} + +func (o DeleteSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// DeleteSlot ... +func (c WebAppsClient) DeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (result DeleteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrol.go b/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrol.go new file mode 100644 index 00000000000..dd5b73ad1b4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrol.go @@ -0,0 +1,78 @@ +package webapps + +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 DeleteSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlOperationOptions() DeleteSourceControlOperationOptions { + return DeleteSourceControlOperationOptions{} +} + +func (o DeleteSourceControlOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControl ... +func (c WebAppsClient) DeleteSourceControl(ctx context.Context, id commonids.AppServiceId, options DeleteSourceControlOperationOptions) (result DeleteSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrolslot.go b/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrolslot.go new file mode 100644 index 00000000000..45220bcdbd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletesourcecontrolslot.go @@ -0,0 +1,77 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlSlotOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlSlotOperationOptions() DeleteSourceControlSlotOperationOptions { + return DeleteSourceControlSlotOperationOptions{} +} + +func (o DeleteSourceControlSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControlSlot ... +func (c WebAppsClient) DeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (result DeleteSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetwork.go b/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetwork.go new file mode 100644 index 00000000000..5f7c911990a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetwork.go @@ -0,0 +1,48 @@ +package webapps + +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 DeleteSwiftVirtualNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetwork ... +func (c WebAppsClient) DeleteSwiftVirtualNetwork(ctx context.Context, id commonids.AppServiceId) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetworkslot.go b/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetworkslot.go new file mode 100644 index 00000000000..a63702c17c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deleteswiftvirtualnetworkslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSwiftVirtualNetworkSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetworkSlot ... +func (c WebAppsClient) DeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjob.go new file mode 100644 index 00000000000..c09a8a7cdcf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJob ... +func (c WebAppsClient) DeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result DeleteTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjobslot.go new file mode 100644 index 00000000000..c9aa75af711 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletetriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJobSlot ... +func (c WebAppsClient) DeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletevnetconnection.go b/resource-manager/web/2024-04-01/webapps/method_deletevnetconnection.go new file mode 100644 index 00000000000..09e001b1b8a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletevnetconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnection ... +func (c WebAppsClient) DeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result DeleteVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deletevnetconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_deletevnetconnectionslot.go new file mode 100644 index 00000000000..eb208686b5d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deletevnetconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnectionSlot ... +func (c WebAppsClient) DeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result DeleteVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifacts.go b/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifacts.go new file mode 100644 index 00000000000..8b6316e6292 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifacts.go @@ -0,0 +1,52 @@ +package webapps + +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 DeployWorkflowArtifactsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifacts ... +func (c WebAppsClient) DeployWorkflowArtifacts(ctx context.Context, id commonids.AppServiceId, input WorkflowArtifacts) (result DeployWorkflowArtifactsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifactsslot.go b/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifactsslot.go new file mode 100644 index 00000000000..86a6bd816b5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_deployworkflowartifactsslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeployWorkflowArtifactsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifactsSlot ... +func (c WebAppsClient) DeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_discoverbackup.go b/resource-manager/web/2024-04-01/webapps/method_discoverbackup.go new file mode 100644 index 00000000000..85b417c4364 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_discoverbackup.go @@ -0,0 +1,59 @@ +package webapps + +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 DiscoverBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackup ... +func (c WebAppsClient) DiscoverBackup(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result DiscoverBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", 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 + } + + var model RestoreRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_discoverbackupslot.go b/resource-manager/web/2024-04-01/webapps/method_discoverbackupslot.go new file mode 100644 index 00000000000..bc2c9a593cb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_discoverbackupslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 DiscoverBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackupSlot ... +func (c WebAppsClient) DiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (result DiscoverBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", 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 + } + + var model RestoreRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpassword.go b/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpassword.go new file mode 100644 index 00000000000..6e02a601437 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpassword.go @@ -0,0 +1,49 @@ +package webapps + +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 GenerateNewSitePublishingPasswordOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPassword ... +func (c WebAppsClient) GenerateNewSitePublishingPassword(ctx context.Context, id commonids.AppServiceId) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpasswordslot.go b/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpasswordslot.go new file mode 100644 index 00000000000..71e052a00e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_generatenewsitepublishingpasswordslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 GenerateNewSitePublishingPasswordSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPasswordSlot ... +func (c WebAppsClient) GenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_get.go b/resource-manager/web/2024-04-01/webapps/method_get.go new file mode 100644 index 00000000000..31066458715 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_get.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "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 *Site +} + +// Get ... +func (c WebAppsClient) Get(ctx context.Context, id commonids.AppServiceId) (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 + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreference.go b/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreference.go new file mode 100644 index 00000000000..f27fab51318 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreference.go @@ -0,0 +1,53 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReference ... +func (c WebAppsClient) GetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (result GetAppSettingKeyVaultReferenceOperationResponse, 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 + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreferenceslot.go b/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreferenceslot.go new file mode 100644 index 00000000000..99870c87c7b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getappsettingkeyvaultreferenceslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReferenceSlot ... +func (c WebAppsClient) GetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, 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 + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferences.go b/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferences.go new file mode 100644 index 00000000000..043c62e221d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferences.go @@ -0,0 +1,106 @@ +package webapps + +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 GetAppSettingsKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAppSettingsKeyVaultReferencesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAppSettingsKeyVaultReferences ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetAppSettingsKeyVaultReferencesCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetAppSettingsKeyVaultReferencesCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferences(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetAppSettingsKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferencesslot.go b/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferencesslot.go new file mode 100644 index 00000000000..ee5c3cbf23a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getappsettingskeyvaultreferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAppSettingsKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAppSettingsKeyVaultReferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAppSettingsKeyVaultReferencesSlot ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetAppSettingsKeyVaultReferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetAppSettingsKeyVaultReferencesSlotCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferencesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetAppSettingsKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettings.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettings.go new file mode 100644 index 00000000000..5deb735be93 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettings.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettings ... +func (c WebAppsClient) GetAuthSettings(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", 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 + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsslot.go new file mode 100644 index 00000000000..8e803724937 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettingsSlot ... +func (c WebAppsClient) GetAuthSettingsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", 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 + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2.go new file mode 100644 index 00000000000..a0504e9fd96 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2 ... +func (c WebAppsClient) GetAuthSettingsV2(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2slot.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2slot.go new file mode 100644 index 00000000000..1709a5010c1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2slot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2Slot ... +func (c WebAppsClient) GetAuthSettingsV2Slot(ctx context.Context, id SlotId) (result GetAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecrets.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecrets.go new file mode 100644 index 00000000000..124903a090d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecrets.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsV2WithoutSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecrets ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecrets(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecretsslot.go b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecretsslot.go new file mode 100644 index 00000000000..a969211442f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getauthsettingsv2withoutsecretsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2WithoutSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecretsSlot ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getbackupconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_getbackupconfiguration.go new file mode 100644 index 00000000000..89906332ea3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getbackupconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +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 GetBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfiguration ... +func (c WebAppsClient) GetBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", 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 + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getbackupconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_getbackupconfigurationslot.go new file mode 100644 index 00000000000..7be87a5817a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getbackupconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfigurationSlot ... +func (c WebAppsClient) GetBackupConfigurationSlot(ctx context.Context, id SlotId) (result GetBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", 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 + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getbackupstatus.go b/resource-manager/web/2024-04-01/webapps/method_getbackupstatus.go new file mode 100644 index 00000000000..ab296926328 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getbackupstatus.go @@ -0,0 +1,53 @@ +package webapps + +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 GetBackupStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatus ... +func (c WebAppsClient) GetBackupStatus(ctx context.Context, id BackupId) (result GetBackupStatusOperationResponse, 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getbackupstatusslot.go b/resource-manager/web/2024-04-01/webapps/method_getbackupstatusslot.go new file mode 100644 index 00000000000..0e862af25fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getbackupstatusslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetBackupStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatusSlot ... +func (c WebAppsClient) GetBackupStatusSlot(ctx context.Context, id SlotBackupId) (result GetBackupStatusSlotOperationResponse, 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_getconfiguration.go new file mode 100644 index 00000000000..1d73ea645f6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +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 GetConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfiguration ... +func (c WebAppsClient) GetConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_getconfigurationslot.go new file mode 100644 index 00000000000..89546b08eb1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSlot ... +func (c WebAppsClient) GetConfigurationSlot(ctx context.Context, id SlotId) (result GetConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshot.go b/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshot.go new file mode 100644 index 00000000000..016b9fcd3bf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshot ... +func (c WebAppsClient) GetConfigurationSnapshot(ctx context.Context, id SnapshotId) (result GetConfigurationSnapshotOperationResponse, 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshotslot.go b/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshotslot.go new file mode 100644 index 00000000000..80d0457f72f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getconfigurationsnapshotslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshotSlot ... +func (c WebAppsClient) GetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result GetConfigurationSnapshotSlotOperationResponse, 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszip.go b/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszip.go new file mode 100644 index 00000000000..b0790356147 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszip.go @@ -0,0 +1,56 @@ +package webapps + +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 GetContainerLogsZipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZip ... +func (c WebAppsClient) GetContainerLogsZip(ctx context.Context, id commonids.AppServiceId) (result GetContainerLogsZipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszipslot.go b/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszipslot.go new file mode 100644 index 00000000000..080f4f9691c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getcontainerlogszipslot.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetContainerLogsZipSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZipSlot ... +func (c WebAppsClient) GetContainerLogsZipSlot(ctx context.Context, id SlotId) (result GetContainerLogsZipSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjob.go b/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjob.go new file mode 100644 index 00000000000..9f5a071f437 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjob.go @@ -0,0 +1,53 @@ +package webapps + +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 GetContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJob ... +func (c WebAppsClient) GetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result GetContinuousWebJobOperationResponse, 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 + } + + var model ContinuousWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjobslot.go new file mode 100644 index 00000000000..8d4e01c6c04 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getcontinuouswebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJobSlot ... +func (c WebAppsClient) GetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result GetContinuousWebJobSlotOperationResponse, 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 + } + + var model ContinuousWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdeployment.go b/resource-manager/web/2024-04-01/webapps/method_getdeployment.go new file mode 100644 index 00000000000..0355511e44e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdeployment.go @@ -0,0 +1,53 @@ +package webapps + +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 GetDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeployment ... +func (c WebAppsClient) GetDeployment(ctx context.Context, id DeploymentId) (result GetDeploymentOperationResponse, 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdeploymentslot.go b/resource-manager/web/2024-04-01/webapps/method_getdeploymentslot.go new file mode 100644 index 00000000000..4ab616abcec --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdeploymentslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeploymentSlot ... +func (c WebAppsClient) GetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result GetDeploymentSlotOperationResponse, 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfiguration.go new file mode 100644 index 00000000000..0612d0c160c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +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 GetDiagnosticLogsConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfiguration ... +func (c WebAppsClient) GetDiagnosticLogsConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", 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 + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfigurationslot.go new file mode 100644 index 00000000000..aef303209ac --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdiagnosticlogsconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetDiagnosticLogsConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfigurationSlot ... +func (c WebAppsClient) GetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", 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 + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..bc014922e27 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifier.go @@ -0,0 +1,53 @@ +package webapps + +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 GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifier ... +func (c WebAppsClient) GetDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierOperationResponse, 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifierslot.go b/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifierslot.go new file mode 100644 index 00000000000..a2e91d0b828 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getdomainownershipidentifierslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) GetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierSlotOperationResponse, 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getftpallowed.go b/resource-manager/web/2024-04-01/webapps/method_getftpallowed.go new file mode 100644 index 00000000000..3fb4b79a51b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getftpallowed.go @@ -0,0 +1,55 @@ +package webapps + +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 GetFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowed ... +func (c WebAppsClient) GetFtpAllowed(ctx context.Context, id commonids.AppServiceId) (result GetFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getftpallowedslot.go b/resource-manager/web/2024-04-01/webapps/method_getftpallowedslot.go new file mode 100644 index 00000000000..2b3a8004dfc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getftpallowedslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowedSlot ... +func (c WebAppsClient) GetFtpAllowedSlot(ctx context.Context, id SlotId) (result GetFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getfunction.go b/resource-manager/web/2024-04-01/webapps/method_getfunction.go new file mode 100644 index 00000000000..c119bf71fa2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getfunction.go @@ -0,0 +1,53 @@ +package webapps + +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 GetFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetFunction ... +func (c WebAppsClient) GetFunction(ctx context.Context, id FunctionId) (result GetFunctionOperationResponse, 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 + } + + var model FunctionEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintoken.go b/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintoken.go new file mode 100644 index 00000000000..cef965d4ee4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintoken.go @@ -0,0 +1,55 @@ +package webapps + +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 GetFunctionsAdminTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminToken ... +func (c WebAppsClient) GetFunctionsAdminToken(ctx context.Context, id commonids.AppServiceId) (result GetFunctionsAdminTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", 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 + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintokenslot.go b/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintokenslot.go new file mode 100644 index 00000000000..cf37de92f47 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getfunctionsadmintokenslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFunctionsAdminTokenSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminTokenSlot ... +func (c WebAppsClient) GetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", 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 + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gethostnamebinding.go b/resource-manager/web/2024-04-01/webapps/method_gethostnamebinding.go new file mode 100644 index 00000000000..023c7f1797c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gethostnamebinding.go @@ -0,0 +1,53 @@ +package webapps + +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 GetHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBinding ... +func (c WebAppsClient) GetHostNameBinding(ctx context.Context, id HostNameBindingId) (result GetHostNameBindingOperationResponse, 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 + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gethostnamebindingslot.go b/resource-manager/web/2024-04-01/webapps/method_gethostnamebindingslot.go new file mode 100644 index 00000000000..d96ab86f748 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gethostnamebindingslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBindingSlot ... +func (c WebAppsClient) GetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result GetHostNameBindingSlotOperationResponse, 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 + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gethybridconnection.go b/resource-manager/web/2024-04-01/webapps/method_gethybridconnection.go new file mode 100644 index 00000000000..f018d1b6ec8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gethybridconnection.go @@ -0,0 +1,53 @@ +package webapps + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c WebAppsClient) GetHybridConnection(ctx context.Context, id RelayId) (result GetHybridConnectionOperationResponse, 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gethybridconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_gethybridconnectionslot.go new file mode 100644 index 00000000000..e36e2d5b984 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gethybridconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnectionSlot ... +func (c WebAppsClient) GetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result GetHybridConnectionSlotOperationResponse, 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstancefunctionslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstancefunctionslot.go new file mode 100644 index 00000000000..6e95d906f08 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstancefunctionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetInstanceFunctionSlot ... +func (c WebAppsClient) GetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result GetInstanceFunctionSlotOperationResponse, 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 + } + + var model FunctionEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceinfo.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceinfo.go new file mode 100644 index 00000000000..0d535788c59 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceinfo.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfo ... +func (c WebAppsClient) GetInstanceInfo(ctx context.Context, id InstanceId) (result GetInstanceInfoOperationResponse, 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 + } + + var model WebSiteInstanceStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceinfoslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceinfoslot.go new file mode 100644 index 00000000000..7ac3ffaf1c8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceinfoslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfoSlot ... +func (c WebAppsClient) GetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceInfoSlotOperationResponse, 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 + } + + var model WebSiteInstanceStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylog.go b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylog.go new file mode 100644 index 00000000000..5f0ecd4b9d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylog.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLog ... +func (c WebAppsClient) GetInstanceMSDeployLog(ctx context.Context, id InstanceId) (result GetInstanceMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylogslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylogslot.go new file mode 100644 index 00000000000..4aa95f5cdc1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploylogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLogSlot ... +func (c WebAppsClient) GetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatus.go b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatus.go new file mode 100644 index 00000000000..9b0781e0511 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatus.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMsDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatus ... +func (c WebAppsClient) GetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (result GetInstanceMsDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatusslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatusslot.go new file mode 100644 index 00000000000..08c034a5c4b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstancemsdeploystatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMsDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatusSlot ... +func (c WebAppsClient) GetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocess.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocess.go new file mode 100644 index 00000000000..32dd68b49cb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocess.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcess ... +func (c WebAppsClient) GetInstanceProcess(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessOperationResponse, 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 + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdump.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdump.go new file mode 100644 index 00000000000..b3c0570e944 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdump.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDump ... +func (c WebAppsClient) GetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdumpslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdumpslot.go new file mode 100644 index 00000000000..f8e66cc080a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessdumpslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDumpSlot ... +func (c WebAppsClient) GetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmodule.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmodule.go new file mode 100644 index 00000000000..f936b7fea0e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmodule.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModule ... +func (c WebAppsClient) GetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (result GetInstanceProcessModuleOperationResponse, 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 + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmoduleslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmoduleslot.go new file mode 100644 index 00000000000..f68ff944498 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessmoduleslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModuleSlot ... +func (c WebAppsClient) GetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (result GetInstanceProcessModuleSlotOperationResponse, 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 + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessslot.go new file mode 100644 index 00000000000..a799b1317f0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceprocessslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcessSlot ... +func (c WebAppsClient) GetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessSlotOperationResponse, 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 + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getinstanceworkflowslot.go b/resource-manager/web/2024-04-01/webapps/method_getinstanceworkflowslot.go new file mode 100644 index 00000000000..8ef0c8f31c8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getinstanceworkflowslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetInstanceWorkflowSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetInstanceWorkflowSlot ... +func (c WebAppsClient) GetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (result GetInstanceWorkflowSlotOperationResponse, 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 + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatus.go b/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatus.go new file mode 100644 index 00000000000..f05e2dd6aea --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatus.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMigrateMySqlStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatus ... +func (c WebAppsClient) GetMigrateMySqlStatus(ctx context.Context, id commonids.AppServiceId) (result GetMigrateMySqlStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", 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 + } + + var model MigrateMySqlStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatusslot.go b/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatusslot.go new file mode 100644 index 00000000000..973c158cbbf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmigratemysqlstatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMigrateMySqlStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatusSlot ... +func (c WebAppsClient) GetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", 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 + } + + var model MigrateMySqlStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmsdeploylog.go b/resource-manager/web/2024-04-01/webapps/method_getmsdeploylog.go new file mode 100644 index 00000000000..e284c016eea --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmsdeploylog.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLog ... +func (c WebAppsClient) GetMSDeployLog(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmsdeploylogslot.go b/resource-manager/web/2024-04-01/webapps/method_getmsdeploylogslot.go new file mode 100644 index 00000000000..2f843d00946 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmsdeploylogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLogSlot ... +func (c WebAppsClient) GetMSDeployLogSlot(ctx context.Context, id SlotId) (result GetMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatus.go b/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatus.go new file mode 100644 index 00000000000..2b61aa427cd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatus.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMSDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatus ... +func (c WebAppsClient) GetMSDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatusslot.go b/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatusslot.go new file mode 100644 index 00000000000..d644965e7fa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getmsdeploystatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatusSlot ... +func (c WebAppsClient) GetMSDeployStatusSlot(ctx context.Context, id SlotId) (result GetMSDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getnetworktraces.go b/resource-manager/web/2024-04-01/webapps/method_getnetworktraces.go new file mode 100644 index 00000000000..c7baf1f6f32 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getnetworktraces.go @@ -0,0 +1,53 @@ +package webapps + +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 GetNetworkTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTraces ... +func (c WebAppsClient) GetNetworkTraces(ctx context.Context, id NetworkTraceId) (result GetNetworkTracesOperationResponse, 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 + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslot.go b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslot.go new file mode 100644 index 00000000000..be577fd2382 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetNetworkTracesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlot ... +func (c WebAppsClient) GetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (result GetNetworkTracesSlotOperationResponse, 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 + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslotv2.go b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslotv2.go new file mode 100644 index 00000000000..6adf1088332 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesslotv2.go @@ -0,0 +1,53 @@ +package webapps + +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 GetNetworkTracesSlotV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlotV2 ... +func (c WebAppsClient) GetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (result GetNetworkTracesSlotV2OperationResponse, 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 + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getnetworktracesv2.go b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesv2.go new file mode 100644 index 00000000000..a647b7df7d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getnetworktracesv2.go @@ -0,0 +1,53 @@ +package webapps + +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 GetNetworkTracesV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesV2 ... +func (c WebAppsClient) GetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (result GetNetworkTracesV2OperationResponse, 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 + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getonedeploystatus.go b/resource-manager/web/2024-04-01/webapps/method_getonedeploystatus.go new file mode 100644 index 00000000000..861f9c0d26d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getonedeploystatus.go @@ -0,0 +1,55 @@ +package webapps + +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 GetOneDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetOneDeployStatus ... +func (c WebAppsClient) GetOneDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetOneDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/onedeploy", 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 + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getpremieraddon.go b/resource-manager/web/2024-04-01/webapps/method_getpremieraddon.go new file mode 100644 index 00000000000..cab1e802f61 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getpremieraddon.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOn ... +func (c WebAppsClient) GetPremierAddOn(ctx context.Context, id PremierAddonId) (result GetPremierAddOnOperationResponse, 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getpremieraddonslot.go b/resource-manager/web/2024-04-01/webapps/method_getpremieraddonslot.go new file mode 100644 index 00000000000..b18d56f259b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getpremieraddonslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOnSlot ... +func (c WebAppsClient) GetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result GetPremierAddOnSlotOperationResponse, 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateaccess.go b/resource-manager/web/2024-04-01/webapps/method_getprivateaccess.go new file mode 100644 index 00000000000..a475aa2c107 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateaccess.go @@ -0,0 +1,55 @@ +package webapps + +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 GetPrivateAccessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccess ... +func (c WebAppsClient) GetPrivateAccess(ctx context.Context, id commonids.AppServiceId) (result GetPrivateAccessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateaccessslot.go b/resource-manager/web/2024-04-01/webapps/method_getprivateaccessslot.go new file mode 100644 index 00000000000..5ca04dcfd35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateaccessslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateAccessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccessSlot ... +func (c WebAppsClient) GetPrivateAccessSlot(ctx context.Context, id SlotId) (result GetPrivateAccessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnection.go b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..078deb2c24a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c WebAppsClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, 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 + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..7eab86729c0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlist.go @@ -0,0 +1,106 @@ +package webapps + +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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c WebAppsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlistslot.go b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlistslot.go new file mode 100644 index 00000000000..46bf684dad2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionlistslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionListSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListSlotCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotComplete(ctx context.Context, id SlotId) (GetPrivateEndpointConnectionListSlotCompleteResult, error) { + return c.GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListSlotCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionListSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetPrivateEndpointConnectionListSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionslot.go new file mode 100644 index 00000000000..dc1da065c8f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivateendpointconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPrivateEndpointConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionSlotOperationResponse, 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 + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresources.go b/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresources.go new file mode 100644 index 00000000000..7a0922f7157 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresources.go @@ -0,0 +1,55 @@ +package webapps + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c WebAppsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresourcesslot.go b/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresourcesslot.go new file mode 100644 index 00000000000..3dc2ee16463 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprivatelinkresourcesslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResourcesSlot ... +func (c WebAppsClient) GetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocess.go b/resource-manager/web/2024-04-01/webapps/method_getprocess.go new file mode 100644 index 00000000000..f53ec86fa97 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocess.go @@ -0,0 +1,53 @@ +package webapps + +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 GetProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcess ... +func (c WebAppsClient) GetProcess(ctx context.Context, id ProcessId) (result GetProcessOperationResponse, 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 + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocessdump.go b/resource-manager/web/2024-04-01/webapps/method_getprocessdump.go new file mode 100644 index 00000000000..4aa575213d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocessdump.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDump ... +func (c WebAppsClient) GetProcessDump(ctx context.Context, id ProcessId) (result GetProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocessdumpslot.go b/resource-manager/web/2024-04-01/webapps/method_getprocessdumpslot.go new file mode 100644 index 00000000000..b904b54a53d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocessdumpslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDumpSlot ... +func (c WebAppsClient) GetProcessDumpSlot(ctx context.Context, id SlotProcessId) (result GetProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocessmodule.go b/resource-manager/web/2024-04-01/webapps/method_getprocessmodule.go new file mode 100644 index 00000000000..84621827e5b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocessmodule.go @@ -0,0 +1,53 @@ +package webapps + +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 GetProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModule ... +func (c WebAppsClient) GetProcessModule(ctx context.Context, id ModuleId) (result GetProcessModuleOperationResponse, 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 + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocessmoduleslot.go b/resource-manager/web/2024-04-01/webapps/method_getprocessmoduleslot.go new file mode 100644 index 00000000000..eb70f4f6077 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocessmoduleslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModuleSlot ... +func (c WebAppsClient) GetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (result GetProcessModuleSlotOperationResponse, 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 + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getprocessslot.go b/resource-manager/web/2024-04-01/webapps/method_getprocessslot.go new file mode 100644 index 00000000000..125ebe5550c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getprocessslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcessSlot ... +func (c WebAppsClient) GetProcessSlot(ctx context.Context, id SlotProcessId) (result GetProcessSlotOperationResponse, 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 + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getpubliccertificate.go b/resource-manager/web/2024-04-01/webapps/method_getpubliccertificate.go new file mode 100644 index 00000000000..d2b18926090 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getpubliccertificate.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificate ... +func (c WebAppsClient) GetPublicCertificate(ctx context.Context, id PublicCertificateId) (result GetPublicCertificateOperationResponse, 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 + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getpubliccertificateslot.go b/resource-manager/web/2024-04-01/webapps/method_getpubliccertificateslot.go new file mode 100644 index 00000000000..81a159edd9f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getpubliccertificateslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetPublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificateSlot ... +func (c WebAppsClient) GetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result GetPublicCertificateSlotOperationResponse, 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 + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnection.go b/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnection.go new file mode 100644 index 00000000000..279bcaac0fc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnection.go @@ -0,0 +1,53 @@ +package webapps + +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 GetRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnection ... +func (c WebAppsClient) GetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result GetRelayServiceConnectionOperationResponse, 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnectionslot.go new file mode 100644 index 00000000000..8260c31d4d5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getrelayserviceconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnectionSlot ... +func (c WebAppsClient) GetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result GetRelayServiceConnectionSlotOperationResponse, 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getscmallowed.go b/resource-manager/web/2024-04-01/webapps/method_getscmallowed.go new file mode 100644 index 00000000000..9b0418a2f0f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getscmallowed.go @@ -0,0 +1,55 @@ +package webapps + +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 GetScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowed ... +func (c WebAppsClient) GetScmAllowed(ctx context.Context, id commonids.AppServiceId) (result GetScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getscmallowedslot.go b/resource-manager/web/2024-04-01/webapps/method_getscmallowedslot.go new file mode 100644 index 00000000000..53a7a3a2331 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getscmallowedslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowedSlot ... +func (c WebAppsClient) GetScmAllowedSlot(ctx context.Context, id SlotId) (result GetScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreference.go b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreference.go new file mode 100644 index 00000000000..aff9e649a27 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreference.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReference ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, 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 + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go new file mode 100644 index 00000000000..6544219dc39 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go @@ -0,0 +1,106 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetSiteConnectionStringKeyVaultReferencesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetSiteConnectionStringKeyVaultReferences ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetSiteConnectionStringKeyVaultReferencesCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetSiteConnectionStringKeyVaultReferencesCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferences(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetSiteConnectionStringKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go new file mode 100644 index 00000000000..9cd169fbf00 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferenceSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, 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 + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go new file mode 100644 index 00000000000..94803ca2384 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetSiteConnectionStringKeyVaultReferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetSiteConnectionStringKeyVaultReferencesSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetSiteConnectionStringKeyVaultReferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsitecontainer.go b/resource-manager/web/2024-04-01/webapps/method_getsitecontainer.go new file mode 100644 index 00000000000..bd1302d106f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsitecontainer.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainer ... +func (c WebAppsClient) GetSiteContainer(ctx context.Context, id SitecontainerId) (result GetSiteContainerOperationResponse, 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 + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsitecontainerslot.go b/resource-manager/web/2024-04-01/webapps/method_getsitecontainerslot.go new file mode 100644 index 00000000000..0f130308780 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsitecontainerslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainerSlot ... +func (c WebAppsClient) GetSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result GetSiteContainerSlotOperationResponse, 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 + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteextension.go b/resource-manager/web/2024-04-01/webapps/method_getsiteextension.go new file mode 100644 index 00000000000..0a6945f3b7d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteextension.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtension ... +func (c WebAppsClient) GetSiteExtension(ctx context.Context, id SiteExtensionId) (result GetSiteExtensionOperationResponse, 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 + } + + var model SiteExtensionInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsiteextensionslot.go b/resource-manager/web/2024-04-01/webapps/method_getsiteextensionslot.go new file mode 100644 index 00000000000..e54acbb50ef --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsiteextensionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtensionSlot ... +func (c WebAppsClient) GetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result GetSiteExtensionSlotOperationResponse, 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 + } + + var model SiteExtensionInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflag.go b/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflag.go new file mode 100644 index 00000000000..63dbaae3ef5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflag.go @@ -0,0 +1,55 @@ +package webapps + +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 GetSitePhpErrorLogFlagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlag ... +func (c WebAppsClient) GetSitePhpErrorLogFlag(ctx context.Context, id commonids.AppServiceId) (result GetSitePhpErrorLogFlagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", 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 + } + + var model SitePhpErrorLogFlag + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflagslot.go b/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflagslot.go new file mode 100644 index 00000000000..4476bb15496 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsitephperrorlogflagslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSitePhpErrorLogFlagSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlagSlot ... +func (c WebAppsClient) GetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", 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 + } + + var model SitePhpErrorLogFlag + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getslot.go b/resource-manager/web/2024-04-01/webapps/method_getslot.go new file mode 100644 index 00000000000..96f47332251 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// GetSlot ... +func (c WebAppsClient) GetSlot(ctx context.Context, id SlotId) (result GetSlotOperationResponse, 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 + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsourcecontrol.go b/resource-manager/web/2024-04-01/webapps/method_getsourcecontrol.go new file mode 100644 index 00000000000..8f1380fc15a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsourcecontrol.go @@ -0,0 +1,57 @@ +package webapps + +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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControl ... +func (c WebAppsClient) GetSourceControl(ctx context.Context, id commonids.AppServiceId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getsourcecontrolslot.go b/resource-manager/web/2024-04-01/webapps/method_getsourcecontrolslot.go new file mode 100644 index 00000000000..59f28a81eeb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getsourcecontrolslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControlSlot ... +func (c WebAppsClient) GetSourceControlSlot(ctx context.Context, id SlotId) (result GetSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnection.go b/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnection.go new file mode 100644 index 00000000000..8d24a59f9ff --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 GetSwiftVirtualNetworkConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnection ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnection(ctx context.Context, id commonids.AppServiceId) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnectionslot.go new file mode 100644 index 00000000000..c94d3312298 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getswiftvirtualnetworkconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSwiftVirtualNetworkConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnectionSlot ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjob.go new file mode 100644 index 00000000000..f408fb21bb1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjob.go @@ -0,0 +1,53 @@ +package webapps + +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 GetTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJob ... +func (c WebAppsClient) GetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result GetTriggeredWebJobOperationResponse, 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 + } + + var model TriggeredWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistory.go b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistory.go new file mode 100644 index 00000000000..d8dac67561f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistory.go @@ -0,0 +1,53 @@ +package webapps + +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 GetTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistory ... +func (c WebAppsClient) GetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (result GetTriggeredWebJobHistoryOperationResponse, 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 + } + + var model TriggeredJobHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistoryslot.go b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..db0ae2aa46c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobhistoryslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistorySlot ... +func (c WebAppsClient) GetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (result GetTriggeredWebJobHistorySlotOperationResponse, 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 + } + + var model TriggeredJobHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobslot.go new file mode 100644 index 00000000000..9d5fdbad976 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_gettriggeredwebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJobSlot ... +func (c WebAppsClient) GetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result GetTriggeredWebJobSlotOperationResponse, 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 + } + + var model TriggeredWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getvnetconnection.go b/resource-manager/web/2024-04-01/webapps/method_getvnetconnection.go new file mode 100644 index 00000000000..4568fe01196 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getvnetconnection.go @@ -0,0 +1,53 @@ +package webapps + +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 GetVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnection ... +func (c WebAppsClient) GetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result GetVnetConnectionOperationResponse, 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongateway.go b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongateway.go new file mode 100644 index 00000000000..71c79ea8c65 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongateway.go @@ -0,0 +1,53 @@ +package webapps + +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 GetVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGateway ... +func (c WebAppsClient) GetVnetConnectionGateway(ctx context.Context, id GatewayId) (result GetVnetConnectionGatewayOperationResponse, 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongatewayslot.go b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongatewayslot.go new file mode 100644 index 00000000000..7abcca7f5ab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectiongatewayslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGatewaySlot ... +func (c WebAppsClient) GetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (result GetVnetConnectionGatewaySlotOperationResponse, 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getvnetconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectionslot.go new file mode 100644 index 00000000000..d212cb00170 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getvnetconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnectionSlot ... +func (c WebAppsClient) GetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result GetVnetConnectionSlotOperationResponse, 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getwebjob.go b/resource-manager/web/2024-04-01/webapps/method_getwebjob.go new file mode 100644 index 00000000000..283a114229d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getwebjob.go @@ -0,0 +1,53 @@ +package webapps + +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 GetWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJob ... +func (c WebAppsClient) GetWebJob(ctx context.Context, id WebJobId) (result GetWebJobOperationResponse, 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 + } + + var model WebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getwebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_getwebjobslot.go new file mode 100644 index 00000000000..e1b57da034c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getwebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +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 GetWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJobSlot ... +func (c WebAppsClient) GetWebJobSlot(ctx context.Context, id SlotWebJobId) (result GetWebJobSlotOperationResponse, 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 + } + + var model WebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogs.go b/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogs.go new file mode 100644 index 00000000000..b663861a930 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogs.go @@ -0,0 +1,56 @@ +package webapps + +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 GetWebSiteContainerLogsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogs ... +func (c WebAppsClient) GetWebSiteContainerLogs(ctx context.Context, id commonids.AppServiceId) (result GetWebSiteContainerLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogsslot.go b/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogsslot.go new file mode 100644 index 00000000000..6446530d54e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getwebsitecontainerlogsslot.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetWebSiteContainerLogsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogsSlot ... +func (c WebAppsClient) GetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_getworkflow.go b/resource-manager/web/2024-04-01/webapps/method_getworkflow.go new file mode 100644 index 00000000000..5588ed7e61d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_getworkflow.go @@ -0,0 +1,53 @@ +package webapps + +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 GetWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetWorkflow ... +func (c WebAppsClient) GetWorkflow(ctx context.Context, id WorkflowId) (result GetWorkflowOperationResponse, 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 + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_installsiteextension.go b/resource-manager/web/2024-04-01/webapps/method_installsiteextension.go new file mode 100644 index 00000000000..7e485b9878f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_installsiteextension.go @@ -0,0 +1,71 @@ +package webapps + +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 InstallSiteExtensionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtension ... +func (c WebAppsClient) InstallSiteExtension(ctx context.Context, id SiteExtensionId) (result InstallSiteExtensionOperationResponse, 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 + } + + 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 +} + +// InstallSiteExtensionThenPoll performs InstallSiteExtension then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionThenPoll(ctx context.Context, id SiteExtensionId) error { + result, err := c.InstallSiteExtension(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtension: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtension: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_installsiteextensionslot.go b/resource-manager/web/2024-04-01/webapps/method_installsiteextensionslot.go new file mode 100644 index 00000000000..4bea72555e7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_installsiteextensionslot.go @@ -0,0 +1,71 @@ +package webapps + +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 InstallSiteExtensionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtensionSlot ... +func (c WebAppsClient) InstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result InstallSiteExtensionSlotOperationResponse, 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 + } + + 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 +} + +// InstallSiteExtensionSlotThenPoll performs InstallSiteExtensionSlot then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionSlotThenPoll(ctx context.Context, id SlotSiteExtensionId) error { + result, err := c.InstallSiteExtensionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtensionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtensionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_iscloneable.go b/resource-manager/web/2024-04-01/webapps/method_iscloneable.go new file mode 100644 index 00000000000..0603d8f018e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_iscloneable.go @@ -0,0 +1,55 @@ +package webapps + +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 IsCloneableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneable ... +func (c WebAppsClient) IsCloneable(ctx context.Context, id commonids.AppServiceId) (result IsCloneableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", 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 + } + + var model SiteCloneability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_iscloneableslot.go b/resource-manager/web/2024-04-01/webapps/method_iscloneableslot.go new file mode 100644 index 00000000000..e971d3c63e4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_iscloneableslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 IsCloneableSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneableSlot ... +func (c WebAppsClient) IsCloneableSlot(ctx context.Context, id SlotId) (result IsCloneableSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", 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 + } + + var model SiteCloneability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_list.go b/resource-manager/web/2024-04-01/webapps/method_list.go new file mode 100644 index 00000000000..460b637e374 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_list.go @@ -0,0 +1,106 @@ +package webapps + +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 *[]Site +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", 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 *[]Site `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 WebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/webapps/method_listapplicationsettings.go b/resource-manager/web/2024-04-01/webapps/method_listapplicationsettings.go new file mode 100644 index 00000000000..ce70c9042fa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listapplicationsettings.go @@ -0,0 +1,55 @@ +package webapps + +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 ListApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettings ... +func (c WebAppsClient) ListApplicationSettings(ctx context.Context, id commonids.AppServiceId) (result ListApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listapplicationsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_listapplicationsettingsslot.go new file mode 100644 index 00000000000..7eefeaa0feb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listapplicationsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettingsSlot ... +func (c WebAppsClient) ListApplicationSettingsSlot(ctx context.Context, id SlotId) (result ListApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccounts.go b/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccounts.go new file mode 100644 index 00000000000..bc513083273 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccounts.go @@ -0,0 +1,55 @@ +package webapps + +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 ListAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccounts ... +func (c WebAppsClient) ListAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId) (result ListAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", 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 + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccountsslot.go b/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccountsslot.go new file mode 100644 index 00000000000..c5a1cd2c3ab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listazurestorageaccountsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccountsSlot ... +func (c WebAppsClient) ListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (result ListAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", 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 + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbackups.go b/resource-manager/web/2024-04-01/webapps/method_listbackups.go new file mode 100644 index 00000000000..a8b70b26ecf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbackups.go @@ -0,0 +1,106 @@ +package webapps + +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 ListBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListBackupsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBackupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBackups ... +func (c WebAppsClient) ListBackups(ctx context.Context, id commonids.AppServiceId) (result ListBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBackupsCustomPager{}, + Path: fmt.Sprintf("%s/backups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListBackupsCompleteResult, error) { + return c.ListBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackups(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbackupsslot.go b/resource-manager/web/2024-04-01/webapps/method_listbackupsslot.go new file mode 100644 index 00000000000..c76afbae931 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbackupsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListBackupsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBackupsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBackupsSlot ... +func (c WebAppsClient) ListBackupsSlot(ctx context.Context, id SlotId) (result ListBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBackupsSlotCustomPager{}, + Path: fmt.Sprintf("%s/backups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsSlotComplete(ctx context.Context, id SlotId) (ListBackupsSlotCompleteResult, error) { + return c.ListBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackupsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecrets.go b/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecrets.go new file mode 100644 index 00000000000..31d9021a61b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecrets.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupStatusSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecrets ... +func (c WebAppsClient) ListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (result ListBackupStatusSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecretsslot.go b/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecretsslot.go new file mode 100644 index 00000000000..ddc128b594c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbackupstatussecretsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupStatusSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecretsSlot ... +func (c WebAppsClient) ListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (result ListBackupStatusSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", 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 + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspolicies.go b/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspolicies.go new file mode 100644 index 00000000000..48de93b0880 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspolicies.go @@ -0,0 +1,106 @@ +package webapps + +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 ListBasicPublishingCredentialsPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicPublishingCredentialsPoliciesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicPublishingCredentialsPolicies ... +func (c WebAppsClient) ListBasicPublishingCredentialsPolicies(ctx context.Context, id commonids.AppServiceId) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicPublishingCredentialsPoliciesCustomPager{}, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", 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 *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesComplete(ctx context.Context, id commonids.AppServiceId) (ListBasicPublishingCredentialsPoliciesCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPolicies(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBasicPublishingCredentialsPoliciesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go b/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go new file mode 100644 index 00000000000..6bfb2b86ffe --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBasicPublishingCredentialsPoliciesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicPublishingCredentialsPoliciesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicPublishingCredentialsPoliciesSlot ... +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicPublishingCredentialsPoliciesSlotCustomPager{}, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", 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 *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotComplete(ctx context.Context, id SlotId) (ListBasicPublishingCredentialsPoliciesSlotCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesSlotCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPoliciesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBasicPublishingCredentialsPoliciesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listbyresourcegroup.go b/resource-manager/web/2024-04-01/webapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0453dace48d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package webapps + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListByResourceGroupOperationOptions struct { + IncludeSlots *bool +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeSlots != nil { + out.Append("includeSlots", fmt.Sprintf("%v", *o.IncludeSlots)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c WebAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c WebAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SiteOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconfigurations.go b/resource-manager/web/2024-04-01/webapps/method_listconfigurations.go new file mode 100644 index 00000000000..8e804a2f12c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconfigurations.go @@ -0,0 +1,106 @@ +package webapps + +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 ListConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +type ListConfigurationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurations ... +func (c WebAppsClient) ListConfigurations(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationsCustomPager{}, + Path: fmt.Sprintf("%s/config", 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 *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationsCompleteResult, error) { + return c.ListConfigurationsCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurations(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListConfigurationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfo.go b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..c3b12636fbb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfo.go @@ -0,0 +1,106 @@ +package webapps + +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 ListConfigurationSnapshotInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationSnapshotInfoCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationSnapshotInfo ... +func (c WebAppsClient) ListConfigurationSnapshotInfo(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationSnapshotInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationSnapshotInfoCustomPager{}, + Path: fmt.Sprintf("%s/config/web/snapshots", 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 *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationSnapshotInfoCompleteResult, error) { + return c.ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfo(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListConfigurationSnapshotInfoCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfoslot.go b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfoslot.go new file mode 100644 index 00000000000..cef77008f85 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsnapshotinfoslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationSnapshotInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationSnapshotInfoSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationSnapshotInfoSlot ... +func (c WebAppsClient) ListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationSnapshotInfoSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/web/snapshots", 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 *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotComplete(ctx context.Context, id SlotId) (ListConfigurationSnapshotInfoSlotCompleteResult, error) { + return c.ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoSlotCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfoSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListConfigurationSnapshotInfoSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconfigurationsslot.go b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsslot.go new file mode 100644 index 00000000000..4e3d0acefe3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconfigurationsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +type ListConfigurationsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationsSlot ... +func (c WebAppsClient) ListConfigurationsSlot(ctx context.Context, id SlotId) (result ListConfigurationsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationsSlotCustomPager{}, + Path: fmt.Sprintf("%s/config", 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 *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsSlotComplete(ctx context.Context, id SlotId) (ListConfigurationsSlotCompleteResult, error) { + return c.ListConfigurationsSlotCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsSlotCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurationsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListConfigurationsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconnectionstrings.go b/resource-manager/web/2024-04-01/webapps/method_listconnectionstrings.go new file mode 100644 index 00000000000..64554b4fd90 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconnectionstrings.go @@ -0,0 +1,55 @@ +package webapps + +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 ListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStrings ... +func (c WebAppsClient) ListConnectionStrings(ctx context.Context, id commonids.AppServiceId) (result ListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", 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 + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listconnectionstringsslot.go b/resource-manager/web/2024-04-01/webapps/method_listconnectionstringsslot.go new file mode 100644 index 00000000000..4f5c82268e8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listconnectionstringsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStringsSlot ... +func (c WebAppsClient) ListConnectionStringsSlot(ctx context.Context, id SlotId) (result ListConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", 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 + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobs.go b/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobs.go new file mode 100644 index 00000000000..63d3df76b91 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobs.go @@ -0,0 +1,106 @@ +package webapps + +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 ListContinuousWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +type ListContinuousWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListContinuousWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListContinuousWebJobs ... +func (c WebAppsClient) ListContinuousWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListContinuousWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListContinuousWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/continuousWebJobs", 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 *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListContinuousWebJobsCompleteResult, error) { + return c.ListContinuousWebJobsCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListContinuousWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobsslot.go b/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobsslot.go new file mode 100644 index 00000000000..f187ed28ce3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listcontinuouswebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListContinuousWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +type ListContinuousWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListContinuousWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListContinuousWebJobsSlot ... +func (c WebAppsClient) ListContinuousWebJobsSlot(ctx context.Context, id SlotId) (result ListContinuousWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListContinuousWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/continuousWebJobs", 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 *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsSlotComplete(ctx context.Context, id SlotId) (ListContinuousWebJobsSlotCompleteResult, error) { + return c.ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsSlotCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListContinuousWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdeploymentlog.go b/resource-manager/web/2024-04-01/webapps/method_listdeploymentlog.go new file mode 100644 index 00000000000..c08913fb632 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdeploymentlog.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLog ... +func (c WebAppsClient) ListDeploymentLog(ctx context.Context, id DeploymentId) (result ListDeploymentLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdeploymentlogslot.go b/resource-manager/web/2024-04-01/webapps/method_listdeploymentlogslot.go new file mode 100644 index 00000000000..ac50302c638 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdeploymentlogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLogSlot ... +func (c WebAppsClient) ListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (result ListDeploymentLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", 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 + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdeployments.go b/resource-manager/web/2024-04-01/webapps/method_listdeployments.go new file mode 100644 index 00000000000..62fe0173758 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdeployments.go @@ -0,0 +1,106 @@ +package webapps + +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 ListDeploymentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +type ListDeploymentsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeployments ... +func (c WebAppsClient) ListDeployments(ctx context.Context, id commonids.AppServiceId) (result ListDeploymentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDeploymentsCustomPager{}, + Path: fmt.Sprintf("%s/deployments", 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 *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsComplete(ctx context.Context, id commonids.AppServiceId) (ListDeploymentsCompleteResult, error) { + return c.ListDeploymentsCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DeploymentOperationPredicate) (result ListDeploymentsCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeployments(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdeploymentsslot.go b/resource-manager/web/2024-04-01/webapps/method_listdeploymentsslot.go new file mode 100644 index 00000000000..d42866c7b88 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdeploymentsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +type ListDeploymentsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsSlot ... +func (c WebAppsClient) ListDeploymentsSlot(ctx context.Context, id SlotId) (result ListDeploymentsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDeploymentsSlotCustomPager{}, + Path: fmt.Sprintf("%s/deployments", 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 *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsSlotComplete(ctx context.Context, id SlotId) (ListDeploymentsSlotCompleteResult, error) { + return c.ListDeploymentsSlotCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DeploymentOperationPredicate) (result ListDeploymentsSlotCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeploymentsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDeploymentsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiers.go b/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiers.go new file mode 100644 index 00000000000..113e62c90b8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiers.go @@ -0,0 +1,106 @@ +package webapps + +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 ListDomainOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListDomainOwnershipIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDomainOwnershipIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDomainOwnershipIdentifiers ... +func (c WebAppsClient) ListDomainOwnershipIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDomainOwnershipIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListDomainOwnershipIdentifiersCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDomainOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiersslot.go b/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiersslot.go new file mode 100644 index 00000000000..8bf54d7bc37 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listdomainownershipidentifiersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDomainOwnershipIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListDomainOwnershipIdentifiersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDomainOwnershipIdentifiersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDomainOwnershipIdentifiersSlot ... +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDomainOwnershipIdentifiersSlotCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListDomainOwnershipIdentifiersSlotCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersSlotCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListDomainOwnershipIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listfunctionkeys.go b/resource-manager/web/2024-04-01/webapps/method_listfunctionkeys.go new file mode 100644 index 00000000000..8408b4dae45 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listfunctionkeys.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeys ... +func (c WebAppsClient) ListFunctionKeys(ctx context.Context, id FunctionId) (result ListFunctionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listfunctionkeysslot.go b/resource-manager/web/2024-04-01/webapps/method_listfunctionkeysslot.go new file mode 100644 index 00000000000..08a6e0172a6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listfunctionkeysslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeysSlot ... +func (c WebAppsClient) ListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listfunctions.go b/resource-manager/web/2024-04-01/webapps/method_listfunctions.go new file mode 100644 index 00000000000..bec63cb0d75 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listfunctions.go @@ -0,0 +1,106 @@ +package webapps + +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 ListFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +type ListFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListFunctions ... +func (c WebAppsClient) ListFunctions(ctx context.Context, id commonids.AppServiceId) (result ListFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", 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 *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListFunctionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListFunctionsComplete(ctx context.Context, id commonids.AppServiceId) (ListFunctionsCompleteResult, error) { + return c.ListFunctionsCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListFunctionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate FunctionEnvelopeOperationPredicate) (result ListFunctionsCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listfunctionsecrets.go b/resource-manager/web/2024-04-01/webapps/method_listfunctionsecrets.go new file mode 100644 index 00000000000..45eb50cf982 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listfunctionsecrets.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecrets ... +func (c WebAppsClient) ListFunctionSecrets(ctx context.Context, id FunctionId) (result ListFunctionSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", 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 + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listfunctionsecretsslot.go b/resource-manager/web/2024-04-01/webapps/method_listfunctionsecretsslot.go new file mode 100644 index 00000000000..15de188c3d5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listfunctionsecretsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecretsSlot ... +func (c WebAppsClient) ListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", 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 + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhostkeys.go b/resource-manager/web/2024-04-01/webapps/method_listhostkeys.go new file mode 100644 index 00000000000..fabdace3a5d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhostkeys.go @@ -0,0 +1,55 @@ +package webapps + +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 ListHostKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeys ... +func (c WebAppsClient) ListHostKeys(ctx context.Context, id commonids.AppServiceId) (result ListHostKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", 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 + } + + var model HostKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhostkeysslot.go b/resource-manager/web/2024-04-01/webapps/method_listhostkeysslot.go new file mode 100644 index 00000000000..750e7a12832 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhostkeysslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeysSlot ... +func (c WebAppsClient) ListHostKeysSlot(ctx context.Context, id SlotId) (result ListHostKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", 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 + } + + var model HostKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhostnamebindings.go b/resource-manager/web/2024-04-01/webapps/method_listhostnamebindings.go new file mode 100644 index 00000000000..3dc80a9cfb7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhostnamebindings.go @@ -0,0 +1,106 @@ +package webapps + +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 ListHostNameBindingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +type ListHostNameBindingsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostNameBindingsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostNameBindings ... +func (c WebAppsClient) ListHostNameBindings(ctx context.Context, id commonids.AppServiceId) (result ListHostNameBindingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostNameBindingsCustomPager{}, + Path: fmt.Sprintf("%s/hostNameBindings", 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 *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsComplete(ctx context.Context, id commonids.AppServiceId) (ListHostNameBindingsCompleteResult, error) { + return c.ListHostNameBindingsCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindings(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHostNameBindingsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhostnamebindingsslot.go b/resource-manager/web/2024-04-01/webapps/method_listhostnamebindingsslot.go new file mode 100644 index 00000000000..e2425090bce --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhostnamebindingsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostNameBindingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +type ListHostNameBindingsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostNameBindingsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostNameBindingsSlot ... +func (c WebAppsClient) ListHostNameBindingsSlot(ctx context.Context, id SlotId) (result ListHostNameBindingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostNameBindingsSlotCustomPager{}, + Path: fmt.Sprintf("%s/hostNameBindings", 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 *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsSlotComplete(ctx context.Context, id SlotId) (ListHostNameBindingsSlotCompleteResult, error) { + return c.ListHostNameBindingsSlotCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsSlotCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindingsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListHostNameBindingsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhybridconnections.go b/resource-manager/web/2024-04-01/webapps/method_listhybridconnections.go new file mode 100644 index 00000000000..0aea9bb9d04 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhybridconnections.go @@ -0,0 +1,55 @@ +package webapps + +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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnections ... +func (c WebAppsClient) ListHybridConnections(ctx context.Context, id commonids.AppServiceId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listhybridconnectionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listhybridconnectionsslot.go new file mode 100644 index 00000000000..d6ec6a8ec2b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listhybridconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHybridConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnectionsSlot ... +func (c WebAppsClient) ListHybridConnectionsSlot(ctx context.Context, id SlotId) (result ListHybridConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstancefunctionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstancefunctionsslot.go new file mode 100644 index 00000000000..6c10eace684 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstancefunctionsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListInstanceFunctionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +type ListInstanceFunctionsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceFunctionsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceFunctionsSlot ... +func (c WebAppsClient) ListInstanceFunctionsSlot(ctx context.Context, id SlotId) (result ListInstanceFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceFunctionsSlotCustomPager{}, + Path: fmt.Sprintf("%s/functions", 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 *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceFunctionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceFunctionsSlotComplete(ctx context.Context, id SlotId) (ListInstanceFunctionsSlotCompleteResult, error) { + return c.ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListInstanceFunctionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate FunctionEnvelopeOperationPredicate) (result ListInstanceFunctionsSlotCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListInstanceFunctionsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceFunctionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiers.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiers.go new file mode 100644 index 00000000000..62730a6aff2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiers.go @@ -0,0 +1,106 @@ +package webapps + +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 ListInstanceIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceIdentifiers ... +func (c WebAppsClient) ListInstanceIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListInstanceIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/instances", 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 *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListInstanceIdentifiersCompleteResult, error) { + return c.ListInstanceIdentifiersCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiersslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiersslot.go new file mode 100644 index 00000000000..65ad91633e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceidentifiersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceIdentifiersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceIdentifiersSlot ... +func (c WebAppsClient) ListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (result ListInstanceIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceIdentifiersSlotCustomPager{}, + Path: fmt.Sprintf("%s/instances", 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 *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListInstanceIdentifiersSlotCompleteResult, error) { + return c.ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersSlotCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocesses.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocesses.go new file mode 100644 index 00000000000..7b596445609 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocesses.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListInstanceProcessesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcesses ... +func (c WebAppsClient) ListInstanceProcesses(ctx context.Context, id InstanceId) (result ListInstanceProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessesCustomPager{}, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesComplete(ctx context.Context, id InstanceId) (ListInstanceProcessesCompleteResult, error) { + return c.ListInstanceProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesCompleteMatchingPredicate(ctx context.Context, id InstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcesses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessesslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessesslot.go new file mode 100644 index 00000000000..725411fb8b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListInstanceProcessesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessesSlot ... +func (c WebAppsClient) ListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (result ListInstanceProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessesSlotCustomPager{}, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesSlotComplete(ctx context.Context, id SlotInstanceId) (ListInstanceProcessesSlotCompleteResult, error) { + return c.ListInstanceProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcessesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodules.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodules.go new file mode 100644 index 00000000000..113a7dd68a6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodules.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListInstanceProcessModulesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessModulesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessModules ... +func (c WebAppsClient) ListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessModulesCustomPager{}, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessModulesCompleteResult, error) { + return c.ListInstanceProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModules(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodulesslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodulesslot.go new file mode 100644 index 00000000000..23d09675fe8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessmodulesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessModulesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessModulesSlot ... +func (c WebAppsClient) ListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessModulesSlotCustomPager{}, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessModulesSlotCompleteResult, error) { + return c.ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModulesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreads.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreads.go new file mode 100644 index 00000000000..82d9b44dc60 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreads.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListInstanceProcessThreadsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessThreadsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessThreads ... +func (c WebAppsClient) ListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessThreadsCustomPager{}, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessThreadsCompleteResult, error) { + return c.ListInstanceProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreads(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreadsslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreadsslot.go new file mode 100644 index 00000000000..513fe67c6a7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceprocessthreadsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessThreadsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessThreadsSlot ... +func (c WebAppsClient) ListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessThreadsSlotCustomPager{}, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessThreadsSlotCompleteResult, error) { + return c.ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreadsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listinstanceworkflowsslot.go b/resource-manager/web/2024-04-01/webapps/method_listinstanceworkflowsslot.go new file mode 100644 index 00000000000..472996214b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listinstanceworkflowsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceWorkflowsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceWorkflowsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceWorkflowsSlot ... +func (c WebAppsClient) ListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (result ListInstanceWorkflowsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceWorkflowsSlotCustomPager{}, + Path: fmt.Sprintf("%s/workflows", 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 *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceWorkflowsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceWorkflowsSlotComplete(ctx context.Context, id SlotId) (ListInstanceWorkflowsSlotCompleteResult, error) { + return c.ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListInstanceWorkflowsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WorkflowEnvelopeOperationPredicate) (result ListInstanceWorkflowsSlotCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListInstanceWorkflowsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListInstanceWorkflowsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listmetadata.go b/resource-manager/web/2024-04-01/webapps/method_listmetadata.go new file mode 100644 index 00000000000..8998ba62c0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listmetadata.go @@ -0,0 +1,55 @@ +package webapps + +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 ListMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadata ... +func (c WebAppsClient) ListMetadata(ctx context.Context, id commonids.AppServiceId) (result ListMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listmetadataslot.go b/resource-manager/web/2024-04-01/webapps/method_listmetadataslot.go new file mode 100644 index 00000000000..b2dcfca269d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listmetadataslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadataSlot ... +func (c WebAppsClient) ListMetadataSlot(ctx context.Context, id SlotId) (result ListMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listnetworkfeatures.go b/resource-manager/web/2024-04-01/webapps/method_listnetworkfeatures.go new file mode 100644 index 00000000000..fde1a7c3d73 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listnetworkfeatures.go @@ -0,0 +1,53 @@ +package webapps + +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 ListNetworkFeaturesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeatures ... +func (c WebAppsClient) ListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (result ListNetworkFeaturesOperationResponse, 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 + } + + var model NetworkFeatures + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listnetworkfeaturesslot.go b/resource-manager/web/2024-04-01/webapps/method_listnetworkfeaturesslot.go new file mode 100644 index 00000000000..c91b5baede0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listnetworkfeaturesslot.go @@ -0,0 +1,53 @@ +package webapps + +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 ListNetworkFeaturesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeaturesSlot ... +func (c WebAppsClient) ListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (result ListNetworkFeaturesSlotOperationResponse, 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 + } + + var model NetworkFeatures + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listperfmoncounters.go b/resource-manager/web/2024-04-01/webapps/method_listperfmoncounters.go new file mode 100644 index 00000000000..ab98305afda --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listperfmoncounters.go @@ -0,0 +1,135 @@ +package webapps + +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 ListPerfMonCountersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersOperationOptions() ListPerfMonCountersOperationOptions { + return ListPerfMonCountersOperationOptions{} +} + +func (o ListPerfMonCountersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListPerfMonCountersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPerfMonCountersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPerfMonCounters ... +func (c WebAppsClient) ListPerfMonCounters(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (result ListPerfMonCountersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListPerfMonCountersCustomPager{}, + Path: fmt.Sprintf("%s/perfcounters", 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 *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersComplete(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (ListPerfMonCountersCompleteResult, error) { + return c.ListPerfMonCountersCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCounters(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListPerfMonCountersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listperfmoncountersslot.go b/resource-manager/web/2024-04-01/webapps/method_listperfmoncountersslot.go new file mode 100644 index 00000000000..b82ebb85e22 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listperfmoncountersslot.go @@ -0,0 +1,134 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPerfMonCountersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersSlotOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersSlotOperationOptions() ListPerfMonCountersSlotOperationOptions { + return ListPerfMonCountersSlotOperationOptions{} +} + +func (o ListPerfMonCountersSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListPerfMonCountersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPerfMonCountersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPerfMonCountersSlot ... +func (c WebAppsClient) ListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (result ListPerfMonCountersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListPerfMonCountersSlotCustomPager{}, + Path: fmt.Sprintf("%s/perfcounters", 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 *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersSlotComplete(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (ListPerfMonCountersSlotCompleteResult, error) { + return c.ListPerfMonCountersSlotCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersSlotCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCountersSlot(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListPerfMonCountersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpremieraddons.go b/resource-manager/web/2024-04-01/webapps/method_listpremieraddons.go new file mode 100644 index 00000000000..b11bf4233c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpremieraddons.go @@ -0,0 +1,55 @@ +package webapps + +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 ListPremierAddOnsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOns ... +func (c WebAppsClient) ListPremierAddOns(ctx context.Context, id commonids.AppServiceId) (result ListPremierAddOnsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpremieraddonsslot.go b/resource-manager/web/2024-04-01/webapps/method_listpremieraddonsslot.go new file mode 100644 index 00000000000..73dbf683ae9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpremieraddonsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPremierAddOnsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOnsSlot ... +func (c WebAppsClient) ListPremierAddOnsSlot(ctx context.Context, id SlotId) (result ListPremierAddOnsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocesses.go b/resource-manager/web/2024-04-01/webapps/method_listprocesses.go new file mode 100644 index 00000000000..ebf1da0bcf9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocesses.go @@ -0,0 +1,106 @@ +package webapps + +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 ListProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListProcessesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcesses ... +func (c WebAppsClient) ListProcesses(ctx context.Context, id commonids.AppServiceId) (result ListProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessesCustomPager{}, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesComplete(ctx context.Context, id commonids.AppServiceId) (ListProcessesCompleteResult, error) { + return c.ListProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ProcessInfoOperationPredicate) (result ListProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcesses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocessesslot.go b/resource-manager/web/2024-04-01/webapps/method_listprocessesslot.go new file mode 100644 index 00000000000..d737e095497 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocessesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListProcessesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessesSlot ... +func (c WebAppsClient) ListProcessesSlot(ctx context.Context, id SlotId) (result ListProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessesSlotCustomPager{}, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesSlotComplete(ctx context.Context, id SlotId) (ListProcessesSlotCompleteResult, error) { + return c.ListProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ProcessInfoOperationPredicate) (result ListProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcessesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocessmodules.go b/resource-manager/web/2024-04-01/webapps/method_listprocessmodules.go new file mode 100644 index 00000000000..e1a3a6af39e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocessmodules.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListProcessModulesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessModulesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessModules ... +func (c WebAppsClient) ListProcessModules(ctx context.Context, id ProcessId) (result ListProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessModulesCustomPager{}, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesComplete(ctx context.Context, id ProcessId) (ListProcessModulesCompleteResult, error) { + return c.ListProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModules(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocessmodulesslot.go b/resource-manager/web/2024-04-01/webapps/method_listprocessmodulesslot.go new file mode 100644 index 00000000000..0ddc8a915f9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocessmodulesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListProcessModulesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessModulesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessModulesSlot ... +func (c WebAppsClient) ListProcessModulesSlot(ctx context.Context, id SlotProcessId) (result ListProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessModulesSlotCustomPager{}, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessModulesSlotCompleteResult, error) { + return c.ListProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModulesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocessthreads.go b/resource-manager/web/2024-04-01/webapps/method_listprocessthreads.go new file mode 100644 index 00000000000..32356aa2170 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocessthreads.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListProcessThreadsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessThreadsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessThreads ... +func (c WebAppsClient) ListProcessThreads(ctx context.Context, id ProcessId) (result ListProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessThreadsCustomPager{}, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsComplete(ctx context.Context, id ProcessId) (ListProcessThreadsCompleteResult, error) { + return c.ListProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreads(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listprocessthreadsslot.go b/resource-manager/web/2024-04-01/webapps/method_listprocessthreadsslot.go new file mode 100644 index 00000000000..d3335f9f125 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listprocessthreadsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListProcessThreadsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessThreadsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessThreadsSlot ... +func (c WebAppsClient) ListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (result ListProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessThreadsSlotCustomPager{}, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessThreadsSlotCompleteResult, error) { + return c.ListProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreadsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listproductionsitedeploymentstatuses.go b/resource-manager/web/2024-04-01/webapps/method_listproductionsitedeploymentstatuses.go new file mode 100644 index 00000000000..dbca4c9c5cf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listproductionsitedeploymentstatuses.go @@ -0,0 +1,106 @@ +package webapps + +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 ListProductionSiteDeploymentStatusesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProductionSiteDeploymentStatusesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProductionSiteDeploymentStatuses ... +func (c WebAppsClient) ListProductionSiteDeploymentStatuses(ctx context.Context, id commonids.AppServiceId) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProductionSiteDeploymentStatusesCustomPager{}, + Path: fmt.Sprintf("%s/deploymentStatus", 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 *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProductionSiteDeploymentStatusesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProductionSiteDeploymentStatusesComplete(ctx context.Context, id commonids.AppServiceId) (ListProductionSiteDeploymentStatusesCompleteResult, error) { + return c.ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListProductionSiteDeploymentStatusesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmDeploymentStatusOperationPredicate) (result ListProductionSiteDeploymentStatusesCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListProductionSiteDeploymentStatuses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListProductionSiteDeploymentStatusesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpubliccertificates.go b/resource-manager/web/2024-04-01/webapps/method_listpubliccertificates.go new file mode 100644 index 00000000000..1566dc4e69f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpubliccertificates.go @@ -0,0 +1,106 @@ +package webapps + +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 ListPublicCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +type ListPublicCertificatesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPublicCertificatesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPublicCertificates ... +func (c WebAppsClient) ListPublicCertificates(ctx context.Context, id commonids.AppServiceId) (result ListPublicCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPublicCertificatesCustomPager{}, + Path: fmt.Sprintf("%s/publicCertificates", 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 *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesComplete(ctx context.Context, id commonids.AppServiceId) (ListPublicCertificatesCompleteResult, error) { + return c.ListPublicCertificatesCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificates(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListPublicCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpubliccertificatesslot.go b/resource-manager/web/2024-04-01/webapps/method_listpubliccertificatesslot.go new file mode 100644 index 00000000000..fb63cdc093c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpubliccertificatesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublicCertificatesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +type ListPublicCertificatesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPublicCertificatesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPublicCertificatesSlot ... +func (c WebAppsClient) ListPublicCertificatesSlot(ctx context.Context, id SlotId) (result ListPublicCertificatesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPublicCertificatesSlotCustomPager{}, + Path: fmt.Sprintf("%s/publicCertificates", 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 *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesSlotComplete(ctx context.Context, id SlotId) (ListPublicCertificatesSlotCompleteResult, error) { + return c.ListPublicCertificatesSlotCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesSlotCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificatesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListPublicCertificatesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentials.go b/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentials.go new file mode 100644 index 00000000000..3c3e5a7d373 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentials.go @@ -0,0 +1,71 @@ +package webapps + +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 ListPublishingCredentialsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentials ... +func (c WebAppsClient) ListPublishingCredentials(ctx context.Context, id commonids.AppServiceId) (result ListPublishingCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsThenPoll performs ListPublishingCredentials then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsThenPoll(ctx context.Context, id commonids.AppServiceId) error { + result, err := c.ListPublishingCredentials(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentials: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentials: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentialsslot.go b/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentialsslot.go new file mode 100644 index 00000000000..6c38961b04a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpublishingcredentialsslot.go @@ -0,0 +1,70 @@ +package webapps + +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 ListPublishingCredentialsSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentialsSlot ... +func (c WebAppsClient) ListPublishingCredentialsSlot(ctx context.Context, id SlotId) (result ListPublishingCredentialsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsSlotThenPoll performs ListPublishingCredentialsSlot then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsSlotThenPoll(ctx context.Context, id SlotId) error { + result, err := c.ListPublishingCredentialsSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentialsSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentialsSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecrets.go b/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecrets.go new file mode 100644 index 00000000000..07b6308ca62 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecrets.go @@ -0,0 +1,59 @@ +package webapps + +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 ListPublishingProfileXmlWithSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecrets ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecrets(ctx context.Context, id commonids.AppServiceId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go b/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go new file mode 100644 index 00000000000..7f32d269123 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublishingProfileXmlWithSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecretsSlot ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", 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 + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnections.go b/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnections.go new file mode 100644 index 00000000000..de929a519e3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnections.go @@ -0,0 +1,55 @@ +package webapps + +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 ListRelayServiceConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnections ... +func (c WebAppsClient) ListRelayServiceConnections(ctx context.Context, id commonids.AppServiceId) (result ListRelayServiceConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnectionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnectionsslot.go new file mode 100644 index 00000000000..56b6752c72f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listrelayserviceconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListRelayServiceConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnectionsSlot ... +func (c WebAppsClient) ListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitebackups.go b/resource-manager/web/2024-04-01/webapps/method_listsitebackups.go new file mode 100644 index 00000000000..453b979ef15 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitebackups.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSiteBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListSiteBackupsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteBackupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteBackups ... +func (c WebAppsClient) ListSiteBackups(ctx context.Context, id commonids.AppServiceId) (result ListSiteBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteBackupsCustomPager{}, + Path: fmt.Sprintf("%s/listbackups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteBackupsCompleteResult, error) { + return c.ListSiteBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListSiteBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackups(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitebackupsslot.go b/resource-manager/web/2024-04-01/webapps/method_listsitebackupsslot.go new file mode 100644 index 00000000000..4b1fa4a16f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitebackupsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListSiteBackupsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteBackupsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteBackupsSlot ... +func (c WebAppsClient) ListSiteBackupsSlot(ctx context.Context, id SlotId) (result ListSiteBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteBackupsSlotCustomPager{}, + Path: fmt.Sprintf("%s/listbackups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsSlotComplete(ctx context.Context, id SlotId) (ListSiteBackupsSlotCompleteResult, error) { + return c.ListSiteBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListSiteBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackupsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitecontainers.go b/resource-manager/web/2024-04-01/webapps/method_listsitecontainers.go new file mode 100644 index 00000000000..b5451f754a5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitecontainers.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSiteContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +type ListSiteContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteContainers ... +func (c WebAppsClient) ListSiteContainers(ctx context.Context, id commonids.AppServiceId) (result ListSiteContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteContainersCustomPager{}, + Path: fmt.Sprintf("%s/sitecontainers", 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 *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteContainersCompleteResult, error) { + return c.ListSiteContainersCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteContainerOperationPredicate) (result ListSiteContainersCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitecontainersslot.go b/resource-manager/web/2024-04-01/webapps/method_listsitecontainersslot.go new file mode 100644 index 00000000000..ad7e84da3ef --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitecontainersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteContainersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +type ListSiteContainersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteContainersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteContainersSlot ... +func (c WebAppsClient) ListSiteContainersSlot(ctx context.Context, id SlotId) (result ListSiteContainersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteContainersSlotCustomPager{}, + Path: fmt.Sprintf("%s/sitecontainers", 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 *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersSlotComplete(ctx context.Context, id SlotId) (ListSiteContainersSlotCompleteResult, error) { + return c.ListSiteContainersSlotCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteContainerOperationPredicate) (result ListSiteContainersSlotCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteContainersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsiteextensions.go b/resource-manager/web/2024-04-01/webapps/method_listsiteextensions.go new file mode 100644 index 00000000000..8541bc980ce --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsiteextensions.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSiteExtensionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +type ListSiteExtensionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteExtensionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteExtensions ... +func (c WebAppsClient) ListSiteExtensions(ctx context.Context, id commonids.AppServiceId) (result ListSiteExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteExtensionsCustomPager{}, + Path: fmt.Sprintf("%s/siteExtensions", 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 *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteExtensionsCompleteResult, error) { + return c.ListSiteExtensionsCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteExtensionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsiteextensionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listsiteextensionsslot.go new file mode 100644 index 00000000000..b71b603d02f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsiteextensionsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteExtensionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +type ListSiteExtensionsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteExtensionsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteExtensionsSlot ... +func (c WebAppsClient) ListSiteExtensionsSlot(ctx context.Context, id SlotId) (result ListSiteExtensionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteExtensionsSlotCustomPager{}, + Path: fmt.Sprintf("%s/siteExtensions", 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 *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsSlotComplete(ctx context.Context, id SlotId) (ListSiteExtensionsSlotCompleteResult, error) { + return c.ListSiteExtensionsSlotCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsSlotCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensionsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSiteExtensionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitepushsettings.go b/resource-manager/web/2024-04-01/webapps/method_listsitepushsettings.go new file mode 100644 index 00000000000..99b7cd099b7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitepushsettings.go @@ -0,0 +1,55 @@ +package webapps + +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 ListSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettings ... +func (c WebAppsClient) ListSitePushSettings(ctx context.Context, id commonids.AppServiceId) (result ListSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", 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 + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsitepushsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_listsitepushsettingsslot.go new file mode 100644 index 00000000000..38b18425808 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsitepushsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettingsSlot ... +func (c WebAppsClient) ListSitePushSettingsSlot(ctx context.Context, id SlotId) (result ListSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", 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 + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listslotconfigurationnames.go b/resource-manager/web/2024-04-01/webapps/method_listslotconfigurationnames.go new file mode 100644 index 00000000000..ccfa9dc0e21 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listslotconfigurationnames.go @@ -0,0 +1,55 @@ +package webapps + +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 ListSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// ListSlotConfigurationNames ... +func (c WebAppsClient) ListSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId) (result ListSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/slotConfigNames", 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 + } + + var model SlotConfigNamesResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesfromproduction.go b/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesfromproduction.go new file mode 100644 index 00000000000..8452739cf2b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesfromproduction.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSlotDifferencesFromProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesFromProductionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +type ListSlotDifferencesFromProductionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotDifferencesFromProductionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotDifferencesFromProduction ... +func (c WebAppsClient) ListSlotDifferencesFromProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ListSlotDifferencesFromProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSlotDifferencesFromProductionCustomPager{}, + Path: fmt.Sprintf("%s/slotsdiffs", 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 *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesFromProductionComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesFromProductionComplete(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (ListSlotDifferencesFromProductionCompleteResult, error) { + return c.ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesFromProductionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesFromProductionCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesFromProduction(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSlotDifferencesFromProductionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesslot.go b/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesslot.go new file mode 100644 index 00000000000..7dad87c2b7a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listslotdifferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotDifferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +type ListSlotDifferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotDifferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotDifferencesSlot ... +func (c WebAppsClient) ListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ListSlotDifferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSlotDifferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/slotsdiffs", 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 *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesSlotComplete(ctx context.Context, id SlotId, input CsmSlotEntity) (ListSlotDifferencesSlotCompleteResult, error) { + return c.ListSlotDifferencesSlotCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesSlotCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesSlot(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSlotDifferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listslots.go b/resource-manager/web/2024-04-01/webapps/method_listslots.go new file mode 100644 index 00000000000..c76f15d5d03 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listslots.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSlotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListSlotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListSlotsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlots ... +func (c WebAppsClient) ListSlots(ctx context.Context, id commonids.AppServiceId) (result ListSlotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSlotsCustomPager{}, + Path: fmt.Sprintf("%s/slots", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSlotsCompleteResult, error) { + return c.ListSlotsCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListSlotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteOperationPredicate) (result ListSlotsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListSlots(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSlotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listslotsitedeploymentstatusesslot.go b/resource-manager/web/2024-04-01/webapps/method_listslotsitedeploymentstatusesslot.go new file mode 100644 index 00000000000..8ceee87cc66 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listslotsitedeploymentstatusesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotSiteDeploymentStatusesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotSiteDeploymentStatusesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotSiteDeploymentStatusesSlot ... +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSlotSiteDeploymentStatusesSlotCustomPager{}, + Path: fmt.Sprintf("%s/deploymentStatus", 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 *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotSiteDeploymentStatusesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotComplete(ctx context.Context, id SlotId) (ListSlotSiteDeploymentStatusesSlotCompleteResult, error) { + return c.ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmDeploymentStatusOperationPredicate) (result ListSlotSiteDeploymentStatusesSlotCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListSlotSiteDeploymentStatusesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSlotSiteDeploymentStatusesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsnapshots.go b/resource-manager/web/2024-04-01/webapps/method_listsnapshots.go new file mode 100644 index 00000000000..ae445c7d99c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsnapshots.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshots ... +func (c WebAppsClient) ListSnapshots(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsCustomPager{}, + Path: fmt.Sprintf("%s/snapshots", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsCompleteResult, error) { + return c.ListSnapshotsCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshots(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSnapshotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondary.go b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondary.go new file mode 100644 index 00000000000..878e74fccd0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondary.go @@ -0,0 +1,106 @@ +package webapps + +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 ListSnapshotsFromDRSecondaryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsFromDRSecondaryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsFromDRSecondaryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsFromDRSecondary ... +func (c WebAppsClient) ListSnapshotsFromDRSecondary(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsFromDRSecondaryCustomPager{}, + Path: fmt.Sprintf("%s/snapshotsdr", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondaryComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondaryComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsFromDRSecondaryCompleteResult, error) { + return c.ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondaryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondaryCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondary(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSnapshotsFromDRSecondaryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondaryslot.go b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondaryslot.go new file mode 100644 index 00000000000..6e438ec2ff9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsfromdrsecondaryslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsFromDRSecondarySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsFromDRSecondarySlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsFromDRSecondarySlot ... +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsFromDRSecondarySlotCustomPager{}, + Path: fmt.Sprintf("%s/snapshotsdr", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondarySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotComplete(ctx context.Context, id SlotId) (ListSnapshotsFromDRSecondarySlotCompleteResult, error) { + return c.ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondarySlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondarySlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSnapshotsFromDRSecondarySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsnapshotsslot.go b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsslot.go new file mode 100644 index 00000000000..840f0882265 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsnapshotsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsSlot ... +func (c WebAppsClient) ListSnapshotsSlot(ctx context.Context, id SlotId) (result ListSnapshotsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsSlotCustomPager{}, + Path: fmt.Sprintf("%s/snapshots", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsSlotComplete(ctx context.Context, id SlotId) (ListSnapshotsSlotCompleteResult, error) { + return c.ListSnapshotsSlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsSlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListSnapshotsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggers.go b/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggers.go new file mode 100644 index 00000000000..3ba753d99a5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggers.go @@ -0,0 +1,55 @@ +package webapps + +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 ListSyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggers ... +func (c WebAppsClient) ListSyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result ListSyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", 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 + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggersslot.go b/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggersslot.go new file mode 100644 index 00000000000..87112ea8e9a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsyncfunctiontriggersslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggersSlot ... +func (c WebAppsClient) ListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", 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 + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsyncstatus.go b/resource-manager/web/2024-04-01/webapps/method_listsyncstatus.go new file mode 100644 index 00000000000..bc0ee3e79f0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsyncstatus.go @@ -0,0 +1,48 @@ +package webapps + +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 ListSyncStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatus ... +func (c WebAppsClient) ListSyncStatus(ctx context.Context, id commonids.AppServiceId) (result ListSyncStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listsyncstatusslot.go b/resource-manager/web/2024-04-01/webapps/method_listsyncstatusslot.go new file mode 100644 index 00000000000..bf199ced94d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listsyncstatusslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatusSlot ... +func (c WebAppsClient) ListSyncStatusSlot(ctx context.Context, id SlotId) (result ListSyncStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistory.go b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistory.go new file mode 100644 index 00000000000..881719e8edf --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistory.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobHistoryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobHistory ... +func (c WebAppsClient) ListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (result ListTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobHistoryCustomPager{}, + Path: fmt.Sprintf("%s/history", 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 *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistoryComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistoryComplete(ctx context.Context, id TriggeredWebJobId) (ListTriggeredWebJobHistoryCompleteResult, error) { + return c.ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistoryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx context.Context, id TriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistoryCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistory(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListTriggeredWebJobHistoryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistoryslot.go b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..727607c47c6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobhistoryslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobHistorySlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobHistorySlot ... +func (c WebAppsClient) ListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobHistorySlotCustomPager{}, + Path: fmt.Sprintf("%s/history", 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 *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistorySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistorySlotComplete(ctx context.Context, id SlotTriggeredWebJobId) (ListTriggeredWebJobHistorySlotCompleteResult, error) { + return c.ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistorySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx context.Context, id SlotTriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistorySlotCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistorySlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListTriggeredWebJobHistorySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobs.go b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobs.go new file mode 100644 index 00000000000..a732150b7fb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobs.go @@ -0,0 +1,106 @@ +package webapps + +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 ListTriggeredWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +type ListTriggeredWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobs ... +func (c WebAppsClient) ListTriggeredWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListTriggeredWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/triggeredWebJobs", 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 *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListTriggeredWebJobsCompleteResult, error) { + return c.ListTriggeredWebJobsCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListTriggeredWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobsslot.go b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobsslot.go new file mode 100644 index 00000000000..6dbb5cb9064 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listtriggeredwebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobsSlot ... +func (c WebAppsClient) ListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (result ListTriggeredWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/triggeredWebJobs", 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 *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsSlotComplete(ctx context.Context, id SlotId) (ListTriggeredWebJobsSlotCompleteResult, error) { + return c.ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsSlotCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListTriggeredWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listusages.go b/resource-manager/web/2024-04-01/webapps/method_listusages.go new file mode 100644 index 00000000000..09825b54c80 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listusages.go @@ -0,0 +1,135 @@ +package webapps + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c WebAppsClient) ListUsages(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listusagesslot.go b/resource-manager/web/2024-04-01/webapps/method_listusagesslot.go new file mode 100644 index 00000000000..0f5459ebad6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listusagesslot.go @@ -0,0 +1,134 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListUsagesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesSlotOperationOptions struct { + Filter *string +} + +func DefaultListUsagesSlotOperationOptions() ListUsagesSlotOperationOptions { + return ListUsagesSlotOperationOptions{} +} + +func (o ListUsagesSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsagesSlot ... +func (c WebAppsClient) ListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (result ListUsagesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesSlotCustomPager{}, + Path: fmt.Sprintf("%s/usages", 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesSlotComplete(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (ListUsagesSlotCompleteResult, error) { + return c.ListUsagesSlotCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesSlotCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsagesSlot(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListUsagesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listvnetconnections.go b/resource-manager/web/2024-04-01/webapps/method_listvnetconnections.go new file mode 100644 index 00000000000..9257086d2e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listvnetconnections.go @@ -0,0 +1,55 @@ +package webapps + +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 ListVnetConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnections ... +func (c WebAppsClient) ListVnetConnections(ctx context.Context, id commonids.AppServiceId) (result ListVnetConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listvnetconnectionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listvnetconnectionsslot.go new file mode 100644 index 00000000000..942cd6b0476 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listvnetconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListVnetConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnectionsSlot ... +func (c WebAppsClient) ListVnetConnectionsSlot(ctx context.Context, id SlotId) (result ListVnetConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listwebjobs.go b/resource-manager/web/2024-04-01/webapps/method_listwebjobs.go new file mode 100644 index 00000000000..46c96736e0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listwebjobs.go @@ -0,0 +1,106 @@ +package webapps + +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 ListWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +type ListWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebJobs ... +func (c WebAppsClient) ListWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/webJobs", 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 *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListWebJobsCompleteResult, error) { + return c.ListWebJobsCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebJobOperationPredicate) (result ListWebJobsCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listwebjobsslot.go b/resource-manager/web/2024-04-01/webapps/method_listwebjobsslot.go new file mode 100644 index 00000000000..421ab88f0e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listwebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +type ListWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebJobsSlot ... +func (c WebAppsClient) ListWebJobsSlot(ctx context.Context, id SlotId) (result ListWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/webJobs", 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 *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsSlotComplete(ctx context.Context, id SlotId) (ListWebJobsSlotCompleteResult, error) { + return c.ListWebJobsSlotCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebJobOperationPredicate) (result ListWebJobsSlotCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listworkflows.go b/resource-manager/web/2024-04-01/webapps/method_listworkflows.go new file mode 100644 index 00000000000..a098ec74cd5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listworkflows.go @@ -0,0 +1,106 @@ +package webapps + +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 ListWorkflowsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListWorkflowsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +type ListWorkflowsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkflowsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkflows ... +func (c WebAppsClient) ListWorkflows(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkflowsCustomPager{}, + Path: fmt.Sprintf("%s/workflows", 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 *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkflowsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWorkflowsComplete(ctx context.Context, id commonids.AppServiceId) (ListWorkflowsCompleteResult, error) { + return c.ListWorkflowsCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListWorkflowsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWorkflowsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WorkflowEnvelopeOperationPredicate) (result ListWorkflowsCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListWorkflows(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListWorkflowsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnections.go b/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnections.go new file mode 100644 index 00000000000..4c7d04686ac --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnections.go @@ -0,0 +1,55 @@ +package webapps + +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 ListWorkflowsConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnections ... +func (c WebAppsClient) ListWorkflowsConnections(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", 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 + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnectionsslot.go b/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnectionsslot.go new file mode 100644 index 00000000000..b85e7a72003 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_listworkflowsconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWorkflowsConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnectionsSlot ... +func (c WebAppsClient) ListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", 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 + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_migratemysql.go b/resource-manager/web/2024-04-01/webapps/method_migratemysql.go new file mode 100644 index 00000000000..ce8f8a7c00c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_migratemysql.go @@ -0,0 +1,75 @@ +package webapps + +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 MigrateMySqlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Operation +} + +// MigrateMySql ... +func (c WebAppsClient) MigrateMySql(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) (result MigrateMySqlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateMySql", 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 +} + +// MigrateMySqlThenPoll performs MigrateMySql then polls until it's completed +func (c WebAppsClient) MigrateMySqlThenPoll(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) error { + result, err := c.MigrateMySql(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MigrateMySql: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateMySql: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_migratestorage.go b/resource-manager/web/2024-04-01/webapps/method_migratestorage.go new file mode 100644 index 00000000000..1fb58c4f795 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_migratestorage.go @@ -0,0 +1,104 @@ +package webapps + +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 MigrateStorageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageMigrationResponse +} + +type MigrateStorageOperationOptions struct { + SubscriptionName *string +} + +func DefaultMigrateStorageOperationOptions() MigrateStorageOperationOptions { + return MigrateStorageOperationOptions{} +} + +func (o MigrateStorageOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SubscriptionName != nil { + out.Append("subscriptionName", fmt.Sprintf("%v", *o.SubscriptionName)) + } + return &out +} + +// MigrateStorage ... +func (c WebAppsClient) MigrateStorage(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (result MigrateStorageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: fmt.Sprintf("%s/migrate", 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 +} + +// MigrateStorageThenPoll performs MigrateStorage then polls until it's completed +func (c WebAppsClient) MigrateStorageThenPoll(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) error { + result, err := c.MigrateStorage(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing MigrateStorage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateStorage: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnet.go b/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnet.go new file mode 100644 index 00000000000..419ea335744 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnet.go @@ -0,0 +1,59 @@ +package webapps + +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 PutPrivateAccessVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnet ... +func (c WebAppsClient) PutPrivateAccessVnet(ctx context.Context, id commonids.AppServiceId, input PrivateAccess) (result PutPrivateAccessVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnetslot.go b/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnetslot.go new file mode 100644 index 00000000000..a2031d0024b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_putprivateaccessvnetslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 PutPrivateAccessVnetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnetSlot ... +func (c WebAppsClient) PutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (result PutPrivateAccessVnetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshot.go b/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshot.go new file mode 100644 index 00000000000..9bd00ef6a3f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RecoverSiteConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshotslot.go b/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshotslot.go new file mode 100644 index 00000000000..c2218167e74 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_recoversiteconfigurationsnapshotslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RecoverSiteConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshotSlot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_resetproductionslotconfig.go b/resource-manager/web/2024-04-01/webapps/method_resetproductionslotconfig.go new file mode 100644 index 00000000000..d3e1980493a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_resetproductionslotconfig.go @@ -0,0 +1,48 @@ +package webapps + +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 ResetProductionSlotConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetProductionSlotConfig ... +func (c WebAppsClient) ResetProductionSlotConfig(ctx context.Context, id commonids.AppServiceId) (result ResetProductionSlotConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_resetslotconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_resetslotconfigurationslot.go new file mode 100644 index 00000000000..15aae400653 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_resetslotconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ResetSlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetSlotConfigurationSlot ... +func (c WebAppsClient) ResetSlotConfigurationSlot(ctx context.Context, id SlotId) (result ResetSlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restart.go b/resource-manager/web/2024-04-01/webapps/method_restart.go new file mode 100644 index 00000000000..47d9224417a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restart.go @@ -0,0 +1,81 @@ +package webapps + +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 RestartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartOperationOptions() RestartOperationOptions { + return RestartOperationOptions{} +} + +func (o RestartOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// Restart ... +func (c WebAppsClient) Restart(ctx context.Context, id commonids.AppServiceId, options RestartOperationOptions) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restartslot.go b/resource-manager/web/2024-04-01/webapps/method_restartslot.go new file mode 100644 index 00000000000..ca81876358d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restartslot.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "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 RestartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartSlotOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartSlotOperationOptions() RestartSlotOperationOptions { + return RestartSlotOperationOptions{} +} + +func (o RestartSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// RestartSlot ... +func (c WebAppsClient) RestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (result RestartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restore.go b/resource-manager/web/2024-04-01/webapps/method_restore.go new file mode 100644 index 00000000000..021d7f79a35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restore.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c WebAppsClient) Restore(ctx context.Context, id BackupId, input RestoreRequest) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c WebAppsClient) RestoreThenPoll(ctx context.Context, id BackupId, input RestoreRequest) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblob.go b/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblob.go new file mode 100644 index 00000000000..0483caf9f9c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblob.go @@ -0,0 +1,75 @@ +package webapps + +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 RestoreFromBackupBlobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlob ... +func (c WebAppsClient) RestoreFromBackupBlob(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result RestoreFromBackupBlobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobThenPoll performs RestoreFromBackupBlob then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobThenPoll(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlob: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblobslot.go b/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblobslot.go new file mode 100644 index 00000000000..27fd565b8af --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restorefrombackupblobslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromBackupBlobSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlobSlot ... +func (c WebAppsClient) RestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (result RestoreFromBackupBlobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobSlotThenPoll performs RestoreFromBackupBlobSlot then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobSlotThenPoll(ctx context.Context, id SlotId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlobSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlobSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlobSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedapp.go b/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedapp.go new file mode 100644 index 00000000000..1b8a16b10b5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedapp.go @@ -0,0 +1,75 @@ +package webapps + +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 RestoreFromDeletedAppOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedApp ... +func (c WebAppsClient) RestoreFromDeletedApp(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppThenPoll performs RestoreFromDeletedApp then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppThenPoll(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedApp(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedApp: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedApp: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedappslot.go b/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedappslot.go new file mode 100644 index 00000000000..6fd61e73c37 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restorefromdeletedappslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromDeletedAppSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedAppSlot ... +func (c WebAppsClient) RestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppSlotThenPoll performs RestoreFromDeletedAppSlot then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppSlotThenPoll(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedAppSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedAppSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedAppSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restoreslot.go b/resource-manager/web/2024-04-01/webapps/method_restoreslot.go new file mode 100644 index 00000000000..0e401f516af --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restoreslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSlot ... +func (c WebAppsClient) RestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (result RestoreSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreSlotThenPoll performs RestoreSlot then polls until it's completed +func (c WebAppsClient) RestoreSlotThenPoll(ctx context.Context, id SlotBackupId, input RestoreRequest) error { + result, err := c.RestoreSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restoresnapshot.go b/resource-manager/web/2024-04-01/webapps/method_restoresnapshot.go new file mode 100644 index 00000000000..191a16d685d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restoresnapshot.go @@ -0,0 +1,75 @@ +package webapps + +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 RestoreSnapshotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshot ... +func (c WebAppsClient) RestoreSnapshot(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) (result RestoreSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotThenPoll performs RestoreSnapshot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotThenPoll(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_restoresnapshotslot.go b/resource-manager/web/2024-04-01/webapps/method_restoresnapshotslot.go new file mode 100644 index 00000000000..95c72292ac1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_restoresnapshotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSnapshotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshotSlot ... +func (c WebAppsClient) RestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (result RestoreSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotSlotThenPoll performs RestoreSnapshotSlot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotSlotThenPoll(ctx context.Context, id SlotId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjob.go new file mode 100644 index 00000000000..368004f11bb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RunTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJob ... +func (c WebAppsClient) RunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result RunTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjobslot.go new file mode 100644 index 00000000000..20589d753fc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_runtriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RunTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJobSlot ... +func (c WebAppsClient) RunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result RunTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_start.go b/resource-manager/web/2024-04-01/webapps/method_start.go new file mode 100644 index 00000000000..6eeb4574e82 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_start.go @@ -0,0 +1,48 @@ +package webapps + +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 StartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c WebAppsClient) Start(ctx context.Context, id commonids.AppServiceId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjob.go b/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjob.go new file mode 100644 index 00000000000..e3a68b92d35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJob ... +func (c WebAppsClient) StartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StartContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjobslot.go new file mode 100644 index 00000000000..25b7624a51e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJobSlot ... +func (c WebAppsClient) StartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StartContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startnetworktrace.go b/resource-manager/web/2024-04-01/webapps/method_startnetworktrace.go new file mode 100644 index 00000000000..3b1246a0d11 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startnetworktrace.go @@ -0,0 +1,109 @@ +package webapps + +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 StartNetworkTraceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartNetworkTraceOperationOptions() StartNetworkTraceOperationOptions { + return StartNetworkTraceOperationOptions{} +} + +func (o StartNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartNetworkTrace ... +func (c WebAppsClient) StartNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) (result StartNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/startNetworkTrace", 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 +} + +// StartNetworkTraceThenPoll performs StartNetworkTrace then polls until it's completed +func (c WebAppsClient) StartNetworkTraceThenPoll(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) error { + result, err := c.StartNetworkTrace(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTrace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTrace: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startnetworktraceslot.go b/resource-manager/web/2024-04-01/webapps/method_startnetworktraceslot.go new file mode 100644 index 00000000000..72c280deeef --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startnetworktraceslot.go @@ -0,0 +1,108 @@ +package webapps + +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 StartNetworkTraceSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartNetworkTraceSlotOperationOptions() StartNetworkTraceSlotOperationOptions { + return StartNetworkTraceSlotOperationOptions{} +} + +func (o StartNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartNetworkTraceSlot ... +func (c WebAppsClient) StartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (result StartNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/startNetworkTrace", 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 +} + +// StartNetworkTraceSlotThenPoll performs StartNetworkTraceSlot then polls until it's completed +func (c WebAppsClient) StartNetworkTraceSlotThenPoll(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) error { + result, err := c.StartNetworkTraceSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTraceSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTraceSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startslot.go b/resource-manager/web/2024-04-01/webapps/method_startslot.go new file mode 100644 index 00000000000..e1ef6c58413 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartSlot ... +func (c WebAppsClient) StartSlot(ctx context.Context, id SlotId) (result StartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktrace.go b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktrace.go new file mode 100644 index 00000000000..0feb53df65b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktrace.go @@ -0,0 +1,92 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationOptions() StartWebSiteNetworkTraceOperationOptions { + return StartWebSiteNetworkTraceOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTrace ... +func (c WebAppsClient) StartWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOptions) (result StartWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/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 + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperation.go b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperation.go new file mode 100644 index 00000000000..1a67be6cba1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperation.go @@ -0,0 +1,109 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationOperationOptions() StartWebSiteNetworkTraceOperationOperationOptions { + return StartWebSiteNetworkTraceOperationOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceOperation ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperation(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) (result StartWebSiteNetworkTraceOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/startOperation", 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 +} + +// StartWebSiteNetworkTraceOperationThenPoll performs StartWebSiteNetworkTraceOperation then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationThenPoll(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperationslot.go b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperationslot.go new file mode 100644 index 00000000000..90f4cda8f0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceoperationslot.go @@ -0,0 +1,108 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions() StartWebSiteNetworkTraceOperationSlotOperationOptions { + return StartWebSiteNetworkTraceOperationSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceOperationSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (result StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/startOperation", 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 +} + +// StartWebSiteNetworkTraceOperationSlotThenPoll performs StartWebSiteNetworkTraceOperationSlot then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlotThenPoll(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperationSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceslot.go b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceslot.go new file mode 100644 index 00000000000..10467c0eda1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_startwebsitenetworktraceslot.go @@ -0,0 +1,91 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceSlotOperationOptions() StartWebSiteNetworkTraceSlotOperationOptions { + return StartWebSiteNetworkTraceSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/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 + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stop.go b/resource-manager/web/2024-04-01/webapps/method_stop.go new file mode 100644 index 00000000000..7f3caf53d9d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stop.go @@ -0,0 +1,48 @@ +package webapps + +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 StopOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c WebAppsClient) Stop(ctx context.Context, id commonids.AppServiceId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjob.go b/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjob.go new file mode 100644 index 00000000000..66fcde1e73b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJob ... +func (c WebAppsClient) StopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StopContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjobslot.go b/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjobslot.go new file mode 100644 index 00000000000..6195a3125e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJobSlot ... +func (c WebAppsClient) StopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StopContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopnetworktrace.go b/resource-manager/web/2024-04-01/webapps/method_stopnetworktrace.go new file mode 100644 index 00000000000..098cdf97671 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopnetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +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 StopNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTrace ... +func (c WebAppsClient) StopNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopnetworktraceslot.go b/resource-manager/web/2024-04-01/webapps/method_stopnetworktraceslot.go new file mode 100644 index 00000000000..08644e40fc9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopnetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTraceSlot ... +func (c WebAppsClient) StopNetworkTraceSlot(ctx context.Context, id SlotId) (result StopNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopslot.go b/resource-manager/web/2024-04-01/webapps/method_stopslot.go new file mode 100644 index 00000000000..cd89d662a26 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopSlot ... +func (c WebAppsClient) StopSlot(ctx context.Context, id SlotId) (result StopSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktrace.go b/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktrace.go new file mode 100644 index 00000000000..7c3fcd820e8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +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 StopWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTrace ... +func (c WebAppsClient) StopWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktraceslot.go b/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktraceslot.go new file mode 100644 index 00000000000..4ac3a77814a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_stopwebsitenetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_swapslotslot.go b/resource-manager/web/2024-04-01/webapps/method_swapslotslot.go new file mode 100644 index 00000000000..4adb4148b94 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_swapslotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 SwapSlotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotSlot ... +func (c WebAppsClient) SwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result SwapSlotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotSlotThenPoll performs SwapSlotSlot then polls until it's completed +func (c WebAppsClient) SwapSlotSlotThenPoll(ctx context.Context, id SlotId, input CsmSlotEntity) error { + result, err := c.SwapSlotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_swapslotwithproduction.go b/resource-manager/web/2024-04-01/webapps/method_swapslotwithproduction.go new file mode 100644 index 00000000000..924b47593e5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_swapslotwithproduction.go @@ -0,0 +1,75 @@ +package webapps + +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 SwapSlotWithProductionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotWithProduction ... +func (c WebAppsClient) SwapSlotWithProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result SwapSlotWithProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotWithProductionThenPoll performs SwapSlotWithProduction then polls until it's completed +func (c WebAppsClient) SwapSlotWithProductionThenPoll(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) error { + result, err := c.SwapSlotWithProduction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotWithProduction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotWithProduction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncfunctions.go b/resource-manager/web/2024-04-01/webapps/method_syncfunctions.go new file mode 100644 index 00000000000..f9e53a89d27 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncfunctions.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctions ... +func (c WebAppsClient) SyncFunctions(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncfunctionsslot.go b/resource-manager/web/2024-04-01/webapps/method_syncfunctionsslot.go new file mode 100644 index 00000000000..37773597814 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncfunctionsslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionsSlot ... +func (c WebAppsClient) SyncFunctionsSlot(ctx context.Context, id SlotId) (result SyncFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggers.go b/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggers.go new file mode 100644 index 00000000000..1370fe7c5d3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggers.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggers ... +func (c WebAppsClient) SyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggersslot.go b/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggersslot.go new file mode 100644 index 00000000000..f3cef3f11df --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncfunctiontriggersslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggersSlot ... +func (c WebAppsClient) SyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result SyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncrepository.go b/resource-manager/web/2024-04-01/webapps/method_syncrepository.go new file mode 100644 index 00000000000..d798d4f5793 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncrepository.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncRepositoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepository ... +func (c WebAppsClient) SyncRepository(ctx context.Context, id commonids.AppServiceId) (result SyncRepositoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_syncrepositoryslot.go b/resource-manager/web/2024-04-01/webapps/method_syncrepositoryslot.go new file mode 100644 index 00000000000..81b7009d872 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_syncrepositoryslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncRepositorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepositorySlot ... +func (c WebAppsClient) SyncRepositorySlot(ctx context.Context, id SlotId) (result SyncRepositorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_update.go b/resource-manager/web/2024-04-01/webapps/method_update.go new file mode 100644 index 00000000000..ce51465dd90 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_update.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Update ... +func (c WebAppsClient) Update(ctx context.Context, id commonids.AppServiceId, input SitePatchResource) (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 + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettings.go b/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettings.go new file mode 100644 index 00000000000..a6abe2e7f9f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettings.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettings ... +func (c WebAppsClient) UpdateApplicationSettings(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettingsslot.go new file mode 100644 index 00000000000..dabaad9a1bb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateapplicationsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettingsSlot ... +func (c WebAppsClient) UpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateauthsettings.go b/resource-manager/web/2024-04-01/webapps/method_updateauthsettings.go new file mode 100644 index 00000000000..c4721b446e6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateauthsettings.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettings ... +func (c WebAppsClient) UpdateAuthSettings(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettings) (result UpdateAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", 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 + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsslot.go new file mode 100644 index 00000000000..efd12302a3c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettingsSlot ... +func (c WebAppsClient) UpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (result UpdateAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", 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 + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2.go b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2.go new file mode 100644 index 00000000000..630b45422db --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2 ... +func (c WebAppsClient) UpdateAuthSettingsV2(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2slot.go b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2slot.go new file mode 100644 index 00000000000..6e054358fe5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateauthsettingsv2slot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2Slot ... +func (c WebAppsClient) UpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccounts.go b/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccounts.go new file mode 100644 index 00000000000..bbda87f586c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccounts.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccounts ... +func (c WebAppsClient) UpdateAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", 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 + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccountsslot.go b/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccountsslot.go new file mode 100644 index 00000000000..de67b3d4cff --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateazurestorageaccountsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccountsSlot ... +func (c WebAppsClient) UpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", 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 + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatebackupconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_updatebackupconfiguration.go new file mode 100644 index 00000000000..eadd42c46b4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatebackupconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfiguration ... +func (c WebAppsClient) UpdateBackupConfiguration(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result UpdateBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatebackupconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_updatebackupconfigurationslot.go new file mode 100644 index 00000000000..6cc6c0db6dd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatebackupconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfigurationSlot ... +func (c WebAppsClient) UpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (result UpdateBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateconfiguration.go b/resource-manager/web/2024-04-01/webapps/method_updateconfiguration.go new file mode 100644 index 00000000000..540effb8493 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfiguration ... +func (c WebAppsClient) UpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result UpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateconfigurationslot.go b/resource-manager/web/2024-04-01/webapps/method_updateconfigurationslot.go new file mode 100644 index 00000000000..2b8a3c837d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfigurationSlot ... +func (c WebAppsClient) UpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result UpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", 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 + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateconnectionstrings.go b/resource-manager/web/2024-04-01/webapps/method_updateconnectionstrings.go new file mode 100644 index 00000000000..e2583e323f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateconnectionstrings.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStrings ... +func (c WebAppsClient) UpdateConnectionStrings(ctx context.Context, id commonids.AppServiceId, input ConnectionStringDictionary) (result UpdateConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", 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 + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateconnectionstringsslot.go b/resource-manager/web/2024-04-01/webapps/method_updateconnectionstringsslot.go new file mode 100644 index 00000000000..02c8aab1742 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateconnectionstringsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStringsSlot ... +func (c WebAppsClient) UpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (result UpdateConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", 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 + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfig.go b/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfig.go new file mode 100644 index 00000000000..3fd9dd8089b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfig.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateDiagnosticLogsConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfig ... +func (c WebAppsClient) UpdateDiagnosticLogsConfig(ctx context.Context, id commonids.AppServiceId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", 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 + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfigslot.go b/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfigslot.go new file mode 100644 index 00000000000..76e26082497 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatediagnosticlogsconfigslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateDiagnosticLogsConfigSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfigSlot ... +func (c WebAppsClient) UpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", 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 + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifier.go b/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifier.go new file mode 100644 index 00000000000..8bb087cd8f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifier.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifierslot.go b/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..8bfd226892c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatedomainownershipidentifierslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateftpallowed.go b/resource-manager/web/2024-04-01/webapps/method_updateftpallowed.go new file mode 100644 index 00000000000..fb80df44e08 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateftpallowed.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowed ... +func (c WebAppsClient) UpdateFtpAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateftpallowedslot.go b/resource-manager/web/2024-04-01/webapps/method_updateftpallowedslot.go new file mode 100644 index 00000000000..8600093e952 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateftpallowedslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowedSlot ... +func (c WebAppsClient) UpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatehybridconnection.go b/resource-manager/web/2024-04-01/webapps/method_updatehybridconnection.go new file mode 100644 index 00000000000..14d186263b3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatehybridconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnection ... +func (c WebAppsClient) UpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result UpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatehybridconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_updatehybridconnectionslot.go new file mode 100644 index 00000000000..8136fefe9af --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatehybridconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnectionSlot ... +func (c WebAppsClient) UpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result UpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatemachinekey.go b/resource-manager/web/2024-04-01/webapps/method_updatemachinekey.go new file mode 100644 index 00000000000..795eaf05e0d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatemachinekey.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateMachineKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// UpdateMachineKey ... +func (c WebAppsClient) UpdateMachineKey(ctx context.Context, id commonids.AppServiceId) (result UpdateMachineKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updatemachinekey", 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 + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatemetadata.go b/resource-manager/web/2024-04-01/webapps/method_updatemetadata.go new file mode 100644 index 00000000000..55294309b86 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatemetadata.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadata ... +func (c WebAppsClient) UpdateMetadata(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatemetadataslot.go b/resource-manager/web/2024-04-01/webapps/method_updatemetadataslot.go new file mode 100644 index 00000000000..99995876e7c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatemetadataslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadataSlot ... +func (c WebAppsClient) UpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", 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 + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatepremieraddon.go b/resource-manager/web/2024-04-01/webapps/method_updatepremieraddon.go new file mode 100644 index 00000000000..dcd3c9b2a8b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatepremieraddon.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdatePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOn ... +func (c WebAppsClient) UpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatepremieraddonslot.go b/resource-manager/web/2024-04-01/webapps/method_updatepremieraddonslot.go new file mode 100644 index 00000000000..e1c27a4d55e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatepremieraddonslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdatePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOnSlot ... +func (c WebAppsClient) UpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnection.go b/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnection.go new file mode 100644 index 00000000000..cd611e9ec20 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnection ... +func (c WebAppsClient) UpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..c24d82100f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updaterelayserviceconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) UpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatescmallowed.go b/resource-manager/web/2024-04-01/webapps/method_updatescmallowed.go new file mode 100644 index 00000000000..120d3629001 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatescmallowed.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowed ... +func (c WebAppsClient) UpdateScmAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatescmallowedslot.go b/resource-manager/web/2024-04-01/webapps/method_updatescmallowedslot.go new file mode 100644 index 00000000000..a3243abfa63 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatescmallowedslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowedSlot ... +func (c WebAppsClient) UpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettings.go b/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettings.go new file mode 100644 index 00000000000..668665c05d4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettings.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettings ... +func (c WebAppsClient) UpdateSitePushSettings(ctx context.Context, id commonids.AppServiceId, input PushSettings) (result UpdateSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", 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 + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettingsslot.go b/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettingsslot.go new file mode 100644 index 00000000000..09988246b8c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatesitepushsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettingsSlot ... +func (c WebAppsClient) UpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (result UpdateSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", 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 + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateslot.go b/resource-manager/web/2024-04-01/webapps/method_updateslot.go new file mode 100644 index 00000000000..82afe00eea3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// UpdateSlot ... +func (c WebAppsClient) UpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (result UpdateSlotOperationResponse, 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 + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateslotconfigurationnames.go b/resource-manager/web/2024-04-01/webapps/method_updateslotconfigurationnames.go new file mode 100644 index 00000000000..8eb1665dd4d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateslotconfigurationnames.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// UpdateSlotConfigurationNames ... +func (c WebAppsClient) UpdateSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId, input SlotConfigNamesResource) (result UpdateSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/slotConfigNames", 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 + } + + var model SlotConfigNamesResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrol.go b/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrol.go new file mode 100644 index 00000000000..a9b4d29999b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrol.go @@ -0,0 +1,61 @@ +package webapps + +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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControl ... +func (c WebAppsClient) UpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrolslot.go b/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrolslot.go new file mode 100644 index 00000000000..27063f72815 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatesourcecontrolslot.go @@ -0,0 +1,60 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControlSlot ... +func (c WebAppsClient) UpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result UpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..1ed44d1b945 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..86d0e38f499 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatevnetconnection.go b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnection.go new file mode 100644 index 00000000000..d24ddba2035 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnection.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnection ... +func (c WebAppsClient) UpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongateway.go b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongateway.go new file mode 100644 index 00000000000..710e26ab2d6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongateway.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGateway ... +func (c WebAppsClient) UpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result UpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongatewayslot.go b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..e292d9dd430 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectiongatewayslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) UpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectionslot.go b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectionslot.go new file mode 100644 index 00000000000..1ce4e92a640 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/method_updatevnetconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +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 UpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnectionSlot ... +func (c WebAppsClient) UpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/webapps/model_allowedaudiencesvalidation.go b/resource-manager/web/2024-04-01/webapps/model_allowedaudiencesvalidation.go new file mode 100644 index 00000000000..da259d9fd38 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_allowedaudiencesvalidation.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedAudiencesValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_allowedprincipals.go b/resource-manager/web/2024-04-01/webapps/model_allowedprincipals.go new file mode 100644 index 00000000000..b17b5652dd2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_allowedprincipals.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedPrincipals struct { + Groups *[]string `json:"groups,omitempty"` + Identities *[]string `json:"identities,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_apidefinitioninfo.go b/resource-manager/web/2024-04-01/webapps/model_apidefinitioninfo.go new file mode 100644 index 00000000000..152027e15e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_apikvreference.go b/resource-manager/web/2024-04-01/webapps/model_apikvreference.go new file mode 100644 index 00000000000..62f12266d3b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_apikvreference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApiKVReferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_apikvreferenceproperties.go b/resource-manager/web/2024-04-01/webapps/model_apikvreferenceproperties.go new file mode 100644 index 00000000000..58a0f5398cc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_apikvreferenceproperties.go @@ -0,0 +1,20 @@ +package webapps + +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 ApiKVReferenceProperties struct { + ActiveVersion *string `json:"activeVersion,omitempty"` + Details *string `json:"details,omitempty"` + IdentityType *identity.SystemAndUserAssignedMap `json:"identityType,omitempty"` + Reference *string `json:"reference,omitempty"` + SecretName *string `json:"secretName,omitempty"` + SecretVersion *string `json:"secretVersion,omitempty"` + Source *ConfigReferenceSource `json:"source,omitempty"` + Status *ResolveStatus `json:"status,omitempty"` + VaultName *string `json:"vaultName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_apimanagementconfig.go b/resource-manager/web/2024-04-01/webapps/model_apimanagementconfig.go new file mode 100644 index 00000000000..9acd3c84278 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_apple.go b/resource-manager/web/2024-04-01/webapps/model_apple.go new file mode 100644 index 00000000000..69e9769061b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_apple.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Apple struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppleRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_appleregistration.go b/resource-manager/web/2024-04-01/webapps/model_appleregistration.go new file mode 100644 index 00000000000..304a6b2b50f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_appleregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppleRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_applicationlogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_applicationlogsconfig.go new file mode 100644 index 00000000000..9734bceb194 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_applicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationLogsConfig struct { + AzureBlobStorage *AzureBlobStorageApplicationLogsConfig `json:"azureBlobStorage,omitempty"` + AzureTableStorage *AzureTableStorageApplicationLogsConfig `json:"azureTableStorage,omitempty"` + FileSystem *FileSystemApplicationLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_appregistration.go b/resource-manager/web/2024-04-01/webapps/model_appregistration.go new file mode 100644 index 00000000000..658b68d4c6e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_appregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppRegistration struct { + AppId *string `json:"appId,omitempty"` + AppSecretSettingName *string `json:"appSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_armidwrapper.go b/resource-manager/web/2024-04-01/webapps/model_armidwrapper.go new file mode 100644 index 00000000000..f73fbd64bb2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_armidwrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_authplatform.go b/resource-manager/web/2024-04-01/webapps/model_authplatform.go new file mode 100644 index 00000000000..c1222a45d4e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_authplatform.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthPlatform struct { + ConfigFilePath *string `json:"configFilePath,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_autohealactions.go b/resource-manager/web/2024-04-01/webapps/model_autohealactions.go new file mode 100644 index 00000000000..c33d955c76e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_autohealactions.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_autohealcustomaction.go b/resource-manager/web/2024-04-01/webapps/model_autohealcustomaction.go new file mode 100644 index 00000000000..49bfb9eb35b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_autohealrules.go b/resource-manager/web/2024-04-01/webapps/model_autohealrules.go new file mode 100644 index 00000000000..b96bc1ad965 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_autohealrules.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_autohealtriggers.go b/resource-manager/web/2024-04-01/webapps/model_autohealtriggers.go new file mode 100644 index 00000000000..932862aab96 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureactivedirectory.go b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectory.go new file mode 100644 index 00000000000..cda4c5114d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectory struct { + Enabled *bool `json:"enabled,omitempty"` + IsAutoProvisioned *bool `json:"isAutoProvisioned,omitempty"` + Login *AzureActiveDirectoryLogin `json:"login,omitempty"` + Registration *AzureActiveDirectoryRegistration `json:"registration,omitempty"` + Validation *AzureActiveDirectoryValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureactivedirectorylogin.go b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectorylogin.go new file mode 100644 index 00000000000..590062cd0e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectorylogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryLogin struct { + DisableWWWAuthenticate *bool `json:"disableWWWAuthenticate,omitempty"` + LoginParameters *[]string `json:"loginParameters,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryregistration.go b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryregistration.go new file mode 100644 index 00000000000..8cb7ab16efb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryregistration.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretCertificateIssuer *string `json:"clientSecretCertificateIssuer,omitempty"` + ClientSecretCertificateSubjectAlternativeName *string `json:"clientSecretCertificateSubjectAlternativeName,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + OpenIdIssuer *string `json:"openIdIssuer,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryvalidation.go b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryvalidation.go new file mode 100644 index 00000000000..bd699d34a12 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureactivedirectoryvalidation.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + DefaultAuthorizationPolicy *DefaultAuthorizationPolicy `json:"defaultAuthorizationPolicy,omitempty"` + JwtClaimChecks *JwtClaimChecks `json:"jwtClaimChecks,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureblobstorageapplicationlogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_azureblobstorageapplicationlogsconfig.go new file mode 100644 index 00000000000..37a7b27b3e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureblobstorageapplicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azureblobstoragehttplogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_azureblobstoragehttplogsconfig.go new file mode 100644 index 00000000000..74820c0d5ac --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azureblobstoragehttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azurestaticwebapps.go b/resource-manager/web/2024-04-01/webapps/model_azurestaticwebapps.go new file mode 100644 index 00000000000..16d67230d5f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azurestaticwebapps.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebApps struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *AzureStaticWebAppsRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azurestaticwebappsregistration.go b/resource-manager/web/2024-04-01/webapps/model_azurestaticwebappsregistration.go new file mode 100644 index 00000000000..bd78e405cfe --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azurestaticwebappsregistration.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebAppsRegistration struct { + ClientId *string `json:"clientId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azurestorageinfovalue.go b/resource-manager/web/2024-04-01/webapps/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..e92f9c01952 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azurestoragepropertydictionaryresource.go b/resource-manager/web/2024-04-01/webapps/model_azurestoragepropertydictionaryresource.go new file mode 100644 index 00000000000..6c7675fec3f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azurestoragepropertydictionaryresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStoragePropertyDictionaryResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]AzureStorageInfoValue `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_azuretablestorageapplicationlogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_azuretablestorageapplicationlogsconfig.go new file mode 100644 index 00000000000..8d8ca355fe4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_azuretablestorageapplicationlogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTableStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + SasURL string `json:"sasUrl"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_backupitem.go b/resource-manager/web/2024-04-01/webapps/model_backupitem.go new file mode 100644 index 00000000000..7bf578be3a9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_backupitem.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupItem struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_backupitemproperties.go b/resource-manager/web/2024-04-01/webapps/model_backupitemproperties.go new file mode 100644 index 00000000000..b74153eec80 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_backupitemproperties.go @@ -0,0 +1,63 @@ +package webapps + +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 BackupItemProperties struct { + BlobName *string `json:"blobName,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + Created *string `json:"created,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + FinishedTimeStamp *string `json:"finishedTimeStamp,omitempty"` + Id *int64 `json:"id,omitempty"` + LastRestoreTimeStamp *string `json:"lastRestoreTimeStamp,omitempty"` + Log *string `json:"log,omitempty"` + Name *string `json:"name,omitempty"` + Scheduled *bool `json:"scheduled,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + Status *BackupItemStatus `json:"status,omitempty"` + StorageAccountURL *string `json:"storageAccountUrl,omitempty"` + WebsiteSizeInBytes *int64 `json:"websiteSizeInBytes,omitempty"` +} + +func (o *BackupItemProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} + +func (o *BackupItemProperties) GetFinishedTimeStampAsTime() (*time.Time, error) { + if o.FinishedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FinishedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetFinishedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FinishedTimeStamp = &formatted +} + +func (o *BackupItemProperties) GetLastRestoreTimeStampAsTime() (*time.Time, error) { + if o.LastRestoreTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRestoreTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetLastRestoreTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRestoreTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_backuprequest.go b/resource-manager/web/2024-04-01/webapps/model_backuprequest.go new file mode 100644 index 00000000000..5247f8695cc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_backuprequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_backuprequestproperties.go b/resource-manager/web/2024-04-01/webapps/model_backuprequestproperties.go new file mode 100644 index 00000000000..0d0229d8c83 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_backuprequestproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequestProperties struct { + BackupName *string `json:"backupName,omitempty"` + BackupSchedule *BackupSchedule `json:"backupSchedule,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + StorageAccountURL string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_backupschedule.go b/resource-manager/web/2024-04-01/webapps/model_backupschedule.go new file mode 100644 index 00000000000..8fb777f2e01 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_backupschedule.go @@ -0,0 +1,43 @@ +package webapps + +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 BackupSchedule struct { + FrequencyInterval int64 `json:"frequencyInterval"` + FrequencyUnit FrequencyUnit `json:"frequencyUnit"` + KeepAtLeastOneBackup bool `json:"keepAtLeastOneBackup"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + RetentionPeriodInDays int64 `json:"retentionPeriodInDays"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *BackupSchedule) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *BackupSchedule) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_blobstoragetokenstore.go b/resource-manager/web/2024-04-01/webapps/model_blobstoragetokenstore.go new file mode 100644 index 00000000000..2cbf67fbeae --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_blobstoragetokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BlobStorageTokenStore struct { + SasURLSettingName *string `json:"sasUrlSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_clientregistration.go b/resource-manager/web/2024-04-01/webapps/model_clientregistration.go new file mode 100644 index 00000000000..a0983671ae0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_clientregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_cloninginfo.go b/resource-manager/web/2024-04-01/webapps/model_cloninginfo.go new file mode 100644 index 00000000000..0934bb9fecc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_cloninginfo.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_connectionstringdictionary.go b/resource-manager/web/2024-04-01/webapps/model_connectionstringdictionary.go new file mode 100644 index 00000000000..ce8d8b95927 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_connectionstringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionStringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]ConnStringValueTypePair `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_connstringinfo.go b/resource-manager/web/2024-04-01/webapps/model_connstringinfo.go new file mode 100644 index 00000000000..a41ade2e9db --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_connstringinfo.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_connstringvaluetypepair.go b/resource-manager/web/2024-04-01/webapps/model_connstringvaluetypepair.go new file mode 100644 index 00000000000..a80c0c6b95e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_connstringvaluetypepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringValueTypePair struct { + Type ConnectionStringType `json:"type"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containercpustatistics.go b/resource-manager/web/2024-04-01/webapps/model_containercpustatistics.go new file mode 100644 index 00000000000..dd2b3964567 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containercpustatistics.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUStatistics struct { + CpuUsage *ContainerCPUUsage `json:"cpuUsage,omitempty"` + OnlineCPUCount *int64 `json:"onlineCpuCount,omitempty"` + SystemCPUUsage *int64 `json:"systemCpuUsage,omitempty"` + ThrottlingData *ContainerThrottlingData `json:"throttlingData,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containercpuusage.go b/resource-manager/web/2024-04-01/webapps/model_containercpuusage.go new file mode 100644 index 00000000000..c7c0de7ff15 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containercpuusage.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUUsage struct { + KernelModeUsage *int64 `json:"kernelModeUsage,omitempty"` + PerCPUUsage *[]int64 `json:"perCpuUsage,omitempty"` + TotalUsage *int64 `json:"totalUsage,omitempty"` + UserModeUsage *int64 `json:"userModeUsage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containerinfo.go b/resource-manager/web/2024-04-01/webapps/model_containerinfo.go new file mode 100644 index 00000000000..e69d7c9d60a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containerinfo.go @@ -0,0 +1,45 @@ +package webapps + +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 ContainerInfo struct { + CurrentCPUStats *ContainerCPUStatistics `json:"currentCpuStats,omitempty"` + CurrentTimeStamp *string `json:"currentTimeStamp,omitempty"` + Eth0 *ContainerNetworkInterfaceStatistics `json:"eth0,omitempty"` + Id *string `json:"id,omitempty"` + MemoryStats *ContainerMemoryStatistics `json:"memoryStats,omitempty"` + Name *string `json:"name,omitempty"` + PreviousCPUStats *ContainerCPUStatistics `json:"previousCpuStats,omitempty"` + PreviousTimeStamp *string `json:"previousTimeStamp,omitempty"` +} + +func (o *ContainerInfo) GetCurrentTimeStampAsTime() (*time.Time, error) { + if o.CurrentTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CurrentTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetCurrentTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CurrentTimeStamp = &formatted +} + +func (o *ContainerInfo) GetPreviousTimeStampAsTime() (*time.Time, error) { + if o.PreviousTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PreviousTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetPreviousTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PreviousTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containermemorystatistics.go b/resource-manager/web/2024-04-01/webapps/model_containermemorystatistics.go new file mode 100644 index 00000000000..766817d234f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containermemorystatistics.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerMemoryStatistics struct { + Limit *int64 `json:"limit,omitempty"` + MaxUsage *int64 `json:"maxUsage,omitempty"` + Usage *int64 `json:"usage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containernetworkinterfacestatistics.go b/resource-manager/web/2024-04-01/webapps/model_containernetworkinterfacestatistics.go new file mode 100644 index 00000000000..70eed77205c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containernetworkinterfacestatistics.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceStatistics struct { + RxBytes *int64 `json:"rxBytes,omitempty"` + RxDropped *int64 `json:"rxDropped,omitempty"` + RxErrors *int64 `json:"rxErrors,omitempty"` + RxPackets *int64 `json:"rxPackets,omitempty"` + TxBytes *int64 `json:"txBytes,omitempty"` + TxDropped *int64 `json:"txDropped,omitempty"` + TxErrors *int64 `json:"txErrors,omitempty"` + TxPackets *int64 `json:"txPackets,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_containerthrottlingdata.go b/resource-manager/web/2024-04-01/webapps/model_containerthrottlingdata.go new file mode 100644 index 00000000000..9a8399671cb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_containerthrottlingdata.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerThrottlingData struct { + Periods *int64 `json:"periods,omitempty"` + ThrottledPeriods *int64 `json:"throttledPeriods,omitempty"` + ThrottledTime *int64 `json:"throttledTime,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_continuouswebjob.go b/resource-manager/web/2024-04-01/webapps/model_continuouswebjob.go new file mode 100644 index 00000000000..960c0b21c35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_continuouswebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContinuousWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_continuouswebjobproperties.go b/resource-manager/web/2024-04-01/webapps/model_continuouswebjobproperties.go new file mode 100644 index 00000000000..ae1f697a892 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_continuouswebjobproperties.go @@ -0,0 +1,17 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJobProperties struct { + DetailedStatus *string `json:"detailed_status,omitempty"` + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + LogUrl *string `json:"log_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Status *ContinuousWebJobStatus `json:"status,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_cookieexpiration.go b/resource-manager/web/2024-04-01/webapps/model_cookieexpiration.go new file mode 100644 index 00000000000..1acd40bff42 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_cookieexpiration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CookieExpiration struct { + Convention *CookieExpirationConvention `json:"convention,omitempty"` + TimeToExpiration *string `json:"timeToExpiration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_corssettings.go b/resource-manager/web/2024-04-01/webapps/model_corssettings.go new file mode 100644 index 00000000000..58894d63e23 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_corssettings.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatus.go b/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatus.go new file mode 100644 index 00000000000..011d7f38b97 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmDeploymentStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatusproperties.go b/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatusproperties.go new file mode 100644 index 00000000000..08a6ae20c11 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmdeploymentstatusproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatusProperties struct { + DeploymentId *string `json:"deploymentId,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + FailedInstancesLogs *[]string `json:"failedInstancesLogs,omitempty"` + NumberOfInstancesFailed *int64 `json:"numberOfInstancesFailed,omitempty"` + NumberOfInstancesInProgress *int64 `json:"numberOfInstancesInProgress,omitempty"` + NumberOfInstancesSuccessful *int64 `json:"numberOfInstancesSuccessful,omitempty"` + Status *DeploymentBuildStatus `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentity.go b/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentity.go new file mode 100644 index 00000000000..dcdf32e913e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmPublishingCredentialsPoliciesEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go b/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go new file mode 100644 index 00000000000..bc91e5c0882 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntityProperties struct { + Allow bool `json:"allow"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmpublishingprofileoptions.go b/resource-manager/web/2024-04-01/webapps/model_csmpublishingprofileoptions.go new file mode 100644 index 00000000000..acf65055371 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmpublishingprofileoptions.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingProfileOptions struct { + Format *PublishingProfileFormat `json:"format,omitempty"` + IncludeDisasterRecoveryEndpoints *bool `json:"includeDisasterRecoveryEndpoints,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmslotentity.go b/resource-manager/web/2024-04-01/webapps/model_csmslotentity.go new file mode 100644 index 00000000000..086fe3ab931 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmslotentity.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmSlotEntity struct { + PreserveVnet bool `json:"preserveVnet"` + TargetSlot string `json:"targetSlot"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_csmusagequota.go b/resource-manager/web/2024-04-01/webapps/model_csmusagequota.go new file mode 100644 index 00000000000..7fad4d7865d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_csmusagequota.go @@ -0,0 +1,30 @@ +package webapps + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresult.go b/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresult.go new file mode 100644 index 00000000000..965958b5906 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresult.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResult struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameAnalysisResultProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresultproperties.go b/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresultproperties.go new file mode 100644 index 00000000000..e8641765248 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_customhostnameanalysisresultproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultProperties struct { + ARecords *[]string `json:"aRecords,omitempty"` + AlternateCNameRecords *[]string `json:"alternateCNameRecords,omitempty"` + AlternateTxtRecords *[]string `json:"alternateTxtRecords,omitempty"` + CNameRecords *[]string `json:"cNameRecords,omitempty"` + ConflictingAppResourceId *string `json:"conflictingAppResourceId,omitempty"` + CustomDomainVerificationFailureInfo *ErrorEntity `json:"customDomainVerificationFailureInfo,omitempty"` + CustomDomainVerificationTest *DnsVerificationTestResult `json:"customDomainVerificationTest,omitempty"` + HasConflictAcrossSubscription *bool `json:"hasConflictAcrossSubscription,omitempty"` + HasConflictOnScaleUnit *bool `json:"hasConflictOnScaleUnit,omitempty"` + IsHostnameAlreadyVerified *bool `json:"isHostnameAlreadyVerified,omitempty"` + TxtRecords *[]string `json:"txtRecords,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_customopenidconnectprovider.go b/resource-manager/web/2024-04-01/webapps/model_customopenidconnectprovider.go new file mode 100644 index 00000000000..6131cc54b0f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_customopenidconnectprovider.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomOpenIdConnectProvider struct { + Enabled *bool `json:"enabled,omitempty"` + Login *OpenIdConnectLogin `json:"login,omitempty"` + Registration *OpenIdConnectRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_daprconfig.go b/resource-manager/web/2024-04-01/webapps/model_daprconfig.go new file mode 100644 index 00000000000..4405627b643 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_daprconfig.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_databasebackupsetting.go b/resource-manager/web/2024-04-01/webapps/model_databasebackupsetting.go new file mode 100644 index 00000000000..57baff31aa0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_databasebackupsetting.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseBackupSetting struct { + ConnectionString *string `json:"connectionString,omitempty"` + ConnectionStringName *string `json:"connectionStringName,omitempty"` + DatabaseType DatabaseType `json:"databaseType"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_defaultauthorizationpolicy.go b/resource-manager/web/2024-04-01/webapps/model_defaultauthorizationpolicy.go new file mode 100644 index 00000000000..7cc4f0cf723 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_defaultauthorizationpolicy.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAuthorizationPolicy struct { + AllowedApplications *[]string `json:"allowedApplications,omitempty"` + AllowedPrincipals *AllowedPrincipals `json:"allowedPrincipals,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequest.go b/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequest.go new file mode 100644 index 00000000000..9ef81650415 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedAppRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequestproperties.go b/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequestproperties.go new file mode 100644 index 00000000000..48010e62a87 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_deletedapprestorerequestproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequestProperties struct { + DeletedSiteId *string `json:"deletedSiteId,omitempty"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_deployment.go b/resource-manager/web/2024-04-01/webapps/model_deployment.go new file mode 100644 index 00000000000..764e2891dd4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_deployment.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Deployment struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeploymentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_deploymentproperties.go b/resource-manager/web/2024-04-01/webapps/model_deploymentproperties.go new file mode 100644 index 00000000000..62df75e6494 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_deploymentproperties.go @@ -0,0 +1,46 @@ +package webapps + +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 DeploymentProperties struct { + Active *bool `json:"active,omitempty"` + Author *string `json:"author,omitempty"` + AuthorEmail *string `json:"author_email,omitempty"` + Deployer *string `json:"deployer,omitempty"` + Details *string `json:"details,omitempty"` + EndTime *string `json:"end_time,omitempty"` + Message *string `json:"message,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *int64 `json:"status,omitempty"` +} + +func (o *DeploymentProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DeploymentProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_enabledconfig.go b/resource-manager/web/2024-04-01/webapps/model_enabledconfig.go new file mode 100644 index 00000000000..740c6a6f750 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_enabledconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnabledConfig struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_environmentvariable.go b/resource-manager/web/2024-04-01/webapps/model_environmentvariable.go new file mode 100644 index 00000000000..44c25f7e4c1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_environmentvariable.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVariable struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_errorentity.go b/resource-manager/web/2024-04-01/webapps/model_errorentity.go new file mode 100644 index 00000000000..3d84f5ece58 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_errorentity.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_experiments.go b/resource-manager/web/2024-04-01/webapps/model_experiments.go new file mode 100644 index 00000000000..9e8a3418c84 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_experiments.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_extendedlocation.go b/resource-manager/web/2024-04-01/webapps/model_extendedlocation.go new file mode 100644 index 00000000000..3f619b04f38 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_extendedlocation.go @@ -0,0 +1,9 @@ +package webapps + +// 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 *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_facebook.go b/resource-manager/web/2024-04-01/webapps/model_facebook.go new file mode 100644 index 00000000000..834ae971243 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_facebook.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Facebook struct { + Enabled *bool `json:"enabled,omitempty"` + GraphApiVersion *string `json:"graphApiVersion,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_filesystemapplicationlogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_filesystemapplicationlogsconfig.go new file mode 100644 index 00000000000..89cb89d942b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_filesystemapplicationlogsconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_filesystemhttplogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_filesystemhttplogsconfig.go new file mode 100644 index 00000000000..f69fa8fecca --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_filesystemhttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + RetentionInMb *int64 `json:"retentionInMb,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_filesystemtokenstore.go b/resource-manager/web/2024-04-01/webapps/model_filesystemtokenstore.go new file mode 100644 index 00000000000..123a111d50b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_filesystemtokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemTokenStore struct { + Directory *string `json:"directory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_forwardproxy.go b/resource-manager/web/2024-04-01/webapps/model_forwardproxy.go new file mode 100644 index 00000000000..897a226b706 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_forwardproxy.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForwardProxy struct { + Convention *ForwardProxyConvention `json:"convention,omitempty"` + CustomHostHeaderName *string `json:"customHostHeaderName,omitempty"` + CustomProtoHeaderName *string `json:"customProtoHeaderName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionappconfig.go b/resource-manager/web/2024-04-01/webapps/model_functionappconfig.go new file mode 100644 index 00000000000..598987c0273 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionappconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionenvelope.go b/resource-manager/web/2024-04-01/webapps/model_functionenvelope.go new file mode 100644 index 00000000000..d690c668b8a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionenvelope.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionenvelopeproperties.go b/resource-manager/web/2024-04-01/webapps/model_functionenvelopeproperties.go new file mode 100644 index 00000000000..b32434f7616 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionenvelopeproperties.go @@ -0,0 +1,20 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelopeProperties struct { + Config *interface{} `json:"config,omitempty"` + ConfigHref *string `json:"config_href,omitempty"` + Files *map[string]string `json:"files,omitempty"` + FunctionAppId *string `json:"function_app_id,omitempty"` + Href *string `json:"href,omitempty"` + InvokeUrlTemplate *string `json:"invoke_url_template,omitempty"` + IsDisabled *bool `json:"isDisabled,omitempty"` + Language *string `json:"language,omitempty"` + ScriptHref *string `json:"script_href,omitempty"` + ScriptRootPathHref *string `json:"script_root_path_href,omitempty"` + SecretsFileHref *string `json:"secrets_file_href,omitempty"` + TestData *string `json:"test_data,omitempty"` + TestDataHref *string `json:"test_data_href,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-04-01/webapps/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..b8121838cd6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsdeployment.go b/resource-manager/web/2024-04-01/webapps/model_functionsdeployment.go new file mode 100644 index 00000000000..fa7c6e12a33 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorage.go b/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..b8752386166 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..087a9f1559f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsecrets.go b/resource-manager/web/2024-04-01/webapps/model_functionsecrets.go new file mode 100644 index 00000000000..daa46718fb3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsecrets.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionSecrets struct { + Key *string `json:"key,omitempty"` + TriggerUrl *string `json:"trigger_url,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsruntime.go b/resource-manager/web/2024-04-01/webapps/model_functionsruntime.go new file mode 100644 index 00000000000..025981cf91c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsruntime.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..2d29b194fcc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..070def9b6d2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..e5d499bf429 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_github.go b/resource-manager/web/2024-04-01/webapps/model_github.go new file mode 100644 index 00000000000..0baa912b7f4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_github.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHub struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_githubactioncodeconfiguration.go b/resource-manager/web/2024-04-01/webapps/model_githubactioncodeconfiguration.go new file mode 100644 index 00000000000..96e13fda517 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_githubactioncodeconfiguration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionCodeConfiguration struct { + RuntimeStack *string `json:"runtimeStack,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_githubactionconfiguration.go b/resource-manager/web/2024-04-01/webapps/model_githubactionconfiguration.go new file mode 100644 index 00000000000..3e0089953d8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_githubactionconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionConfiguration struct { + CodeConfiguration *GitHubActionCodeConfiguration `json:"codeConfiguration,omitempty"` + ContainerConfiguration *GitHubActionContainerConfiguration `json:"containerConfiguration,omitempty"` + GenerateWorkflowFile *bool `json:"generateWorkflowFile,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_githubactioncontainerconfiguration.go b/resource-manager/web/2024-04-01/webapps/model_githubactioncontainerconfiguration.go new file mode 100644 index 00000000000..db70b234959 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_githubactioncontainerconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionContainerConfiguration struct { + ImageName *string `json:"imageName,omitempty"` + Password *string `json:"password,omitempty"` + ServerURL *string `json:"serverUrl,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_globalvalidation.go b/resource-manager/web/2024-04-01/webapps/model_globalvalidation.go new file mode 100644 index 00000000000..e3f6446954e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_globalvalidation.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalValidation struct { + ExcludedPaths *[]string `json:"excludedPaths,omitempty"` + RedirectToProvider *string `json:"redirectToProvider,omitempty"` + RequireAuthentication *bool `json:"requireAuthentication,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientActionV2 `json:"unauthenticatedClientAction,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_google.go b/resource-manager/web/2024-04-01/webapps/model_google.go new file mode 100644 index 00000000000..739f5aba70b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_google.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Google struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_handlermapping.go b/resource-manager/web/2024-04-01/webapps/model_handlermapping.go new file mode 100644 index 00000000000..b5593f88002 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_handlermapping.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hostingenvironmentprofile.go b/resource-manager/web/2024-04-01/webapps/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e75ca71ee32 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hostkeys.go b/resource-manager/web/2024-04-01/webapps/model_hostkeys.go new file mode 100644 index 00000000000..af8cb685979 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hostkeys.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostKeys struct { + FunctionKeys *map[string]string `json:"functionKeys,omitempty"` + MasterKey *string `json:"masterKey,omitempty"` + SystemKeys *map[string]string `json:"systemKeys,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hostnamebinding.go b/resource-manager/web/2024-04-01/webapps/model_hostnamebinding.go new file mode 100644 index 00000000000..4759b208afa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hostnamebinding.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBinding struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HostNameBindingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hostnamebindingproperties.go b/resource-manager/web/2024-04-01/webapps/model_hostnamebindingproperties.go new file mode 100644 index 00000000000..89d397ba5fa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hostnamebindingproperties.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBindingProperties struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + DomainId *string `json:"domainId,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hostnamesslstate.go b/resource-manager/web/2024-04-01/webapps/model_hostnamesslstate.go new file mode 100644 index 00000000000..a330c5447ea --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_httplogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_httplogsconfig.go new file mode 100644 index 00000000000..006cccdc08f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_httplogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPLogsConfig struct { + AzureBlobStorage *AzureBlobStorageHTTPLogsConfig `json:"azureBlobStorage,omitempty"` + FileSystem *FileSystemHTTPLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_httpsettings.go b/resource-manager/web/2024-04-01/webapps/model_httpsettings.go new file mode 100644 index 00000000000..50a72c92e61 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_httpsettings.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettings struct { + ForwardProxy *ForwardProxy `json:"forwardProxy,omitempty"` + RequireHTTPS *bool `json:"requireHttps,omitempty"` + Routes *HTTPSettingsRoutes `json:"routes,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_httpsettingsroutes.go b/resource-manager/web/2024-04-01/webapps/model_httpsettingsroutes.go new file mode 100644 index 00000000000..deb06f51434 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_httpsettingsroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettingsRoutes struct { + ApiPrefix *string `json:"apiPrefix,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hybridconnection.go b/resource-manager/web/2024-04-01/webapps/model_hybridconnection.go new file mode 100644 index 00000000000..57e4841bb22 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hybridconnection.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_hybridconnectionproperties.go b/resource-manager/web/2024-04-01/webapps/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..82c9d19bbb9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_identifier.go b/resource-manager/web/2024-04-01/webapps/model_identifier.go new file mode 100644 index 00000000000..134faaa6890 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_identifier.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_identifierproperties.go b/resource-manager/web/2024-04-01/webapps/model_identifierproperties.go new file mode 100644 index 00000000000..3826ff38a2e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_identifierproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_identityproviders.go b/resource-manager/web/2024-04-01/webapps/model_identityproviders.go new file mode 100644 index 00000000000..383fb8243f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_identityproviders.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviders struct { + Apple *Apple `json:"apple,omitempty"` + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + AzureStaticWebApps *AzureStaticWebApps `json:"azureStaticWebApps,omitempty"` + CustomOpenIdConnectProviders *map[string]CustomOpenIdConnectProvider `json:"customOpenIdConnectProviders,omitempty"` + Facebook *Facebook `json:"facebook,omitempty"` + GitHub *GitHub `json:"gitHub,omitempty"` + Google *Google `json:"google,omitempty"` + LegacyMicrosoftAccount *LegacyMicrosoftAccount `json:"legacyMicrosoftAccount,omitempty"` + Twitter *Twitter `json:"twitter,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_ipsecurityrestriction.go b/resource-manager/web/2024-04-01/webapps/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..2d96d9b6520 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_jwtclaimchecks.go b/resource-manager/web/2024-04-01/webapps/model_jwtclaimchecks.go new file mode 100644 index 00000000000..be04286a8e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_jwtclaimchecks.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JwtClaimChecks struct { + AllowedClientApplications *[]string `json:"allowedClientApplications,omitempty"` + AllowedGroups *[]string `json:"allowedGroups,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_keyinfo.go b/resource-manager/web/2024-04-01/webapps/model_keyinfo.go new file mode 100644 index 00000000000..5463d9e53ce --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_keyinfo.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyInfo struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_legacymicrosoftaccount.go b/resource-manager/web/2024-04-01/webapps/model_legacymicrosoftaccount.go new file mode 100644 index 00000000000..77b7761115c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_legacymicrosoftaccount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LegacyMicrosoftAccount struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_localizablestring.go b/resource-manager/web/2024-04-01/webapps/model_localizablestring.go new file mode 100644 index 00000000000..1fac79f7d9f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_localizablestring.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_login.go b/resource-manager/web/2024-04-01/webapps/model_login.go new file mode 100644 index 00000000000..3e8e040d421 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_login.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Login struct { + AllowedExternalRedirectURLs *[]string `json:"allowedExternalRedirectUrls,omitempty"` + CookieExpiration *CookieExpiration `json:"cookieExpiration,omitempty"` + Nonce *Nonce `json:"nonce,omitempty"` + PreserveURLFragmentsForLogins *bool `json:"preserveUrlFragmentsForLogins,omitempty"` + Routes *LoginRoutes `json:"routes,omitempty"` + TokenStore *TokenStore `json:"tokenStore,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_loginroutes.go b/resource-manager/web/2024-04-01/webapps/model_loginroutes.go new file mode 100644 index 00000000000..8009af99b43 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_loginroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginRoutes struct { + LogoutEndpoint *string `json:"logoutEndpoint,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_loginscopes.go b/resource-manager/web/2024-04-01/webapps/model_loginscopes.go new file mode 100644 index 00000000000..4b1160d5562 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_loginscopes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginScopes struct { + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequest.go b/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequest.go new file mode 100644 index 00000000000..7661e8391ae --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequestproperties.go b/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequestproperties.go new file mode 100644 index 00000000000..0a9492d11bb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_migratemysqlrequestproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequestProperties struct { + ConnectionString string `json:"connectionString"` + MigrationType MySqlMigrationType `json:"migrationType"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatus.go b/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatus.go new file mode 100644 index 00000000000..93e2c1806cd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatusproperties.go b/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatusproperties.go new file mode 100644 index 00000000000..bb707fc1768 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_migratemysqlstatusproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatusProperties struct { + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + MigrationOperationStatus *OperationStatus `json:"migrationOperationStatus,omitempty"` + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploy.go b/resource-manager/web/2024-04-01/webapps/model_msdeploy.go new file mode 100644 index 00000000000..27ad333e0e5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploy.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeploy struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploycore.go b/resource-manager/web/2024-04-01/webapps/model_msdeploycore.go new file mode 100644 index 00000000000..e87d9f960ad --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploycore.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployCore struct { + AppOffline *bool `json:"appOffline,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + DbType *string `json:"dbType,omitempty"` + PackageUri *string `json:"packageUri,omitempty"` + SetParameters *map[string]string `json:"setParameters,omitempty"` + SetParametersXmlFileUri *string `json:"setParametersXmlFileUri,omitempty"` + SkipAppData *bool `json:"skipAppData,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploylog.go b/resource-manager/web/2024-04-01/webapps/model_msdeploylog.go new file mode 100644 index 00000000000..344db502e39 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploylog.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLog struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployLogProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploylogentry.go b/resource-manager/web/2024-04-01/webapps/model_msdeploylogentry.go new file mode 100644 index 00000000000..b300f240305 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploylogentry.go @@ -0,0 +1,28 @@ +package webapps + +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 MSDeployLogEntry struct { + Message *string `json:"message,omitempty"` + Time *string `json:"time,omitempty"` + Type *MSDeployLogEntryType `json:"type,omitempty"` +} + +func (o *MSDeployLogEntry) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployLogEntry) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploylogproperties.go b/resource-manager/web/2024-04-01/webapps/model_msdeploylogproperties.go new file mode 100644 index 00000000000..4d30fd74a57 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploylogproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLogProperties struct { + Entries *[]MSDeployLogEntry `json:"entries,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeployproperties.go b/resource-manager/web/2024-04-01/webapps/model_msdeployproperties.go new file mode 100644 index 00000000000..2fdb5e36d60 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeployproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployProperties struct { + AddOnPackages *[]MSDeployCore `json:"addOnPackages,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploystatus.go b/resource-manager/web/2024-04-01/webapps/model_msdeploystatus.go new file mode 100644 index 00000000000..9f782217369 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploystatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_msdeploystatusproperties.go b/resource-manager/web/2024-04-01/webapps/model_msdeploystatusproperties.go new file mode 100644 index 00000000000..739caae3f32 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_msdeploystatusproperties.go @@ -0,0 +1,42 @@ +package webapps + +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 MSDeployStatusProperties struct { + Complete *bool `json:"complete,omitempty"` + Deployer *string `json:"deployer,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ProvisioningState *MSDeployProvisioningState `json:"provisioningState,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *MSDeployStatusProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MSDeployStatusProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_namevaluepair.go b/resource-manager/web/2024-04-01/webapps/model_namevaluepair.go new file mode 100644 index 00000000000..db12fa3a313 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_namevaluepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_networkfeatures.go b/resource-manager/web/2024-04-01/webapps/model_networkfeatures.go new file mode 100644 index 00000000000..34cbbf7f121 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_networkfeatures.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeatures struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkFeaturesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_networkfeaturesproperties.go b/resource-manager/web/2024-04-01/webapps/model_networkfeaturesproperties.go new file mode 100644 index 00000000000..a51a0260488 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_networkfeaturesproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeaturesProperties struct { + HybridConnections *[]RelayServiceConnectionEntity `json:"hybridConnections,omitempty"` + HybridConnectionsV2 *[]HybridConnection `json:"hybridConnectionsV2,omitempty"` + VirtualNetworkConnection *VnetInfo `json:"virtualNetworkConnection,omitempty"` + VirtualNetworkName *string `json:"virtualNetworkName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_networktrace.go b/resource-manager/web/2024-04-01/webapps/model_networktrace.go new file mode 100644 index 00000000000..4c22aec67e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_networktrace.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkTrace struct { + Message *string `json:"message,omitempty"` + Path *string `json:"path,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_nonce.go b/resource-manager/web/2024-04-01/webapps/model_nonce.go new file mode 100644 index 00000000000..ae90e0008f5 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_nonce.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nonce struct { + NonceExpirationInterval *string `json:"nonceExpirationInterval,omitempty"` + ValidateNonce *bool `json:"validateNonce,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_openidconnectclientcredential.go b/resource-manager/web/2024-04-01/webapps/model_openidconnectclientcredential.go new file mode 100644 index 00000000000..11d3fe51886 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_openidconnectclientcredential.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectClientCredential struct { + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + Method *ClientCredentialMethod `json:"method,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_openidconnectconfig.go b/resource-manager/web/2024-04-01/webapps/model_openidconnectconfig.go new file mode 100644 index 00000000000..c76119be643 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_openidconnectconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectConfig struct { + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + CertificationUri *string `json:"certificationUri,omitempty"` + Issuer *string `json:"issuer,omitempty"` + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + WellKnownOpenIdConfiguration *string `json:"wellKnownOpenIdConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_openidconnectlogin.go b/resource-manager/web/2024-04-01/webapps/model_openidconnectlogin.go new file mode 100644 index 00000000000..e8a1c2ae8ed --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_openidconnectlogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectLogin struct { + NameClaimType *string `json:"nameClaimType,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_openidconnectregistration.go b/resource-manager/web/2024-04-01/webapps/model_openidconnectregistration.go new file mode 100644 index 00000000000..faf47478e0c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_openidconnectregistration.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectRegistration struct { + ClientCredential *OpenIdConnectClientCredential `json:"clientCredential,omitempty"` + ClientId *string `json:"clientId,omitempty"` + OpenIdConnectConfiguration *OpenIdConnectConfig `json:"openIdConnectConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_operation.go b/resource-manager/web/2024-04-01/webapps/model_operation.go new file mode 100644 index 00000000000..19973cf1953 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_operation.go @@ -0,0 +1,57 @@ +package webapps + +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 Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_perfmonresponse.go b/resource-manager/web/2024-04-01/webapps/model_perfmonresponse.go new file mode 100644 index 00000000000..9b5ecb7207b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_perfmonresponse.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerfMonResponse struct { + Code *string `json:"code,omitempty"` + Data *PerfMonSet `json:"data,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_perfmonsample.go b/resource-manager/web/2024-04-01/webapps/model_perfmonsample.go new file mode 100644 index 00000000000..d431429707b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_perfmonsample.go @@ -0,0 +1,28 @@ +package webapps + +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 PerfMonSample struct { + InstanceName *string `json:"instanceName,omitempty"` + Time *string `json:"time,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +func (o *PerfMonSample) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSample) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_perfmonset.go b/resource-manager/web/2024-04-01/webapps/model_perfmonset.go new file mode 100644 index 00000000000..3c4b44ec647 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_perfmonset.go @@ -0,0 +1,42 @@ +package webapps + +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 PerfMonSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Values *[]PerfMonSample `json:"values,omitempty"` +} + +func (o *PerfMonSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PerfMonSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_premieraddon.go b/resource-manager/web/2024-04-01/webapps/model_premieraddon.go new file mode 100644 index 00000000000..7d64dfe405d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_premieraddon.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOn struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresource.go b/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresource.go new file mode 100644 index 00000000000..6d715b148db --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresourceproperties.go b/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresourceproperties.go new file mode 100644 index 00000000000..6a330db952e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_premieraddonpatchresourceproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResourceProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_premieraddonproperties.go b/resource-manager/web/2024-04-01/webapps/model_premieraddonproperties.go new file mode 100644 index 00000000000..1a0c2eeb3eb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_premieraddonproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privateaccess.go b/resource-manager/web/2024-04-01/webapps/model_privateaccess.go new file mode 100644 index 00000000000..57bb75c3f6a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privateaccess.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccess struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateAccessProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privateaccessproperties.go b/resource-manager/web/2024-04-01/webapps/model_privateaccessproperties.go new file mode 100644 index 00000000000..654c66fb229 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privateaccessproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessProperties struct { + Enabled *bool `json:"enabled,omitempty"` + VirtualNetworks *[]PrivateAccessVirtualNetwork `json:"virtualNetworks,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privateaccesssubnet.go b/resource-manager/web/2024-04-01/webapps/model_privateaccesssubnet.go new file mode 100644 index 00000000000..c0308f0a6b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privateaccesssubnet.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessSubnet struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privateaccessvirtualnetwork.go b/resource-manager/web/2024-04-01/webapps/model_privateaccessvirtualnetwork.go new file mode 100644 index 00000000000..1aa31d5386c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privateaccessvirtualnetwork.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessVirtualNetwork struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + Subnets *[]PrivateAccessSubnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privatelinkconnectionstate.go b/resource-manager/web/2024-04-01/webapps/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..0cb41b46def --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privatelinkresource.go b/resource-manager/web/2024-04-01/webapps/model_privatelinkresource.go new file mode 100644 index 00000000000..8ad526f8d22 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceproperties.go b/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..681e7763d0b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..44ee0fa08c8 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processinfo.go b/resource-manager/web/2024-04-01/webapps/model_processinfo.go new file mode 100644 index 00000000000..fc0db143ae2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processinfoproperties.go b/resource-manager/web/2024-04-01/webapps/model_processinfoproperties.go new file mode 100644 index 00000000000..705da9f398d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processinfoproperties.go @@ -0,0 +1,73 @@ +package webapps + +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 ProcessInfoProperties struct { + Children *[]string `json:"children,omitempty"` + CommandLine *string `json:"command_line,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + Description *string `json:"description,omitempty"` + EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` + FileName *string `json:"file_name,omitempty"` + HandleCount *int64 `json:"handle_count,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + IisProfileTimeoutInSeconds *float64 `json:"iis_profile_timeout_in_seconds,omitempty"` + IsIisProfileRunning *bool `json:"is_iis_profile_running,omitempty"` + IsProfileRunning *bool `json:"is_profile_running,omitempty"` + IsScmSite *bool `json:"is_scm_site,omitempty"` + IsWebjob *bool `json:"is_webjob,omitempty"` + Minidump *string `json:"minidump,omitempty"` + ModuleCount *int64 `json:"module_count,omitempty"` + Modules *[]ProcessModuleInfo `json:"modules,omitempty"` + NonPagedSystemMemory *int64 `json:"non_paged_system_memory,omitempty"` + OpenFileHandles *[]string `json:"open_file_handles,omitempty"` + PagedMemory *int64 `json:"paged_memory,omitempty"` + PagedSystemMemory *int64 `json:"paged_system_memory,omitempty"` + Parent *string `json:"parent,omitempty"` + PeakPagedMemory *int64 `json:"peak_paged_memory,omitempty"` + PeakVirtualMemory *int64 `json:"peak_virtual_memory,omitempty"` + PeakWorkingSet *int64 `json:"peak_working_set,omitempty"` + PrivateMemory *int64 `json:"private_memory,omitempty"` + PrivilegedCpuTime *string `json:"privileged_cpu_time,omitempty"` + StartTime *string `json:"start_time,omitempty"` + ThreadCount *int64 `json:"thread_count,omitempty"` + Threads *[]ProcessThreadInfo `json:"threads,omitempty"` + TimeStamp *string `json:"time_stamp,omitempty"` + TotalCpuTime *string `json:"total_cpu_time,omitempty"` + UserCpuTime *string `json:"user_cpu_time,omitempty"` + UserName *string `json:"user_name,omitempty"` + VirtualMemory *int64 `json:"virtual_memory,omitempty"` + WorkingSet *int64 `json:"working_set,omitempty"` +} + +func (o *ProcessInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *ProcessInfoProperties) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processmoduleinfo.go b/resource-manager/web/2024-04-01/webapps/model_processmoduleinfo.go new file mode 100644 index 00000000000..9f12d6c8bab --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processmoduleinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessModuleInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processmoduleinfoproperties.go b/resource-manager/web/2024-04-01/webapps/model_processmoduleinfoproperties.go new file mode 100644 index 00000000000..170aa09c221 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processmoduleinfoproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfoProperties struct { + BaseAddress *string `json:"base_address,omitempty"` + FileDescription *string `json:"file_description,omitempty"` + FileName *string `json:"file_name,omitempty"` + FilePath *string `json:"file_path,omitempty"` + FileVersion *string `json:"file_version,omitempty"` + Href *string `json:"href,omitempty"` + IsDebug *bool `json:"is_debug,omitempty"` + Language *string `json:"language,omitempty"` + ModuleMemorySize *int64 `json:"module_memory_size,omitempty"` + Product *string `json:"product,omitempty"` + ProductVersion *string `json:"product_version,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processthreadinfo.go b/resource-manager/web/2024-04-01/webapps/model_processthreadinfo.go new file mode 100644 index 00000000000..f11e4d7370c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processthreadinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessThreadInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessThreadInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_processthreadinfoproperties.go b/resource-manager/web/2024-04-01/webapps/model_processthreadinfoproperties.go new file mode 100644 index 00000000000..e115c1477b6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_processthreadinfoproperties.go @@ -0,0 +1,37 @@ +package webapps + +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 ProcessThreadInfoProperties struct { + BasePriority *int64 `json:"base_priority,omitempty"` + CurrentPriority *int64 `json:"current_priority,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + PriorityLevel *string `json:"priority_level,omitempty"` + Process *string `json:"process,omitempty"` + StartAddress *string `json:"start_address,omitempty"` + StartTime *string `json:"start_time,omitempty"` + State *string `json:"state,omitempty"` + TotalProcessorTime *string `json:"total_processor_time,omitempty"` + UserProcessorTime *string `json:"user_processor_time,omitempty"` + WaitReason *string `json:"wait_reason,omitempty"` +} + +func (o *ProcessThreadInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessThreadInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_publiccertificate.go b/resource-manager/web/2024-04-01/webapps/model_publiccertificate.go new file mode 100644 index 00000000000..41d2238cf35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_publiccertificate.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicCertificateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_publiccertificateproperties.go b/resource-manager/web/2024-04-01/webapps/model_publiccertificateproperties.go new file mode 100644 index 00000000000..291d9a59a0f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_publiccertificateproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificateProperties struct { + Blob *string `json:"blob,omitempty"` + PublicCertificateLocation *PublicCertificateLocation `json:"publicCertificateLocation,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_pushsettings.go b/resource-manager/web/2024-04-01/webapps/model_pushsettings.go new file mode 100644 index 00000000000..c233a60ea49 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_pushsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_pushsettingsproperties.go b/resource-manager/web/2024-04-01/webapps/model_pushsettingsproperties.go new file mode 100644 index 00000000000..bdf39a78d98 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_rampuprule.go b/resource-manager/web/2024-04-01/webapps/model_rampuprule.go new file mode 100644 index 00000000000..2688d09f601 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_rampuprule.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentity.go b/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentity.go new file mode 100644 index 00000000000..a2bfbf4739e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RelayServiceConnectionEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentityproperties.go b/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentityproperties.go new file mode 100644 index 00000000000..608b034c0df --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_relayserviceconnectionentityproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntityProperties struct { + BiztalkUri *string `json:"biztalkUri,omitempty"` + EntityConnectionString *string `json:"entityConnectionString,omitempty"` + EntityName *string `json:"entityName,omitempty"` + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + ResourceConnectionString *string `json:"resourceConnectionString,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..2657ec83161 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..82a747ca53b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_requestsbasedtrigger.go b/resource-manager/web/2024-04-01/webapps/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..f8d9ec672d0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_resourceconfig.go b/resource-manager/web/2024-04-01/webapps/model_resourceconfig.go new file mode 100644 index 00000000000..14a70233fe9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_resourceconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_restorerequest.go b/resource-manager/web/2024-04-01/webapps/model_restorerequest.go new file mode 100644 index 00000000000..c56dde6c785 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_restorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_restorerequestproperties.go b/resource-manager/web/2024-04-01/webapps/model_restorerequestproperties.go new file mode 100644 index 00000000000..ea35e477253 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_restorerequestproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AdjustConnectionStrings *bool `json:"adjustConnectionStrings,omitempty"` + AppServicePlan *string `json:"appServicePlan,omitempty"` + BlobName *string `json:"blobName,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + IgnoreDatabases *bool `json:"ignoreDatabases,omitempty"` + OperationType *BackupRestoreOperationType `json:"operationType,omitempty"` + Overwrite bool `json:"overwrite"` + SiteName *string `json:"siteName,omitempty"` + StorageAccountURL string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_site.go b/resource-manager/web/2024-04-01/webapps/model_site.go new file mode 100644 index 00000000000..48c36824946 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_site.go @@ -0,0 +1,20 @@ +package webapps + +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 Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteauthsettings.go b/resource-manager/web/2024-04-01/webapps/model_siteauthsettings.go new file mode 100644 index 00000000000..b1a8431fdcc --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteauthsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsproperties.go b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsproperties.go new file mode 100644 index 00000000000..7ad71ad2704 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsproperties.go @@ -0,0 +1,45 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsProperties struct { + AadClaimsAuthorization *string `json:"aadClaimsAuthorization,omitempty"` + AdditionalLoginParams *[]string `json:"additionalLoginParams,omitempty"` + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + AllowedExternalRedirectURLs *[]string `json:"allowedExternalRedirectUrls,omitempty"` + AuthFilePath *string `json:"authFilePath,omitempty"` + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + ConfigVersion *string `json:"configVersion,omitempty"` + DefaultProvider *BuiltInAuthenticationProvider `json:"defaultProvider,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FacebookAppId *string `json:"facebookAppId,omitempty"` + FacebookAppSecret *string `json:"facebookAppSecret,omitempty"` + FacebookAppSecretSettingName *string `json:"facebookAppSecretSettingName,omitempty"` + FacebookOAuthScopes *[]string `json:"facebookOAuthScopes,omitempty"` + GitHubClientId *string `json:"gitHubClientId,omitempty"` + GitHubClientSecret *string `json:"gitHubClientSecret,omitempty"` + GitHubClientSecretSettingName *string `json:"gitHubClientSecretSettingName,omitempty"` + GitHubOAuthScopes *[]string `json:"gitHubOAuthScopes,omitempty"` + GoogleClientId *string `json:"googleClientId,omitempty"` + GoogleClientSecret *string `json:"googleClientSecret,omitempty"` + GoogleClientSecretSettingName *string `json:"googleClientSecretSettingName,omitempty"` + GoogleOAuthScopes *[]string `json:"googleOAuthScopes,omitempty"` + IsAuthFromFile *string `json:"isAuthFromFile,omitempty"` + Issuer *string `json:"issuer,omitempty"` + MicrosoftAccountClientId *string `json:"microsoftAccountClientId,omitempty"` + MicrosoftAccountClientSecret *string `json:"microsoftAccountClientSecret,omitempty"` + MicrosoftAccountClientSecretSettingName *string `json:"microsoftAccountClientSecretSettingName,omitempty"` + MicrosoftAccountOAuthScopes *[]string `json:"microsoftAccountOAuthScopes,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` + TokenStoreEnabled *bool `json:"tokenStoreEnabled,omitempty"` + TwitterConsumerKey *string `json:"twitterConsumerKey,omitempty"` + TwitterConsumerSecret *string `json:"twitterConsumerSecret,omitempty"` + TwitterConsumerSecretSettingName *string `json:"twitterConsumerSecretSettingName,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientAction `json:"unauthenticatedClientAction,omitempty"` + ValidateIssuer *bool `json:"validateIssuer,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2.go b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2.go new file mode 100644 index 00000000000..ee79ab12848 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2 struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsV2Properties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2properties.go b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2properties.go new file mode 100644 index 00000000000..9fe4cea0565 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteauthsettingsv2properties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2Properties struct { + GlobalValidation *GlobalValidation `json:"globalValidation,omitempty"` + HTTPSettings *HTTPSettings `json:"httpSettings,omitempty"` + IdentityProviders *IdentityProviders `json:"identityProviders,omitempty"` + Login *Login `json:"login,omitempty"` + Platform *AuthPlatform `json:"platform,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitecloneability.go b/resource-manager/web/2024-04-01/webapps/model_sitecloneability.go new file mode 100644 index 00000000000..ff7a0079247 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitecloneability.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneability struct { + BlockingCharacteristics *[]SiteCloneabilityCriterion `json:"blockingCharacteristics,omitempty"` + BlockingFeatures *[]SiteCloneabilityCriterion `json:"blockingFeatures,omitempty"` + Result *CloneAbilityResult `json:"result,omitempty"` + UnsupportedFeatures *[]SiteCloneabilityCriterion `json:"unsupportedFeatures,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitecloneabilitycriterion.go b/resource-manager/web/2024-04-01/webapps/model_sitecloneabilitycriterion.go new file mode 100644 index 00000000000..89a4c57de83 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitecloneabilitycriterion.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneabilityCriterion struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteconfig.go b/resource-manager/web/2024-04-01/webapps/model_siteconfig.go new file mode 100644 index 00000000000..faaa3834f5e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteconfig.go @@ -0,0 +1,97 @@ +package webapps + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteconfigresource.go b/resource-manager/web/2024-04-01/webapps/model_siteconfigresource.go new file mode 100644 index 00000000000..46d60ffe0b9 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteconfigresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfig `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfo.go b/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..2fea88a6a47 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigurationSnapshotInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfigurationSnapshotInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfoproperties.go b/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfoproperties.go new file mode 100644 index 00000000000..8907cc179db --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteconfigurationsnapshotinfoproperties.go @@ -0,0 +1,27 @@ +package webapps + +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 SiteConfigurationSnapshotInfoProperties struct { + SnapshotId *int64 `json:"snapshotId,omitempty"` + Time *string `json:"time,omitempty"` +} + +func (o *SiteConfigurationSnapshotInfoProperties) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfigurationSnapshotInfoProperties) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitecontainer.go b/resource-manager/web/2024-04-01/webapps/model_sitecontainer.go new file mode 100644 index 00000000000..ab2c105b488 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitecontainer.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteContainer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitecontainerproperties.go b/resource-manager/web/2024-04-01/webapps/model_sitecontainerproperties.go new file mode 100644 index 00000000000..ea67ce1a7e2 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitecontainerproperties.go @@ -0,0 +1,49 @@ +package webapps + +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 SiteContainerProperties struct { + AuthType *AuthType `json:"authType,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` + Image string `json:"image"` + IsMain bool `json:"isMain"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + PasswordSecret *string `json:"passwordSecret,omitempty"` + StartUpCommand *string `json:"startUpCommand,omitempty"` + TargetPort *string `json:"targetPort,omitempty"` + UserManagedIdentityClientId *string `json:"userManagedIdentityClientId,omitempty"` + UserName *string `json:"userName,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} + +func (o *SiteContainerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *SiteContainerProperties) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitednsconfig.go b/resource-manager/web/2024-04-01/webapps/model_sitednsconfig.go new file mode 100644 index 00000000000..e378e356c3f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteextensioninfo.go b/resource-manager/web/2024-04-01/webapps/model_siteextensioninfo.go new file mode 100644 index 00000000000..918563b2f1d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteextensioninfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteExtensionInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteExtensionInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteextensioninfoproperties.go b/resource-manager/web/2024-04-01/webapps/model_siteextensioninfoproperties.go new file mode 100644 index 00000000000..4a10138d54c --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteextensioninfoproperties.go @@ -0,0 +1,57 @@ +package webapps + +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 SiteExtensionInfoProperties struct { + Authors *[]string `json:"authors,omitempty"` + Comment *string `json:"comment,omitempty"` + Description *string `json:"description,omitempty"` + DownloadCount *int64 `json:"download_count,omitempty"` + ExtensionId *string `json:"extension_id,omitempty"` + ExtensionType *SiteExtensionType `json:"extension_type,omitempty"` + ExtensionUrl *string `json:"extension_url,omitempty"` + FeedUrl *string `json:"feed_url,omitempty"` + IconUrl *string `json:"icon_url,omitempty"` + InstalledDateTime *string `json:"installed_date_time,omitempty"` + InstallerCommandLineParams *string `json:"installer_command_line_params,omitempty"` + LicenseUrl *string `json:"license_url,omitempty"` + LocalIsLatestVersion *bool `json:"local_is_latest_version,omitempty"` + LocalPath *string `json:"local_path,omitempty"` + ProjectUrl *string `json:"project_url,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublishedDateTime *string `json:"published_date_time,omitempty"` + Summary *string `json:"summary,omitempty"` + Title *string `json:"title,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *SiteExtensionInfoProperties) GetInstalledDateTimeAsTime() (*time.Time, error) { + if o.InstalledDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.InstalledDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetInstalledDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.InstalledDateTime = &formatted +} + +func (o *SiteExtensionInfoProperties) GetPublishedDateTimeAsTime() (*time.Time, error) { + if o.PublishedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PublishedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetPublishedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PublishedDateTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitelimits.go b/resource-manager/web/2024-04-01/webapps/model_sitelimits.go new file mode 100644 index 00000000000..271933cbb7d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitelimits.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitelogsconfig.go b/resource-manager/web/2024-04-01/webapps/model_sitelogsconfig.go new file mode 100644 index 00000000000..91bb4451cde --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitelogsconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfig struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteLogsConfigProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitelogsconfigproperties.go b/resource-manager/web/2024-04-01/webapps/model_sitelogsconfigproperties.go new file mode 100644 index 00000000000..1b853da7ad6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitelogsconfigproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfigProperties struct { + ApplicationLogs *ApplicationLogsConfig `json:"applicationLogs,omitempty"` + DetailedErrorMessages *EnabledConfig `json:"detailedErrorMessages,omitempty"` + FailedRequestsTracing *EnabledConfig `json:"failedRequestsTracing,omitempty"` + HTTPLogs *HTTPLogsConfig `json:"httpLogs,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitemachinekey.go b/resource-manager/web/2024-04-01/webapps/model_sitemachinekey.go new file mode 100644 index 00000000000..c6d65bc957d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitepatchresource.go b/resource-manager/web/2024-04-01/webapps/model_sitepatchresource.go new file mode 100644 index 00000000000..ca1829f5c66 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitepatchresource.go @@ -0,0 +1,17 @@ +package webapps + +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 SitePatchResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitepatchresourceproperties.go b/resource-manager/web/2024-04-01/webapps/model_sitepatchresourceproperties.go new file mode 100644 index 00000000000..77ba3270f28 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitepatchresourceproperties.go @@ -0,0 +1,79 @@ +package webapps + +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 SitePatchResourceProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` +} + +func (o *SitePatchResourceProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SitePatchResourceProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflag.go b/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflag.go new file mode 100644 index 00000000000..fd18d5d39f6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflag.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlag struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePhpErrorLogFlagProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflagproperties.go b/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflagproperties.go new file mode 100644 index 00000000000..4a9465a064b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitephperrorlogflagproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlagProperties struct { + LocalLogErrors *string `json:"localLogErrors,omitempty"` + LocalLogErrorsMaxLength *string `json:"localLogErrorsMaxLength,omitempty"` + MasterLogErrors *string `json:"masterLogErrors,omitempty"` + MasterLogErrorsMaxLength *string `json:"masterLogErrorsMaxLength,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_siteproperties.go b/resource-manager/web/2024-04-01/webapps/model_siteproperties.go new file mode 100644 index 00000000000..3e70c6ad29f --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_siteproperties.go @@ -0,0 +1,93 @@ +package webapps + +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 SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrol.go b/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrol.go new file mode 100644 index 00000000000..8b8a43b83b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrol.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteSourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrolproperties.go b/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrolproperties.go new file mode 100644 index 00000000000..9634590165d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_sitesourcecontrolproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControlProperties struct { + Branch *string `json:"branch,omitempty"` + DeploymentRollbackEnabled *bool `json:"deploymentRollbackEnabled,omitempty"` + GitHubActionConfiguration *GitHubActionConfiguration `json:"gitHubActionConfiguration,omitempty"` + IsGitHubAction *bool `json:"isGitHubAction,omitempty"` + IsManualIntegration *bool `json:"isManualIntegration,omitempty"` + IsMercurial *bool `json:"isMercurial,omitempty"` + RepoURL *string `json:"repoUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slotconfignames.go b/resource-manager/web/2024-04-01/webapps/model_slotconfignames.go new file mode 100644 index 00000000000..34cbe7ce354 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slotconfignames.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNames struct { + AppSettingNames *[]string `json:"appSettingNames,omitempty"` + AzureStorageConfigNames *[]string `json:"azureStorageConfigNames,omitempty"` + ConnectionStringNames *[]string `json:"connectionStringNames,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slotconfignamesresource.go b/resource-manager/web/2024-04-01/webapps/model_slotconfignamesresource.go new file mode 100644 index 00000000000..dea993a310d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slotconfignamesresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNamesResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotConfigNames `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slotdifference.go b/resource-manager/web/2024-04-01/webapps/model_slotdifference.go new file mode 100644 index 00000000000..433c86817c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slotdifference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotDifferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slotdifferenceproperties.go b/resource-manager/web/2024-04-01/webapps/model_slotdifferenceproperties.go new file mode 100644 index 00000000000..79f90d274fa --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slotdifferenceproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifferenceProperties struct { + Description *string `json:"description,omitempty"` + DiffRule *string `json:"diffRule,omitempty"` + Level *string `json:"level,omitempty"` + SettingName *string `json:"settingName,omitempty"` + SettingType *string `json:"settingType,omitempty"` + ValueInCurrentSlot *string `json:"valueInCurrentSlot,omitempty"` + ValueInTargetSlot *string `json:"valueInTargetSlot,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slotswapstatus.go b/resource-manager/web/2024-04-01/webapps/model_slotswapstatus.go new file mode 100644 index 00000000000..c9eb5b7eeff --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package webapps + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-04-01/webapps/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..6d2bb3b5050 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_snapshot.go b/resource-manager/web/2024-04-01/webapps/model_snapshot.go new file mode 100644 index 00000000000..6a113202c94 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_snapshot.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_snapshotproperties.go b/resource-manager/web/2024-04-01/webapps/model_snapshotproperties.go new file mode 100644 index 00000000000..e6cf11407ff --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_snapshotrecoverysource.go b/resource-manager/web/2024-04-01/webapps/model_snapshotrecoverysource.go new file mode 100644 index 00000000000..5a9d31cacbb --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_snapshotrecoverysource.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRecoverySource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequest.go b/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequest.go new file mode 100644 index 00000000000..f3b15067bd6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequestproperties.go b/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequestproperties.go new file mode 100644 index 00000000000..43d7139eb35 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_snapshotrestorerequestproperties.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequestProperties struct { + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + Overwrite bool `json:"overwrite"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + RecoverySource *SnapshotRecoverySource `json:"recoverySource,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-04-01/webapps/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..38028980ea1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-04-01/webapps/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..399920aec5a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptions.go b/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptions.go new file mode 100644 index 00000000000..45da1f0d070 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptions.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptions struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationOptionsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptionsproperties.go b/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptionsproperties.go new file mode 100644 index 00000000000..102ddb713f6 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_storagemigrationoptionsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptionsProperties struct { + AzurefilesConnectionString string `json:"azurefilesConnectionString"` + AzurefilesShare string `json:"azurefilesShare"` + BlockWriteAccessToSite *bool `json:"blockWriteAccessToSite,omitempty"` + SwitchSiteAfterMigration *bool `json:"switchSiteAfterMigration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponse.go b/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponse.go new file mode 100644 index 00000000000..9422d63effd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponse.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponseproperties.go b/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponseproperties.go new file mode 100644 index 00000000000..780c084c664 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_storagemigrationresponseproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponseProperties struct { + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_stringdictionary.go b/resource-manager/web/2024-04-01/webapps/model_stringdictionary.go new file mode 100644 index 00000000000..20fcaaa92b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_stringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetwork.go b/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetwork.go new file mode 100644 index 00000000000..db095809863 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetwork.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetwork struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SwiftVirtualNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetworkproperties.go b/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetworkproperties.go new file mode 100644 index 00000000000..8c1ca0faa38 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_swiftvirtualnetworkproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetworkProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + SwiftSupported *bool `json:"swiftSupported,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_tokenstore.go b/resource-manager/web/2024-04-01/webapps/model_tokenstore.go new file mode 100644 index 00000000000..4668774ac25 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_tokenstore.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenStore struct { + AzureBlobStorage *BlobStorageTokenStore `json:"azureBlobStorage,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FileSystem *FileSystemTokenStore `json:"fileSystem,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistory.go b/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistory.go new file mode 100644 index 00000000000..2eb9852d4b7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredJobHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistoryproperties.go b/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistoryproperties.go new file mode 100644 index 00000000000..37c8ad7df32 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_triggeredjobhistoryproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistoryProperties struct { + Runs *[]TriggeredJobRun `json:"runs,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_triggeredjobrun.go b/resource-manager/web/2024-04-01/webapps/model_triggeredjobrun.go new file mode 100644 index 00000000000..695a8d5a98d --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_triggeredjobrun.go @@ -0,0 +1,48 @@ +package webapps + +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 TriggeredJobRun struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"end_time,omitempty"` + ErrorUrl *string `json:"error_url,omitempty"` + JobName *string `json:"job_name,omitempty"` + OutputUrl *string `json:"output_url,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *TriggeredWebJobStatus `json:"status,omitempty"` + Trigger *string `json:"trigger,omitempty"` + Url *string `json:"url,omitempty"` + WebJobId *string `json:"web_job_id,omitempty"` + WebJobName *string `json:"web_job_name,omitempty"` +} + +func (o *TriggeredJobRun) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *TriggeredJobRun) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/webapps/model_triggeredwebjob.go b/resource-manager/web/2024-04-01/webapps/model_triggeredwebjob.go new file mode 100644 index 00000000000..aab21f2dfae --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_triggeredwebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_triggeredwebjobproperties.go b/resource-manager/web/2024-04-01/webapps/model_triggeredwebjobproperties.go new file mode 100644 index 00000000000..0205e0bc246 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_triggeredwebjobproperties.go @@ -0,0 +1,19 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + HistoryUrl *string `json:"history_url,omitempty"` + LatestRun *TriggeredJobRun `json:"latest_run,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + SchedulerLogsUrl *string `json:"scheduler_logs_url,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_twitter.go b/resource-manager/web/2024-04-01/webapps/model_twitter.go new file mode 100644 index 00000000000..16018b814ad --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_twitter.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Twitter struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *TwitterRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_twitterregistration.go b/resource-manager/web/2024-04-01/webapps/model_twitterregistration.go new file mode 100644 index 00000000000..15d70794ab7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_twitterregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TwitterRegistration struct { + ConsumerKey *string `json:"consumerKey,omitempty"` + ConsumerSecretSettingName *string `json:"consumerSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_user.go b/resource-manager/web/2024-04-01/webapps/model_user.go new file mode 100644 index 00000000000..0be0f9a3507 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_user.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_userproperties.go b/resource-manager/web/2024-04-01/webapps/model_userproperties.go new file mode 100644 index 00000000000..42d228f76de --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_userproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_virtualapplication.go b/resource-manager/web/2024-04-01/webapps/model_virtualapplication.go new file mode 100644 index 00000000000..cd9a20e0a97 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_virtualapplication.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_virtualdirectory.go b/resource-manager/web/2024-04-01/webapps/model_virtualdirectory.go new file mode 100644 index 00000000000..e12dd8d0b49 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetgateway.go b/resource-manager/web/2024-04-01/webapps/model_vnetgateway.go new file mode 100644 index 00000000000..59ce757342b --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetgateway.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetgatewayproperties.go b/resource-manager/web/2024-04-01/webapps/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..e90b78642ee --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetinfo.go b/resource-manager/web/2024-04-01/webapps/model_vnetinfo.go new file mode 100644 index 00000000000..9ef7b52d7de --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetinfo.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetinforesource.go b/resource-manager/web/2024-04-01/webapps/model_vnetinforesource.go new file mode 100644 index 00000000000..6b6193e0fee --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetroute.go b/resource-manager/web/2024-04-01/webapps/model_vnetroute.go new file mode 100644 index 00000000000..58365af2214 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetroute.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_vnetrouteproperties.go b/resource-manager/web/2024-04-01/webapps/model_vnetrouteproperties.go new file mode 100644 index 00000000000..00d288ce7d7 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_volumemount.go b/resource-manager/web/2024-04-01/webapps/model_volumemount.go new file mode 100644 index 00000000000..fd0456dd18e --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_volumemount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + ContainerMountPath string `json:"containerMountPath"` + Data *string `json:"data,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + VolumeSubPath string `json:"volumeSubPath"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_webjob.go b/resource-manager/web/2024-04-01/webapps/model_webjob.go new file mode 100644 index 00000000000..6dfbc3f0a58 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_webjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_webjobproperties.go b/resource-manager/web/2024-04-01/webapps/model_webjobproperties.go new file mode 100644 index 00000000000..b67f1af63a0 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_webjobproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatus.go b/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatus.go new file mode 100644 index 00000000000..7cf30ebf35a --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebSiteInstanceStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatusproperties.go b/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatusproperties.go new file mode 100644 index 00000000000..56592442bc4 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_websiteinstancestatusproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatusProperties struct { + ConsoleURL *string `json:"consoleUrl,omitempty"` + Containers *map[string]ContainerInfo `json:"containers,omitempty"` + DetectorURL *string `json:"detectorUrl,omitempty"` + HealthCheckURL *string `json:"healthCheckUrl,omitempty"` + PhysicalZone *string `json:"physicalZone,omitempty"` + State *SiteRuntimeState `json:"state,omitempty"` + StatusURL *string `json:"statusUrl,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_workflowartifacts.go b/resource-manager/web/2024-04-01/webapps/model_workflowartifacts.go new file mode 100644 index 00000000000..52498481889 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_workflowartifacts.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowArtifacts struct { + AppSettings *interface{} `json:"appSettings,omitempty"` + Files *map[string]interface{} `json:"files,omitempty"` + FilesToDelete *[]string `json:"filesToDelete,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_workflowenvelope.go b/resource-manager/web/2024-04-01/webapps/model_workflowenvelope.go new file mode 100644 index 00000000000..6f4ea5ce596 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_workflowenvelope.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_workflowenvelopeproperties.go b/resource-manager/web/2024-04-01/webapps/model_workflowenvelopeproperties.go new file mode 100644 index 00000000000..a14bffda962 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_workflowenvelopeproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelopeProperties struct { + Files *map[string]interface{} `json:"files,omitempty"` + FlowState *WorkflowState `json:"flowState,omitempty"` + Health *WorkflowHealth `json:"health,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/webapps/model_workflowhealth.go b/resource-manager/web/2024-04-01/webapps/model_workflowhealth.go new file mode 100644 index 00000000000..f9ec376ba05 --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/model_workflowhealth.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowHealth struct { + Error *ErrorEntity `json:"error,omitempty"` + State WorkflowHealthState `json:"state"` +} diff --git a/resource-manager/web/2024-04-01/webapps/predicates.go b/resource-manager/web/2024-04-01/webapps/predicates.go new file mode 100644 index 00000000000..3961c0e0cfd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/predicates.go @@ -0,0 +1,788 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApiKVReferenceOperationPredicate) Matches(input ApiKVReference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type BackupItemOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BackupItemOperationPredicate) Matches(input BackupItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ContinuousWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ContinuousWebJobOperationPredicate) Matches(input ContinuousWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmDeploymentStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmDeploymentStatusOperationPredicate) Matches(input CsmDeploymentStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmPublishingCredentialsPoliciesEntityOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmPublishingCredentialsPoliciesEntityOperationPredicate) Matches(input CsmPublishingCredentialsPoliciesEntity) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type DeploymentOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeploymentOperationPredicate) Matches(input Deployment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type FunctionEnvelopeOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p FunctionEnvelopeOperationPredicate) Matches(input FunctionEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type HostNameBindingOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HostNameBindingOperationPredicate) Matches(input HostNameBinding) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PerfMonResponseOperationPredicate struct { + Code *string + Message *string +} + +func (p PerfMonResponseOperationPredicate) Matches(input PerfMonResponse) bool { + + if p.Code != nil && (input.Code == nil || *p.Code != *input.Code) { + return false + } + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + return true +} + +type ProcessInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessInfoOperationPredicate) Matches(input ProcessInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ProcessModuleInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessModuleInfoOperationPredicate) Matches(input ProcessModuleInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ProcessThreadInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessThreadInfoOperationPredicate) Matches(input ProcessThreadInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PublicCertificateOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PublicCertificateOperationPredicate) Matches(input PublicCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteConfigResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigResourceOperationPredicate) Matches(input SiteConfigResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteConfigurationSnapshotInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigurationSnapshotInfoOperationPredicate) Matches(input SiteConfigurationSnapshotInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteContainerOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteContainerOperationPredicate) Matches(input SiteContainer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteExtensionInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteExtensionInfoOperationPredicate) Matches(input SiteExtensionInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SlotDifferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SlotDifferenceOperationPredicate) Matches(input SlotDifference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SnapshotOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SnapshotOperationPredicate) Matches(input Snapshot) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type TriggeredJobHistoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredJobHistoryOperationPredicate) Matches(input TriggeredJobHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type TriggeredWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredWebJobOperationPredicate) Matches(input TriggeredWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebJobOperationPredicate) Matches(input WebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WebSiteInstanceStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebSiteInstanceStatusOperationPredicate) Matches(input WebSiteInstanceStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WorkflowEnvelopeOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WorkflowEnvelopeOperationPredicate) Matches(input WorkflowEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.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/web/2024-04-01/webapps/version.go b/resource-manager/web/2024-04-01/webapps/version.go new file mode 100644 index 00000000000..12e5562b0bd --- /dev/null +++ b/resource-manager/web/2024-04-01/webapps/version.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapps/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/README.md b/resource-manager/web/2024-04-01/workflowrunactions/README.md new file mode 100644 index 00000000000..45dcea0c205 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/README.md @@ -0,0 +1,186 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowrunactions` Documentation + +The `workflowrunactions` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflowrunactions" +``` + + +### Client Initialization + +```go +client := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName") + +read, err := client.CopeRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.CopeRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.CopeRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.Get` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +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: `WorkflowRunActionsClient.List` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +// alternatively `client.List(ctx, id, workflowrunactions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowrunactions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.ListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.ListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.ListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +read, err := client.WorkflowRunActionRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.WorkflowRunActionRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +// alternatively `client.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName") + +read, err := client.WorkflowRunActionRepetitionsRequestHistoriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +// alternatively `client.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/workflowrunactions/client.go b/resource-manager/web/2024-04-01/workflowrunactions/client.go new file mode 100644 index 00000000000..463cc06a5f9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/client.go @@ -0,0 +1,26 @@ +package workflowrunactions + +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 WorkflowRunActionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunActionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunActionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowrunactions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunActionsClient: %+v", err) + } + + return &WorkflowRunActionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/constants.go b/resource-manager/web/2024-04-01/workflowrunactions/constants.go new file mode 100644 index 00000000000..98029f459ce --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/constants.go @@ -0,0 +1,84 @@ +package workflowrunactions + +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 WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_action.go b/resource-manager/web/2024-04-01/workflowrunactions/id_action.go new file mode 100644 index 00000000000..d8931531676 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_action.go @@ -0,0 +1,163 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ActionId{}) +} + +var _ resourceids.ResourceId = &ActionId{} + +// ActionId is a struct representing the Resource ID for a Action +type ActionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string +} + +// NewActionID returns a new ActionId struct +func NewActionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string) ActionId { + return ActionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + } +} + +// ParseActionID parses 'input' into a ActionId +func ParseActionID(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseActionIDInsensitively parses 'input' case-insensitively into a ActionId +// note: this method should only be used for API response data and not user input +func ParseActionIDInsensitively(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ActionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + return nil +} + +// ValidateActionID checks that 'input' can be parsed as a Action ID +func ValidateActionID(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 := ParseActionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Action ID +func (id ActionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Action ID +func (id ActionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + } +} + +// String returns a human-readable description of this Action ID +func (id ActionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + } + return fmt.Sprintf("Action (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_action_test.go b/resource-manager/web/2024-04-01/workflowrunactions/id_action_test.go new file mode 100644 index 00000000000..1a7cdb61b0c --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_action_test.go @@ -0,0 +1,507 @@ +package workflowrunactions + +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 = &ActionId{} + +func TestNewActionID(t *testing.T) { + id := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } +} + +func TestFormatActionID(t *testing.T) { + actual := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseActionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestParseActionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestSegmentsForActionId(t *testing.T) { + segments := ActionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ActionId 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/web/2024-04-01/workflowrunactions/id_repetition.go b/resource-manager/web/2024-04-01/workflowrunactions/id_repetition.go new file mode 100644 index 00000000000..eea587301e1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_repetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RepetitionId{}) +} + +var _ resourceids.ResourceId = &RepetitionId{} + +// RepetitionId is a struct representing the Resource ID for a Repetition +type RepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string +} + +// NewRepetitionID returns a new RepetitionId struct +func NewRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string) RepetitionId { + return RepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + } +} + +// ParseRepetitionID parses 'input' into a RepetitionId +func ParseRepetitionID(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRepetitionIDInsensitively parses 'input' case-insensitively into a RepetitionId +// note: this method should only be used for API response data and not user input +func ParseRepetitionIDInsensitively(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RepetitionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + return nil +} + +// ValidateRepetitionID checks that 'input' can be parsed as a Repetition ID +func ValidateRepetitionID(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 := ParseRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Repetition ID +func (id RepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Repetition ID +func (id RepetitionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionName"), + } +} + +// String returns a human-readable description of this Repetition ID +func (id RepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + } + return fmt.Sprintf("Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_repetition_test.go b/resource-manager/web/2024-04-01/workflowrunactions/id_repetition_test.go new file mode 100644 index 00000000000..9b2f3157fe9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_repetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +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 = &RepetitionId{} + +func TestNewRepetitionID(t *testing.T) { + id := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.RepetitionName != "repetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionName") + } +} + +func TestFormatRepetitionID(t *testing.T) { + actual := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestParseRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + RepetitionName: "rEpEtItIoNnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestSegmentsForRepetitionId(t *testing.T) { + segments := RepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RepetitionId 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/web/2024-04-01/workflowrunactions/id_requesthistory.go b/resource-manager/web/2024-04-01/workflowrunactions/id_requesthistory.go new file mode 100644 index 00000000000..d15a9523fb5 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_requesthistory.go @@ -0,0 +1,181 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RequestHistoryId{}) +} + +var _ resourceids.ResourceId = &RequestHistoryId{} + +// RequestHistoryId is a struct representing the Resource ID for a Request History +type RequestHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string + RequestHistoryName string +} + +// NewRequestHistoryID returns a new RequestHistoryId struct +func NewRequestHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string, requestHistoryName string) RequestHistoryId { + return RequestHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + RequestHistoryName: requestHistoryName, + } +} + +// ParseRequestHistoryID parses 'input' into a RequestHistoryId +func ParseRequestHistoryID(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRequestHistoryIDInsensitively parses 'input' case-insensitively into a RequestHistoryId +// note: this method should only be used for API response data and not user input +func ParseRequestHistoryIDInsensitively(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RequestHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + if id.RequestHistoryName, ok = input.Parsed["requestHistoryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "requestHistoryName", input) + } + + return nil +} + +// ValidateRequestHistoryID checks that 'input' can be parsed as a Request History ID +func ValidateRequestHistoryID(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 := ParseRequestHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Request History ID +func (id RequestHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s/requestHistories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName, id.RequestHistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Request History ID +func (id RequestHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionName"), + resourceids.StaticSegment("staticRequestHistories", "requestHistories", "requestHistories"), + resourceids.UserSpecifiedSegment("requestHistoryName", "requestHistoryName"), + } +} + +// String returns a human-readable description of this Request History ID +func (id RequestHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + fmt.Sprintf("Request History Name: %q", id.RequestHistoryName), + } + return fmt.Sprintf("Request History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_requesthistory_test.go b/resource-manager/web/2024-04-01/workflowrunactions/id_requesthistory_test.go new file mode 100644 index 00000000000..170be7c8e38 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_requesthistory_test.go @@ -0,0 +1,597 @@ +package workflowrunactions + +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 = &RequestHistoryId{} + +func TestNewRequestHistoryID(t *testing.T) { + id := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.RepetitionName != "repetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionName") + } + + if id.RequestHistoryName != "requestHistoryName" { + t.Fatalf("Expected %q but got %q for Segment 'RequestHistoryName'", id.RequestHistoryName, "requestHistoryName") + } +} + +func TestFormatRequestHistoryID(t *testing.T) { + actual := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRequestHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + RequestHistoryName: "requestHistoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestParseRequestHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + RequestHistoryName: "requestHistoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS/rEqUeStHiStOrYnAmE", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + RepetitionName: "rEpEtItIoNnAmE", + RequestHistoryName: "rEqUeStHiStOrYnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS/rEqUeStHiStOrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestSegmentsForRequestHistoryId(t *testing.T) { + segments := RequestHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RequestHistoryId 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/web/2024-04-01/workflowrunactions/id_run.go b/resource-manager/web/2024-04-01/workflowrunactions/id_run.go new file mode 100644 index 00000000000..50398640cd1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_run.go @@ -0,0 +1,154 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(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 := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_run_test.go b/resource-manager/web/2024-04-01/workflowrunactions/id_run_test.go new file mode 100644 index 00000000000..5b5fc911ae0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_run_test.go @@ -0,0 +1,462 @@ +package workflowrunactions + +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 = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId 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/web/2024-04-01/workflowrunactions/id_scoperepetition.go b/resource-manager/web/2024-04-01/workflowrunactions/id_scoperepetition.go new file mode 100644 index 00000000000..0e6e953b99e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_scoperepetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ScopeRepetitionId{}) +} + +var _ resourceids.ResourceId = &ScopeRepetitionId{} + +// ScopeRepetitionId is a struct representing the Resource ID for a Scope Repetition +type ScopeRepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + ScopeRepetitionName string +} + +// NewScopeRepetitionID returns a new ScopeRepetitionId struct +func NewScopeRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, scopeRepetitionName string) ScopeRepetitionId { + return ScopeRepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + ScopeRepetitionName: scopeRepetitionName, + } +} + +// ParseScopeRepetitionID parses 'input' into a ScopeRepetitionId +func ParseScopeRepetitionID(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopeRepetitionIDInsensitively parses 'input' case-insensitively into a ScopeRepetitionId +// note: this method should only be used for API response data and not user input +func ParseScopeRepetitionIDInsensitively(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopeRepetitionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.ScopeRepetitionName, ok = input.Parsed["scopeRepetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scopeRepetitionName", input) + } + + return nil +} + +// ValidateScopeRepetitionID checks that 'input' can be parsed as a Scope Repetition ID +func ValidateScopeRepetitionID(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 := ParseScopeRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scope Repetition ID +func (id ScopeRepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/scopeRepetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.ScopeRepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scope Repetition ID +func (id ScopeRepetitionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticScopeRepetitions", "scopeRepetitions", "scopeRepetitions"), + resourceids.UserSpecifiedSegment("scopeRepetitionName", "scopeRepetitionName"), + } +} + +// String returns a human-readable description of this Scope Repetition ID +func (id ScopeRepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Scope Repetition Name: %q", id.ScopeRepetitionName), + } + return fmt.Sprintf("Scope Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/id_scoperepetition_test.go b/resource-manager/web/2024-04-01/workflowrunactions/id_scoperepetition_test.go new file mode 100644 index 00000000000..0b1db9c0160 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/id_scoperepetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +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 = &ScopeRepetitionId{} + +func TestNewScopeRepetitionID(t *testing.T) { + id := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.ScopeRepetitionName != "scopeRepetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'ScopeRepetitionName'", id.ScopeRepetitionName, "scopeRepetitionName") + } +} + +func TestFormatScopeRepetitionID(t *testing.T) { + actual := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopeRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + ScopeRepetitionName: "scopeRepetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestParseScopeRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + ScopeRepetitionName: "scopeRepetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnNaMe", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + ScopeRepetitionName: "sCoPeRePeTiTiOnNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestSegmentsForScopeRepetitionId(t *testing.T) { + segments := ScopeRepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopeRepetitionId 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/web/2024-04-01/workflowrunactions/method_coperepetitionsget.go b/resource-manager/web/2024-04-01/workflowrunactions/method_coperepetitionsget.go new file mode 100644 index 00000000000..f860d0462b4 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_coperepetitionsget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +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 CopeRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsGet ... +func (c WorkflowRunActionsClient) CopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (result CopeRepetitionsGetOperationResponse, 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 + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_coperepetitionslist.go b/resource-manager/web/2024-04-01/workflowrunactions/method_coperepetitionslist.go new file mode 100644 index 00000000000..8e3b1832ac8 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_coperepetitionslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 CopeRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CopeRepetitionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CopeRepetitionsList ... +func (c WorkflowRunActionsClient) CopeRepetitionsList(ctx context.Context, id ActionId) (result CopeRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CopeRepetitionsListCustomPager{}, + Path: fmt.Sprintf("%s/scopeRepetitions", 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 *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CopeRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) CopeRepetitionsListComplete(ctx context.Context, id ActionId) (CopeRepetitionsListCompleteResult, error) { + return c.CopeRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// CopeRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) CopeRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result CopeRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.CopeRepetitionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = CopeRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_get.go b/resource-manager/web/2024-04-01/workflowrunactions/method_get.go new file mode 100644 index 00000000000..c86b02f4ca2 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_get.go @@ -0,0 +1,53 @@ +package workflowrunactions + +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 *WorkflowRunAction +} + +// Get ... +func (c WorkflowRunActionsClient) Get(ctx context.Context, id ActionId) (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 + } + + var model WorkflowRunAction + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_list.go b/resource-manager/web/2024-04-01/workflowrunactions/method_list.go new file mode 100644 index 00000000000..084239bb128 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_list.go @@ -0,0 +1,138 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunAction +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunAction +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowRunActionsClient) List(ctx context.Context, id RunId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/actions", 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 *[]WorkflowRunAction `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 WorkflowRunActionsClient) ListComplete(ctx context.Context, id RunId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunActionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RunId, options ListOperationOptions, predicate WorkflowRunActionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRunAction, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/workflowrunactions/method_listexpressiontraces.go b/resource-manager/web/2024-04-01/workflowrunactions/method_listexpressiontraces.go new file mode 100644 index 00000000000..07ca3a3e829 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_listexpressiontraces.go @@ -0,0 +1,98 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 ListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type ListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +type ListExpressionTracesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListExpressionTracesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListExpressionTraces ... +func (c WorkflowRunActionsClient) ListExpressionTraces(ctx context.Context, id ActionId) (result ListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListExpressionTracesCustomPager{}, + Path: fmt.Sprintf("%s/listExpressionTraces", 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 *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListExpressionTracesComplete(ctx context.Context, id ActionId) (result ListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.ListExpressionTraces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsget.go b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsget.go new file mode 100644 index 00000000000..eb39d17169e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsGetOperationResponse, 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 + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslist.go b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslist.go new file mode 100644 index 00000000000..6b6fadac68b --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &WorkflowRunActionRepetitionsListCustomPager{}, + Path: fmt.Sprintf("%s/repetitions", 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 *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListComplete(ctx context.Context, id ActionId) (WorkflowRunActionRepetitionsListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result WorkflowRunActionRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.WorkflowRunActionRepetitionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = WorkflowRunActionRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go new file mode 100644 index 00000000000..a3f212a0cfe --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go @@ -0,0 +1,98 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsListExpressionTracesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsListExpressionTraces ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &WorkflowRunActionRepetitionsListExpressionTracesCustomPager{}, + Path: fmt.Sprintf("%s/listExpressionTraces", 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 *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = WorkflowRunActionRepetitionsListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go new file mode 100644 index 00000000000..67800134834 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, 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 + } + + var model RequestHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go new file mode 100644 index 00000000000..c1d6265df03 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsRequestHistoriesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsRequestHistoriesList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &WorkflowRunActionRepetitionsRequestHistoriesListCustomPager{}, + Path: fmt.Sprintf("%s/requestHistories", 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 *[]RequestHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsRequestHistoriesListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx context.Context, id RepetitionId) (WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx, id, RequestHistoryOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx context.Context, id RepetitionId, predicate RequestHistoryOperationPredicate) (result WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, err error) { + items := make([]RequestHistory, 0) + + resp, err := c.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_contenthash.go b/resource-manager/web/2024-04-01/workflowrunactions/model_contenthash.go new file mode 100644 index 00000000000..3c0011433bc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_contentlink.go b/resource-manager/web/2024-04-01/workflowrunactions/model_contentlink.go new file mode 100644 index 00000000000..bd3dc0e8dbc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_errorproperties.go b/resource-manager/web/2024-04-01/workflowrunactions/model_errorproperties.go new file mode 100644 index 00000000000..0c17755bd62 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_errorproperties.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorProperties struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_errorresponse.go b/resource-manager/web/2024-04-01/workflowrunactions/model_errorresponse.go new file mode 100644 index 00000000000..9856e5afdda --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_errorresponse.go @@ -0,0 +1,8 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorResponse struct { + Error *ErrorProperties `json:"error,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_repetitionindex.go b/resource-manager/web/2024-04-01/workflowrunactions/model_repetitionindex.go new file mode 100644 index 00000000000..ba809fd0741 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_repetitionindex.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepetitionIndex struct { + ItemIndex int64 `json:"itemIndex"` + ScopeName *string `json:"scopeName,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_request.go b/resource-manager/web/2024-04-01/workflowrunactions/model_request.go new file mode 100644 index 00000000000..1ced5675ea2 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_request.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Request struct { + Headers *interface{} `json:"headers,omitempty"` + Method *string `json:"method,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistory.go b/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistory.go new file mode 100644 index 00000000000..61e48b714f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistory.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistory struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RequestHistoryProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistoryproperties.go b/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistoryproperties.go new file mode 100644 index 00000000000..86fd91ff9e0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_requesthistoryproperties.go @@ -0,0 +1,41 @@ +package workflowrunactions + +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 RequestHistoryProperties struct { + EndTime *string `json:"endTime,omitempty"` + Request *Request `json:"request,omitempty"` + Response *Response `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RequestHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RequestHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_response.go b/resource-manager/web/2024-04-01/workflowrunactions/model_response.go new file mode 100644 index 00000000000..2697b1a5aab --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_response.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Response struct { + BodyLink *ContentLink `json:"bodyLink,omitempty"` + Headers *interface{} `json:"headers,omitempty"` + StatusCode *int64 `json:"statusCode,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_retryhistory.go b/resource-manager/web/2024-04-01/workflowrunactions/model_retryhistory.go new file mode 100644 index 00000000000..372ab23d01f --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_retryhistory.go @@ -0,0 +1,43 @@ +package workflowrunactions + +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 RetryHistory struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Code *string `json:"code,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorResponse `json:"error,omitempty"` + ServiceRequestId *string `json:"serviceRequestId,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RetryHistory) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RetryHistory) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_runactioncorrelation.go b/resource-manager/web/2024-04-01/workflowrunactions/model_runactioncorrelation.go new file mode 100644 index 00000000000..dc7976ccc37 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_runactioncorrelation.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunActionCorrelation struct { + ActionTrackingId *string `json:"actionTrackingId,omitempty"` + ClientKeywords *[]string `json:"clientKeywords,omitempty"` + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunaction.go b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunaction.go new file mode 100644 index 00000000000..443cf266c76 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunaction.go @@ -0,0 +1,11 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunAction struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunActionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionproperties.go b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionproperties.go new file mode 100644 index 00000000000..515fd157766 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionproperties.go @@ -0,0 +1,48 @@ +package workflowrunactions + +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 WorkflowRunActionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go new file mode 100644 index 00000000000..6705564dcf3 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionDefinition struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkflowRunActionRepetitionProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go new file mode 100644 index 00000000000..759c33c6009 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go @@ -0,0 +1,52 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + IterationCount *int64 `json:"iterationCount,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RepetitionIndexes *[]RepetitionIndex `json:"repetitionIndexes,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionRepetitionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionRepetitionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowrunactions/predicates.go b/resource-manager/web/2024-04-01/workflowrunactions/predicates.go new file mode 100644 index 00000000000..fa466cf2c8e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/predicates.go @@ -0,0 +1,83 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistoryOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RequestHistoryOperationPredicate) Matches(input RequestHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.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 +} + +type WorkflowRunActionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunActionOperationPredicate) Matches(input WorkflowRunAction) 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 +} + +type WorkflowRunActionRepetitionDefinitionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowRunActionRepetitionDefinitionOperationPredicate) Matches(input WorkflowRunActionRepetitionDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.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/web/2024-04-01/workflowrunactions/version.go b/resource-manager/web/2024-04-01/workflowrunactions/version.go new file mode 100644 index 00000000000..4a5fc99a355 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowrunactions/version.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowrunactions/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflowruns/README.md b/resource-manager/web/2024-04-01/workflowruns/README.md new file mode 100644 index 00000000000..899af342187 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowruns` Documentation + +The `workflowruns` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflowruns" +``` + + +### Client Initialization + +```go +client := workflowruns.NewWorkflowRunsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunsClient.Cancel` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +read, err := client.Cancel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunsClient.Get` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +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: `WorkflowRunsClient.List` + +```go +ctx := context.TODO() +id := workflowruns.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowruns.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowruns.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/workflowruns/client.go b/resource-manager/web/2024-04-01/workflowruns/client.go new file mode 100644 index 00000000000..73a34bf9d60 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/client.go @@ -0,0 +1,26 @@ +package workflowruns + +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 WorkflowRunsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowruns", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunsClient: %+v", err) + } + + return &WorkflowRunsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflowruns/constants.go b/resource-manager/web/2024-04-01/workflowruns/constants.go new file mode 100644 index 00000000000..35a87b003f0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/constants.go @@ -0,0 +1,146 @@ +package workflowruns + +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 ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow.go b/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow.go new file mode 100644 index 00000000000..b87857c4e6f --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow_test.go b/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow_test.go new file mode 100644 index 00000000000..5895776d52c --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowruns + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2024-04-01/workflowruns/id_run.go b/resource-manager/web/2024-04-01/workflowruns/id_run.go new file mode 100644 index 00000000000..968133f5c51 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/id_run.go @@ -0,0 +1,154 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(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 := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowruns/id_run_test.go b/resource-manager/web/2024-04-01/workflowruns/id_run_test.go new file mode 100644 index 00000000000..abacc74a502 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/id_run_test.go @@ -0,0 +1,462 @@ +package workflowruns + +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 = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId 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/web/2024-04-01/workflowruns/method_cancel.go b/resource-manager/web/2024-04-01/workflowruns/method_cancel.go new file mode 100644 index 00000000000..bb4d8b5ae55 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/method_cancel.go @@ -0,0 +1,47 @@ +package workflowruns + +import ( + "context" + "fmt" + "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 CancelOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Cancel ... +func (c WorkflowRunsClient) Cancel(ctx context.Context, id RunId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowruns/method_get.go b/resource-manager/web/2024-04-01/workflowruns/method_get.go new file mode 100644 index 00000000000..17d61b2a5b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/method_get.go @@ -0,0 +1,53 @@ +package workflowruns + +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 *WorkflowRun +} + +// Get ... +func (c WorkflowRunsClient) Get(ctx context.Context, id RunId) (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 + } + + var model WorkflowRun + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowruns/method_list.go b/resource-manager/web/2024-04-01/workflowruns/method_list.go new file mode 100644 index 00000000000..01f6d279698 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/method_list.go @@ -0,0 +1,138 @@ +package workflowruns + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRun +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRun +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowRunsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/runs", 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 *[]WorkflowRun `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 WorkflowRunsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowRunOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRun, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/workflowruns/model_contenthash.go b/resource-manager/web/2024-04-01/workflowruns/model_contenthash.go new file mode 100644 index 00000000000..88622a95a71 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_contentlink.go b/resource-manager/web/2024-04-01/workflowruns/model_contentlink.go new file mode 100644 index 00000000000..c373bce184c --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_correlation.go b/resource-manager/web/2024-04-01/workflowruns/model_correlation.go new file mode 100644 index 00000000000..39ab7e52bc4 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_correlation.go @@ -0,0 +1,8 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_resourcereference.go b/resource-manager/web/2024-04-01/workflowruns/model_resourcereference.go new file mode 100644 index 00000000000..b3a7c0a9505 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_workflowoutputparameter.go b/resource-manager/web/2024-04-01/workflowruns/model_workflowoutputparameter.go new file mode 100644 index 00000000000..eafad5d773e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_workflowoutputparameter.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowOutputParameter struct { + Description *string `json:"description,omitempty"` + Error *interface{} `json:"error,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_workflowrun.go b/resource-manager/web/2024-04-01/workflowruns/model_workflowrun.go new file mode 100644 index 00000000000..10487050a8b --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_workflowrun.go @@ -0,0 +1,11 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRun struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_workflowrunproperties.go b/resource-manager/web/2024-04-01/workflowruns/model_workflowrunproperties.go new file mode 100644 index 00000000000..65670fb8d3a --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_workflowrunproperties.go @@ -0,0 +1,61 @@ +package workflowruns + +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 WorkflowRunProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Outputs *map[string]WorkflowOutputParameter `json:"outputs,omitempty"` + Response *WorkflowRunTrigger `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Trigger *WorkflowRunTrigger `json:"trigger,omitempty"` + WaitEndTime *string `json:"waitEndTime,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowRunProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *WorkflowRunProperties) GetWaitEndTimeAsTime() (*time.Time, error) { + if o.WaitEndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.WaitEndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetWaitEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.WaitEndTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowruns/model_workflowruntrigger.go b/resource-manager/web/2024-04-01/workflowruns/model_workflowruntrigger.go new file mode 100644 index 00000000000..64680149cd7 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/model_workflowruntrigger.go @@ -0,0 +1,63 @@ +package workflowruns + +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 WorkflowRunTrigger struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + Name *string `json:"name,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunTrigger) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunTrigger) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowRunTrigger) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowruns/predicates.go b/resource-manager/web/2024-04-01/workflowruns/predicates.go new file mode 100644 index 00000000000..ad76dae5873 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/predicates.go @@ -0,0 +1,27 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunOperationPredicate) Matches(input WorkflowRun) 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/web/2024-04-01/workflowruns/version.go b/resource-manager/web/2024-04-01/workflowruns/version.go new file mode 100644 index 00000000000..9bf83d98ecd --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowruns/version.go @@ -0,0 +1,10 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowruns/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflows/README.md b/resource-manager/web/2024-04-01/workflows/README.md new file mode 100644 index 00000000000..f667fba76d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/README.md @@ -0,0 +1,62 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflows` Documentation + +The `workflows` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflows" +``` + + +### Client Initialization + +```go +client := workflows.NewWorkflowsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowsClient.RegenerateAccessKey` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +payload := workflows.RegenerateActionParameter{ + // ... +} + + +read, err := client.RegenerateAccessKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowsClient.Validate` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +payload := workflows.Workflow{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-04-01/workflows/client.go b/resource-manager/web/2024-04-01/workflows/client.go new file mode 100644 index 00000000000..46648dbfe97 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/client.go @@ -0,0 +1,26 @@ +package workflows + +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 WorkflowsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflows", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowsClient: %+v", err) + } + + return &WorkflowsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflows/constants.go b/resource-manager/web/2024-04-01/workflows/constants.go new file mode 100644 index 00000000000..856f9a16584 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/constants.go @@ -0,0 +1,402 @@ +package workflows + +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 KeyType string + +const ( + KeyTypeNotSpecified KeyType = "NotSpecified" + KeyTypePrimary KeyType = "Primary" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypeNotSpecified), + string(KeyTypePrimary), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "notspecified": KeyTypeNotSpecified, + "primary": KeyTypePrimary, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type Kind string + +const ( + KindStateful Kind = "Stateful" + KindStateless Kind = "Stateless" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindStateful), + string(KindStateless), + } +} + +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "stateful": KindStateful, + "stateless": KindStateless, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflows/id_managementworkflow.go b/resource-manager/web/2024-04-01/workflows/id_managementworkflow.go new file mode 100644 index 00000000000..47ad1eb715b --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflows + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflows/id_managementworkflow_test.go b/resource-manager/web/2024-04-01/workflows/id_managementworkflow_test.go new file mode 100644 index 00000000000..8499136fb32 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflows + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2024-04-01/workflows/method_regenerateaccesskey.go b/resource-manager/web/2024-04-01/workflows/method_regenerateaccesskey.go new file mode 100644 index 00000000000..6d15da4bbd2 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/method_regenerateaccesskey.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "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 RegenerateAccessKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateAccessKey ... +func (c WorkflowsClient) RegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (result RegenerateAccessKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateAccessKey", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflows/method_validate.go b/resource-manager/web/2024-04-01/workflows/method_validate.go new file mode 100644 index 00000000000..14ed7cd27b9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/method_validate.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c WorkflowsClient) Validate(ctx context.Context, id ManagementWorkflowId, input Workflow) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..e110c491fc2 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..e14581b5ddc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_flowendpoints.go b/resource-manager/web/2024-04-01/workflows/model_flowendpoints.go new file mode 100644 index 00000000000..ab677222e7a --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_flowendpointsconfiguration.go b/resource-manager/web/2024-04-01/workflows/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..19393db48ab --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_ipaddress.go b/resource-manager/web/2024-04-01/workflows/model_ipaddress.go new file mode 100644 index 00000000000..0d10e34c4f8 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_ipaddressrange.go b/resource-manager/web/2024-04-01/workflows/model_ipaddressrange.go new file mode 100644 index 00000000000..347495131a8 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicies.go b/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..a4b8fac5970 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicy.go b/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..cf129596719 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_openauthenticationpolicyclaim.go b/resource-manager/web/2024-04-01/workflows/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..3ab50a9ca9b --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_regenerateactionparameter.go b/resource-manager/web/2024-04-01/workflows/model_regenerateactionparameter.go new file mode 100644 index 00000000000..a01c112c1c1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_regenerateactionparameter.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateActionParameter struct { + KeyType *KeyType `json:"keyType,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_resourcereference.go b/resource-manager/web/2024-04-01/workflows/model_resourcereference.go new file mode 100644 index 00000000000..8541ecad863 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_workflow.go b/resource-manager/web/2024-04-01/workflows/model_workflow.go new file mode 100644 index 00000000000..7b9bb73f9b5 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_workflow.go @@ -0,0 +1,18 @@ +package workflows + +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 Workflow struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_workflowparameter.go b/resource-manager/web/2024-04-01/workflows/model_workflowparameter.go new file mode 100644 index 00000000000..c79cf198562 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/model_workflowproperties.go b/resource-manager/web/2024-04-01/workflows/model_workflowproperties.go new file mode 100644 index 00000000000..0dd6da80483 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_workflowproperties.go @@ -0,0 +1,51 @@ +package workflows + +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 WorkflowProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + IntegrationServiceEnvironment *ResourceReference `json:"integrationServiceEnvironment,omitempty"` + Kind *Kind `json:"kind,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflows/model_workflowsku.go b/resource-manager/web/2024-04-01/workflows/model_workflowsku.go new file mode 100644 index 00000000000..64591de779f --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflows/version.go b/resource-manager/web/2024-04-01/workflows/version.go new file mode 100644 index 00000000000..0a1b06977bf --- /dev/null +++ b/resource-manager/web/2024-04-01/workflows/version.go @@ -0,0 +1,10 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflows/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/README.md b/resource-manager/web/2024-04-01/workflowtriggerhistories/README.md new file mode 100644 index 00000000000..e51f5e970d0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowtriggerhistories` Documentation + +The `workflowtriggerhistories` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflowtriggerhistories" +``` + + +### Client Initialization + +```go +client := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + +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: `WorkflowTriggerHistoriesClient.List` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +// alternatively `client.List(ctx, id, workflowtriggerhistories.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggerhistories.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Resubmit` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + +if err := client.ResubmitThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/client.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/client.go new file mode 100644 index 00000000000..e1a3815134e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/client.go @@ -0,0 +1,26 @@ +package workflowtriggerhistories + +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 WorkflowTriggerHistoriesClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggerHistoriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowtriggerhistories", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggerHistoriesClient: %+v", err) + } + + return &WorkflowTriggerHistoriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/constants.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/constants.go new file mode 100644 index 00000000000..9ccf7819b12 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/constants.go @@ -0,0 +1,84 @@ +package workflowtriggerhistories + +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 WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger.go new file mode 100644 index 00000000000..185a7964307 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(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 := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger_test.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger_test.go new file mode 100644 index 00000000000..a7e902f354d --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggerhistories + +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 = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId 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/web/2024-04-01/workflowtriggerhistories/id_triggerhistory.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_triggerhistory.go new file mode 100644 index 00000000000..248b48c2216 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_triggerhistory.go @@ -0,0 +1,163 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TriggerHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggerHistoryId{} + +// TriggerHistoryId is a struct representing the Resource ID for a Trigger History +type TriggerHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string + HistoryName string +} + +// NewTriggerHistoryID returns a new TriggerHistoryId struct +func NewTriggerHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string, historyName string) TriggerHistoryId { + return TriggerHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + HistoryName: historyName, + } +} + +// ParseTriggerHistoryID parses 'input' into a TriggerHistoryId +func ParseTriggerHistoryID(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerHistoryIDInsensitively parses 'input' case-insensitively into a TriggerHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggerHistoryIDInsensitively(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggerHistoryID checks that 'input' can be parsed as a Trigger History ID +func ValidateTriggerHistoryID(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 := ParseTriggerHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger History ID +func (id TriggerHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s/histories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger History ID +func (id TriggerHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + resourceids.StaticSegment("staticHistories", "histories", "histories"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this Trigger History ID +func (id TriggerHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Trigger History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/id_triggerhistory_test.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_triggerhistory_test.go new file mode 100644 index 00000000000..9acaaf52faa --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/id_triggerhistory_test.go @@ -0,0 +1,507 @@ +package workflowtriggerhistories + +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 = &TriggerHistoryId{} + +func TestNewTriggerHistoryID(t *testing.T) { + id := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatTriggerHistoryID(t *testing.T) { + actual := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggerHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs/hIsToRyNaMe", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggerHistoryId(t *testing.T) { + segments := TriggerHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerHistoryId 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/web/2024-04-01/workflowtriggerhistories/method_get.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_get.go new file mode 100644 index 00000000000..25ba7f1b42f --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_get.go @@ -0,0 +1,53 @@ +package workflowtriggerhistories + +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 *WorkflowTriggerHistory +} + +// Get ... +func (c WorkflowTriggerHistoriesClient) Get(ctx context.Context, id TriggerHistoryId) (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 + } + + var model WorkflowTriggerHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/method_list.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_list.go new file mode 100644 index 00000000000..fa03f7faa25 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_list.go @@ -0,0 +1,138 @@ +package workflowtriggerhistories + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTriggerHistory +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTriggerHistory +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowTriggerHistoriesClient) List(ctx context.Context, id TriggerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/histories", 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 *[]WorkflowTriggerHistory `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 WorkflowTriggerHistoriesClient) ListComplete(ctx context.Context, id TriggerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerHistoryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggerHistoriesClient) ListCompleteMatchingPredicate(ctx context.Context, id TriggerId, options ListOperationOptions, predicate WorkflowTriggerHistoryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTriggerHistory, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/workflowtriggerhistories/method_resubmit.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_resubmit.go new file mode 100644 index 00000000000..3608c02e4dc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/method_resubmit.go @@ -0,0 +1,69 @@ +package workflowtriggerhistories + +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 ResubmitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resubmit ... +func (c WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, id TriggerHistoryId) (result ResubmitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resubmit", 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 +} + +// ResubmitThenPoll performs Resubmit then polls until it's completed +func (c WorkflowTriggerHistoriesClient) ResubmitThenPoll(ctx context.Context, id TriggerHistoryId) error { + result, err := c.Resubmit(ctx, id) + if err != nil { + return fmt.Errorf("performing Resubmit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resubmit: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contenthash.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contenthash.go new file mode 100644 index 00000000000..685fd29e9f7 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contentlink.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contentlink.go new file mode 100644 index 00000000000..73c25f49ab8 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_correlation.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_correlation.go new file mode 100644 index 00000000000..e052b2efb68 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_correlation.go @@ -0,0 +1,8 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_resourcereference.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_resourcereference.go new file mode 100644 index 00000000000..ac6b3afa7c3 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistory.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistory.go new file mode 100644 index 00000000000..a1d64aebe3c --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistory.go @@ -0,0 +1,11 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistory struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go new file mode 100644 index 00000000000..42821930e6a --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go @@ -0,0 +1,61 @@ +package workflowtriggerhistories + +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 WorkflowTriggerHistoryProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Fired *bool `json:"fired,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + Run *ResourceReference `json:"run,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowTriggerHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowtriggerhistories/predicates.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/predicates.go new file mode 100644 index 00000000000..20fca9c869f --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistoryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerHistoryOperationPredicate) Matches(input WorkflowTriggerHistory) 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/web/2024-04-01/workflowtriggerhistories/version.go b/resource-manager/web/2024-04-01/workflowtriggerhistories/version.go new file mode 100644 index 00000000000..68f403d2ad5 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggerhistories/version.go @@ -0,0 +1,10 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowtriggerhistories/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/README.md b/resource-manager/web/2024-04-01/workflowtriggers/README.md new file mode 100644 index 00000000000..798261cdecd --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/README.md @@ -0,0 +1,97 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowtriggers` Documentation + +The `workflowtriggers` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflowtriggers" +``` + + +### Client Initialization + +```go +client := workflowtriggers.NewWorkflowTriggersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggersClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +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: `WorkflowTriggersClient.GetSchemaJson` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +read, err := client.GetSchemaJson(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.List` + +```go +ctx := context.TODO() +id := workflowtriggers.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowtriggers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggersClient.ListCallbackURL` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +read, err := client.ListCallbackURL(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.Run` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +if err := client.RunThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-04-01/workflowtriggers/client.go b/resource-manager/web/2024-04-01/workflowtriggers/client.go new file mode 100644 index 00000000000..06e7b704ecf --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/client.go @@ -0,0 +1,26 @@ +package workflowtriggers + +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 WorkflowTriggersClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggersClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowtriggers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggersClient: %+v", err) + } + + return &WorkflowTriggersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/constants.go b/resource-manager/web/2024-04-01/workflowtriggers/constants.go new file mode 100644 index 00000000000..344f92609e4 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/constants.go @@ -0,0 +1,397 @@ +package workflowtriggers + +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 DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type DaysOfWeek string + +const ( + DaysOfWeekFriday DaysOfWeek = "Friday" + DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" + DaysOfWeekTuesday DaysOfWeek = "Tuesday" + DaysOfWeekWednesday DaysOfWeek = "Wednesday" +) + +func PossibleValuesForDaysOfWeek() []string { + return []string{ + string(DaysOfWeekFriday), + string(DaysOfWeekMonday), + string(DaysOfWeekSaturday), + string(DaysOfWeekSunday), + string(DaysOfWeekThursday), + string(DaysOfWeekTuesday), + string(DaysOfWeekWednesday), + } +} + +func (s *DaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaysOfWeek(input string) (*DaysOfWeek, error) { + vals := map[string]DaysOfWeek{ + "friday": DaysOfWeekFriday, + "monday": DaysOfWeekMonday, + "saturday": DaysOfWeekSaturday, + "sunday": DaysOfWeekSunday, + "thursday": DaysOfWeekThursday, + "tuesday": DaysOfWeekTuesday, + "wednesday": DaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaysOfWeek(input) + return &out, nil +} + +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyNotSpecified RecurrenceFrequency = "NotSpecified" + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +func PossibleValuesForRecurrenceFrequency() []string { + return []string{ + string(RecurrenceFrequencyDay), + string(RecurrenceFrequencyHour), + string(RecurrenceFrequencyMinute), + string(RecurrenceFrequencyMonth), + string(RecurrenceFrequencyNotSpecified), + string(RecurrenceFrequencySecond), + string(RecurrenceFrequencyWeek), + string(RecurrenceFrequencyYear), + } +} + +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { + vals := map[string]RecurrenceFrequency{ + "day": RecurrenceFrequencyDay, + "hour": RecurrenceFrequencyHour, + "minute": RecurrenceFrequencyMinute, + "month": RecurrenceFrequencyMonth, + "notspecified": RecurrenceFrequencyNotSpecified, + "second": RecurrenceFrequencySecond, + "week": RecurrenceFrequencyWeek, + "year": RecurrenceFrequencyYear, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecurrenceFrequency(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} + +type WorkflowTriggerProvisioningState string + +const ( + WorkflowTriggerProvisioningStateAccepted WorkflowTriggerProvisioningState = "Accepted" + WorkflowTriggerProvisioningStateCanceled WorkflowTriggerProvisioningState = "Canceled" + WorkflowTriggerProvisioningStateCompleted WorkflowTriggerProvisioningState = "Completed" + WorkflowTriggerProvisioningStateCreated WorkflowTriggerProvisioningState = "Created" + WorkflowTriggerProvisioningStateCreating WorkflowTriggerProvisioningState = "Creating" + WorkflowTriggerProvisioningStateDeleted WorkflowTriggerProvisioningState = "Deleted" + WorkflowTriggerProvisioningStateDeleting WorkflowTriggerProvisioningState = "Deleting" + WorkflowTriggerProvisioningStateFailed WorkflowTriggerProvisioningState = "Failed" + WorkflowTriggerProvisioningStateMoving WorkflowTriggerProvisioningState = "Moving" + WorkflowTriggerProvisioningStateNotSpecified WorkflowTriggerProvisioningState = "NotSpecified" + WorkflowTriggerProvisioningStateReady WorkflowTriggerProvisioningState = "Ready" + WorkflowTriggerProvisioningStateRegistered WorkflowTriggerProvisioningState = "Registered" + WorkflowTriggerProvisioningStateRegistering WorkflowTriggerProvisioningState = "Registering" + WorkflowTriggerProvisioningStateRunning WorkflowTriggerProvisioningState = "Running" + WorkflowTriggerProvisioningStateSucceeded WorkflowTriggerProvisioningState = "Succeeded" + WorkflowTriggerProvisioningStateUnregistered WorkflowTriggerProvisioningState = "Unregistered" + WorkflowTriggerProvisioningStateUnregistering WorkflowTriggerProvisioningState = "Unregistering" + WorkflowTriggerProvisioningStateUpdating WorkflowTriggerProvisioningState = "Updating" +) + +func PossibleValuesForWorkflowTriggerProvisioningState() []string { + return []string{ + string(WorkflowTriggerProvisioningStateAccepted), + string(WorkflowTriggerProvisioningStateCanceled), + string(WorkflowTriggerProvisioningStateCompleted), + string(WorkflowTriggerProvisioningStateCreated), + string(WorkflowTriggerProvisioningStateCreating), + string(WorkflowTriggerProvisioningStateDeleted), + string(WorkflowTriggerProvisioningStateDeleting), + string(WorkflowTriggerProvisioningStateFailed), + string(WorkflowTriggerProvisioningStateMoving), + string(WorkflowTriggerProvisioningStateNotSpecified), + string(WorkflowTriggerProvisioningStateReady), + string(WorkflowTriggerProvisioningStateRegistered), + string(WorkflowTriggerProvisioningStateRegistering), + string(WorkflowTriggerProvisioningStateRunning), + string(WorkflowTriggerProvisioningStateSucceeded), + string(WorkflowTriggerProvisioningStateUnregistered), + string(WorkflowTriggerProvisioningStateUnregistering), + string(WorkflowTriggerProvisioningStateUpdating), + } +} + +func (s *WorkflowTriggerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowTriggerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowTriggerProvisioningState(input string) (*WorkflowTriggerProvisioningState, error) { + vals := map[string]WorkflowTriggerProvisioningState{ + "accepted": WorkflowTriggerProvisioningStateAccepted, + "canceled": WorkflowTriggerProvisioningStateCanceled, + "completed": WorkflowTriggerProvisioningStateCompleted, + "created": WorkflowTriggerProvisioningStateCreated, + "creating": WorkflowTriggerProvisioningStateCreating, + "deleted": WorkflowTriggerProvisioningStateDeleted, + "deleting": WorkflowTriggerProvisioningStateDeleting, + "failed": WorkflowTriggerProvisioningStateFailed, + "moving": WorkflowTriggerProvisioningStateMoving, + "notspecified": WorkflowTriggerProvisioningStateNotSpecified, + "ready": WorkflowTriggerProvisioningStateReady, + "registered": WorkflowTriggerProvisioningStateRegistered, + "registering": WorkflowTriggerProvisioningStateRegistering, + "running": WorkflowTriggerProvisioningStateRunning, + "succeeded": WorkflowTriggerProvisioningStateSucceeded, + "unregistered": WorkflowTriggerProvisioningStateUnregistered, + "unregistering": WorkflowTriggerProvisioningStateUnregistering, + "updating": WorkflowTriggerProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowTriggerProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow.go b/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow.go new file mode 100644 index 00000000000..7f55952af52 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow_test.go b/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow_test.go new file mode 100644 index 00000000000..1ca968f9de0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowtriggers + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2024-04-01/workflowtriggers/id_trigger.go b/resource-manager/web/2024-04-01/workflowtriggers/id_trigger.go new file mode 100644 index 00000000000..3980bdfb0bc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(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 := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/id_trigger_test.go b/resource-manager/web/2024-04-01/workflowtriggers/id_trigger_test.go new file mode 100644 index 00000000000..c101bbec5e7 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggers + +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 = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId 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/web/2024-04-01/workflowtriggers/method_get.go b/resource-manager/web/2024-04-01/workflowtriggers/method_get.go new file mode 100644 index 00000000000..d1bcd504fe2 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/method_get.go @@ -0,0 +1,53 @@ +package workflowtriggers + +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 *WorkflowTrigger +} + +// Get ... +func (c WorkflowTriggersClient) Get(ctx context.Context, id TriggerId) (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 + } + + var model WorkflowTrigger + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/method_getschemajson.go b/resource-manager/web/2024-04-01/workflowtriggers/method_getschemajson.go new file mode 100644 index 00000000000..c26d831b302 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/method_getschemajson.go @@ -0,0 +1,54 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 GetSchemaJsonOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JsonSchema +} + +// GetSchemaJson ... +func (c WorkflowTriggersClient) GetSchemaJson(ctx context.Context, id TriggerId) (result GetSchemaJsonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas/json", 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 + } + + var model JsonSchema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/method_list.go b/resource-manager/web/2024-04-01/workflowtriggers/method_list.go new file mode 100644 index 00000000000..e311d6393de --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/method_list.go @@ -0,0 +1,138 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTrigger +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTrigger +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowTriggersClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/triggers", 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 *[]WorkflowTrigger `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 WorkflowTriggersClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggersClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowTriggerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTrigger, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/workflowtriggers/method_listcallbackurl.go b/resource-manager/web/2024-04-01/workflowtriggers/method_listcallbackurl.go new file mode 100644 index 00000000000..4fa4045250d --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/method_listcallbackurl.go @@ -0,0 +1,54 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 ListCallbackURLOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerCallbackURL +} + +// ListCallbackURL ... +func (c WorkflowTriggersClient) ListCallbackURL(ctx context.Context, id TriggerId) (result ListCallbackURLOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCallbackUrl", 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 + } + + var model WorkflowTriggerCallbackURL + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/method_run.go b/resource-manager/web/2024-04-01/workflowtriggers/method_run.go new file mode 100644 index 00000000000..2fa34636832 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/method_run.go @@ -0,0 +1,70 @@ +package workflowtriggers + +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 RunOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Run ... +func (c WorkflowTriggersClient) Run(ctx context.Context, id TriggerId) (result RunOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 +} + +// RunThenPoll performs Run then polls until it's completed +func (c WorkflowTriggersClient) RunThenPoll(ctx context.Context, id TriggerId) error { + result, err := c.Run(ctx, id) + if err != nil { + return fmt.Errorf("performing Run: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Run: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_jsonschema.go b/resource-manager/web/2024-04-01/workflowtriggers/model_jsonschema.go new file mode 100644 index 00000000000..9dbec86f757 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_jsonschema.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JsonSchema struct { + Content *string `json:"content,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_recurrenceschedule.go b/resource-manager/web/2024-04-01/workflowtriggers/model_recurrenceschedule.go new file mode 100644 index 00000000000..7ea8413d4cd --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_recurrenceschedule.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceSchedule struct { + Hours *[]int64 `json:"hours,omitempty"` + Minutes *[]int64 `json:"minutes,omitempty"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + MonthlyOccurrences *[]RecurrenceScheduleOccurrence `json:"monthlyOccurrences,omitempty"` + WeekDays *[]DaysOfWeek `json:"weekDays,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_recurrencescheduleoccurrence.go b/resource-manager/web/2024-04-01/workflowtriggers/model_recurrencescheduleoccurrence.go new file mode 100644 index 00000000000..39f417c38d7 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_recurrencescheduleoccurrence.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceScheduleOccurrence struct { + Day *DayOfWeek `json:"day,omitempty"` + Occurrence *int64 `json:"occurrence,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_resourcereference.go b/resource-manager/web/2024-04-01/workflowtriggers/model_resourcereference.go new file mode 100644 index 00000000000..f96ba2e28a0 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtrigger.go b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtrigger.go new file mode 100644 index 00000000000..b2502e9f9c4 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtrigger.go @@ -0,0 +1,11 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTrigger struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggercallbackurl.go b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggercallbackurl.go new file mode 100644 index 00000000000..710a39b43aa --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggercallbackurl.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerCallbackURL struct { + BasePath *string `json:"basePath,omitempty"` + Method *string `json:"method,omitempty"` + Queries *WorkflowTriggerListCallbackURLQueries `json:"queries,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` + RelativePathParameters *[]string `json:"relativePathParameters,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go new file mode 100644 index 00000000000..f4e969fd7ab --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerListCallbackURLQueries struct { + ApiVersion *string `json:"api-version,omitempty"` + Se *string `json:"se,omitempty"` + Sig *string `json:"sig,omitempty"` + Sp *string `json:"sp,omitempty"` + Sv *string `json:"sv,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerproperties.go b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerproperties.go new file mode 100644 index 00000000000..b860a57a39c --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerproperties.go @@ -0,0 +1,70 @@ +package workflowtriggers + +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 WorkflowTriggerProperties struct { + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + NextExecutionTime *string `json:"nextExecutionTime,omitempty"` + ProvisioningState *WorkflowTriggerProvisioningState `json:"provisioningState,omitempty"` + Recurrence *WorkflowTriggerRecurrence `json:"recurrence,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowTriggerProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetNextExecutionTimeAsTime() (*time.Time, error) { + if o.NextExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetNextExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextExecutionTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerrecurrence.go b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerrecurrence.go new file mode 100644 index 00000000000..ec9873b4518 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/model_workflowtriggerrecurrence.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerRecurrence struct { + EndTime *string `json:"endTime,omitempty"` + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Schedule *RecurrenceSchedule `json:"schedule,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowtriggers/predicates.go b/resource-manager/web/2024-04-01/workflowtriggers/predicates.go new file mode 100644 index 00000000000..724f6388737 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerOperationPredicate) Matches(input WorkflowTrigger) 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/web/2024-04-01/workflowtriggers/version.go b/resource-manager/web/2024-04-01/workflowtriggers/version.go new file mode 100644 index 00000000000..c7304bbcfb9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowtriggers/version.go @@ -0,0 +1,10 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowtriggers/2024-04-01" +} diff --git a/resource-manager/web/2024-04-01/workflowversions/README.md b/resource-manager/web/2024-04-01/workflowversions/README.md new file mode 100644 index 00000000000..b81734cd0cc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-04-01/workflowversions` Documentation + +The `workflowversions` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-04-01`). + +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/web/2024-04-01/workflowversions" +``` + + +### Client Initialization + +```go +client := workflowversions.NewWorkflowVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowVersionsClient.Get` + +```go +ctx := context.TODO() +id := workflowversions.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId") + +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: `WorkflowVersionsClient.List` + +```go +ctx := context.TODO() +id := workflowversions.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowversions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowversions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-04-01/workflowversions/client.go b/resource-manager/web/2024-04-01/workflowversions/client.go new file mode 100644 index 00000000000..b569325e0f3 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/client.go @@ -0,0 +1,26 @@ +package workflowversions + +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 WorkflowVersionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowVersionsClient: %+v", err) + } + + return &WorkflowVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-04-01/workflowversions/constants.go b/resource-manager/web/2024-04-01/workflowversions/constants.go new file mode 100644 index 00000000000..fe1be75f3e9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/constants.go @@ -0,0 +1,317 @@ +package workflowversions + +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 OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow.go b/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow.go new file mode 100644 index 00000000000..29c5ebda9ab --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow_test.go b/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow_test.go new file mode 100644 index 00000000000..fb252bd145e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowversions + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2024-04-01/workflowversions/id_version.go b/resource-manager/web/2024-04-01/workflowversions/id_version.go new file mode 100644 index 00000000000..d1585eebfb1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/id_version.go @@ -0,0 +1,154 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + VersionId string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, versionId string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + VersionId: versionId, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.VersionId, ok = input.Parsed["versionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionId", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(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 := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.VersionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionId", "versionId"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Version: %q", id.VersionId), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-04-01/workflowversions/id_version_test.go b/resource-manager/web/2024-04-01/workflowversions/id_version_test.go new file mode 100644 index 00000000000..5398d232c03 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/id_version_test.go @@ -0,0 +1,462 @@ +package workflowversions + +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 = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId") + + 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.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.VersionId != "versionId" { + t.Fatalf("Expected %q but got %q for Segment 'VersionId'", id.VersionId, "versionId") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + VersionId: "versionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + VersionId: "versionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS/vErSiOnId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + VersionId: "vErSiOnId", + }, + }, + { + // 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.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS/vErSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(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.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId 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/web/2024-04-01/workflowversions/method_get.go b/resource-manager/web/2024-04-01/workflowversions/method_get.go new file mode 100644 index 00000000000..f2ae2ecca09 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/method_get.go @@ -0,0 +1,53 @@ +package workflowversions + +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 *WorkflowVersion +} + +// Get ... +func (c WorkflowVersionsClient) Get(ctx context.Context, id VersionId) (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 + } + + var model WorkflowVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-04-01/workflowversions/method_list.go b/resource-manager/web/2024-04-01/workflowversions/method_list.go new file mode 100644 index 00000000000..05d795dfb2d --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/method_list.go @@ -0,0 +1,134 @@ +package workflowversions + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowVersion +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowVersion +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowVersionsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", 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 *[]WorkflowVersion `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 WorkflowVersionsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowVersion, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/web/2024-04-01/workflowversions/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2024-04-01/workflowversions/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..4d1b24e5c47 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2024-04-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..623db6898d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_flowendpoints.go b/resource-manager/web/2024-04-01/workflowversions/model_flowendpoints.go new file mode 100644 index 00000000000..78fd2c63224 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_flowendpointsconfiguration.go b/resource-manager/web/2024-04-01/workflowversions/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..dd3a411d472 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_ipaddress.go b/resource-manager/web/2024-04-01/workflowversions/model_ipaddress.go new file mode 100644 index 00000000000..2594d6696b1 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_ipaddressrange.go b/resource-manager/web/2024-04-01/workflowversions/model_ipaddressrange.go new file mode 100644 index 00000000000..c663c9f3a9e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicies.go b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..5b41cfe9f74 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicy.go b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..2a53bfad87e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationpolicyclaim.go b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..2df917da9bc --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_resourcereference.go b/resource-manager/web/2024-04-01/workflowversions/model_resourcereference.go new file mode 100644 index 00000000000..095116732d9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_workflowparameter.go b/resource-manager/web/2024-04-01/workflowversions/model_workflowparameter.go new file mode 100644 index 00000000000..4adc5e9fef6 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_workflowsku.go b/resource-manager/web/2024-04-01/workflowversions/model_workflowsku.go new file mode 100644 index 00000000000..d5bcab2e40e --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_workflowversion.go b/resource-manager/web/2024-04-01/workflowversions/model_workflowversion.go new file mode 100644 index 00000000000..ae7647f4412 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_workflowversion.go @@ -0,0 +1,13 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersion struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowVersionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-04-01/workflowversions/model_workflowversionproperties.go b/resource-manager/web/2024-04-01/workflowversions/model_workflowversionproperties.go new file mode 100644 index 00000000000..0d9459677c9 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/model_workflowversionproperties.go @@ -0,0 +1,49 @@ +package workflowversions + +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 WorkflowVersionProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowVersionProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowVersionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2024-04-01/workflowversions/predicates.go b/resource-manager/web/2024-04-01/workflowversions/predicates.go new file mode 100644 index 00000000000..1458230244b --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/predicates.go @@ -0,0 +1,32 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowVersionOperationPredicate) Matches(input WorkflowVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.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/web/2024-04-01/workflowversions/version.go b/resource-manager/web/2024-04-01/workflowversions/version.go new file mode 100644 index 00000000000..87157825241 --- /dev/null +++ b/resource-manager/web/2024-04-01/workflowversions/version.go @@ -0,0 +1,10 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowversions/2024-04-01" +} diff --git a/resource-manager/workloads/2024-09-01/client.go b/resource-manager/workloads/2024-09-01/client.go new file mode 100644 index 00000000000..1721f61e63f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/client.go @@ -0,0 +1,55 @@ +package v2024_09_01 + +// 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/workloads/2024-09-01/sapapplicationserverinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapcentralserverinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapdatabaseinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + SAPApplicationServerInstances *sapapplicationserverinstances.SAPApplicationServerInstancesClient + SAPCentralServerInstances *sapcentralserverinstances.SAPCentralServerInstancesClient + SAPDatabaseInstances *sapdatabaseinstances.SAPDatabaseInstancesClient + SAPVirtualInstances *sapvirtualinstances.SAPVirtualInstancesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + sAPApplicationServerInstancesClient, err := sapapplicationserverinstances.NewSAPApplicationServerInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPApplicationServerInstances client: %+v", err) + } + configureFunc(sAPApplicationServerInstancesClient.Client) + + sAPCentralServerInstancesClient, err := sapcentralserverinstances.NewSAPCentralServerInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPCentralServerInstances client: %+v", err) + } + configureFunc(sAPCentralServerInstancesClient.Client) + + sAPDatabaseInstancesClient, err := sapdatabaseinstances.NewSAPDatabaseInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPDatabaseInstances client: %+v", err) + } + configureFunc(sAPDatabaseInstancesClient.Client) + + sAPVirtualInstancesClient, err := sapvirtualinstances.NewSAPVirtualInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SAPVirtualInstances client: %+v", err) + } + configureFunc(sAPVirtualInstancesClient.Client) + + return &Client{ + SAPApplicationServerInstances: sAPApplicationServerInstancesClient, + SAPCentralServerInstances: sAPCentralServerInstancesClient, + SAPDatabaseInstances: sAPDatabaseInstancesClient, + SAPVirtualInstances: sAPVirtualInstancesClient, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md new file mode 100644 index 00000000000..465dbf93f8d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapapplicationserverinstances` Documentation + +The `sapapplicationserverinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +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/workloads/2024-09-01/sapapplicationserverinstances" +``` + + +### Client Initialization + +```go +client := sapapplicationserverinstances.NewSAPApplicationServerInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.SAPApplicationServerInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +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: `SAPApplicationServerInstancesClient.List` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// 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: `SAPApplicationServerInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPApplicationServerInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapapplicationserverinstances.NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + +payload := sapapplicationserverinstances.UpdateSAPApplicationInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go new file mode 100644 index 00000000000..db488a14e78 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/client.go @@ -0,0 +1,26 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPApplicationServerInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPApplicationServerInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapapplicationserverinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPApplicationServerInstancesClient: %+v", err) + } + + return &SAPApplicationServerInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go new file mode 100644 index 00000000000..d8b974d4109 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/constants.go @@ -0,0 +1,210 @@ +package sapapplicationserverinstances + +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 ApplicationServerVirtualMachineType string + +const ( + ApplicationServerVirtualMachineTypeActive ApplicationServerVirtualMachineType = "Active" + ApplicationServerVirtualMachineTypeStandby ApplicationServerVirtualMachineType = "Standby" + ApplicationServerVirtualMachineTypeUnknown ApplicationServerVirtualMachineType = "Unknown" +) + +func PossibleValuesForApplicationServerVirtualMachineType() []string { + return []string{ + string(ApplicationServerVirtualMachineTypeActive), + string(ApplicationServerVirtualMachineTypeStandby), + string(ApplicationServerVirtualMachineTypeUnknown), + } +} + +func (s *ApplicationServerVirtualMachineType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationServerVirtualMachineType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationServerVirtualMachineType(input string) (*ApplicationServerVirtualMachineType, error) { + vals := map[string]ApplicationServerVirtualMachineType{ + "active": ApplicationServerVirtualMachineTypeActive, + "standby": ApplicationServerVirtualMachineTypeStandby, + "unknown": ApplicationServerVirtualMachineTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationServerVirtualMachineType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go new file mode 100644 index 00000000000..3f2e13be454 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance.go @@ -0,0 +1,139 @@ +package sapapplicationserverinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&ApplicationInstanceId{}) +} + +var _ resourceids.ResourceId = &ApplicationInstanceId{} + +// ApplicationInstanceId is a struct representing the Resource ID for a Application Instance +type ApplicationInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + ApplicationInstanceName string +} + +// NewApplicationInstanceID returns a new ApplicationInstanceId struct +func NewApplicationInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, applicationInstanceName string) ApplicationInstanceId { + return ApplicationInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + ApplicationInstanceName: applicationInstanceName, + } +} + +// ParseApplicationInstanceID parses 'input' into a ApplicationInstanceId +func ParseApplicationInstanceID(input string) (*ApplicationInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationInstanceIDInsensitively parses 'input' case-insensitively into a ApplicationInstanceId +// note: this method should only be used for API response data and not user input +func ParseApplicationInstanceIDInsensitively(input string) (*ApplicationInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.ApplicationInstanceName, ok = input.Parsed["applicationInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationInstanceName", input) + } + + return nil +} + +// ValidateApplicationInstanceID checks that 'input' can be parsed as a Application Instance ID +func ValidateApplicationInstanceID(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 := ParseApplicationInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Instance ID +func (id ApplicationInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/applicationInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.ApplicationInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Instance ID +func (id ApplicationInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticApplicationInstances", "applicationInstances", "applicationInstances"), + resourceids.UserSpecifiedSegment("applicationInstanceName", "applicationInstanceName"), + } +} + +// String returns a human-readable description of this Application Instance ID +func (id ApplicationInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Application Instance Name: %q", id.ApplicationInstanceName), + } + return fmt.Sprintf("Application Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go new file mode 100644 index 00000000000..4fa45a598af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_applicationinstance_test.go @@ -0,0 +1,327 @@ +package sapapplicationserverinstances + +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 = &ApplicationInstanceId{} + +func TestNewApplicationInstanceID(t *testing.T) { + id := NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.ApplicationInstanceName != "applicationInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationInstanceName'", id.ApplicationInstanceName, "applicationInstanceName") + } +} + +func TestFormatApplicationInstanceID(t *testing.T) { + actual := NewApplicationInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "applicationInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + ApplicationInstanceName: "applicationInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.ApplicationInstanceName != v.Expected.ApplicationInstanceName { + t.Fatalf("Expected %q but got %q for ApplicationInstanceName", v.Expected.ApplicationInstanceName, actual.ApplicationInstanceName) + } + + } +} + +func TestParseApplicationInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + ApplicationInstanceName: "applicationInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/applicationInstances/applicationInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS/aPpLiCaTiOnInStAnCeNaMe", + Expected: &ApplicationInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + ApplicationInstanceName: "aPpLiCaTiOnInStAnCeNaMe", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/aPpLiCaTiOnInStAnCeS/aPpLiCaTiOnInStAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.ApplicationInstanceName != v.Expected.ApplicationInstanceName { + t.Fatalf("Expected %q but got %q for ApplicationInstanceName", v.Expected.ApplicationInstanceName, actual.ApplicationInstanceName) + } + + } +} + +func TestSegmentsForApplicationInstanceId(t *testing.T) { + segments := ApplicationInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationInstanceId 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/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..5c188729bb2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapapplicationserverinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..9b2455837f7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapapplicationserverinstances + +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 = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId 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/workloads/2024-09-01/sapapplicationserverinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go new file mode 100644 index 00000000000..ab1f8b5ee76 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_create.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPApplicationServerInstance +} + +// Create ... +func (c SAPApplicationServerInstancesClient) Create(ctx context.Context, id ApplicationInstanceId, input SAPApplicationServerInstance) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPApplicationServerInstancesClient) CreateThenPoll(ctx context.Context, id ApplicationInstanceId, input SAPApplicationServerInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go new file mode 100644 index 00000000000..ef31f64cc32 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstancesClient) Delete(ctx context.Context, id ApplicationInstanceId) (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 SAPApplicationServerInstancesClient) DeleteThenPoll(ctx context.Context, id ApplicationInstanceId) 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/workloads/2024-09-01/sapapplicationserverinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go new file mode 100644 index 00000000000..85535b6b205 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_get.go @@ -0,0 +1,53 @@ +package sapapplicationserverinstances + +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 *SAPApplicationServerInstance +} + +// Get ... +func (c SAPApplicationServerInstancesClient) Get(ctx context.Context, id ApplicationInstanceId) (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 + } + + var model SAPApplicationServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go new file mode 100644 index 00000000000..e91a1644df2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_list.go @@ -0,0 +1,105 @@ +package sapapplicationserverinstances + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPApplicationServerInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPApplicationServerInstance +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SAPApplicationServerInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/applicationInstances", 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 *[]SAPApplicationServerInstance `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 SAPApplicationServerInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPApplicationServerInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPApplicationServerInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPApplicationServerInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPApplicationServerInstance, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/workloads/2024-09-01/sapapplicationserverinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go new file mode 100644 index 00000000000..0545e8c99eb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_start.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPApplicationServerInstancesClient) Start(ctx context.Context, id ApplicationInstanceId, input StartRequest) (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/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPApplicationServerInstancesClient) StartThenPoll(ctx context.Context, id ApplicationInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go new file mode 100644 index 00000000000..e572880ab74 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapapplicationserverinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPApplicationServerInstancesClient) Stop(ctx context.Context, id ApplicationInstanceId, input StopRequest) (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/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPApplicationServerInstancesClient) StopThenPoll(ctx context.Context, id ApplicationInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/workloads/2024-09-01/sapapplicationserverinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go new file mode 100644 index 00000000000..d1e46dcbf2e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/method_update.go @@ -0,0 +1,57 @@ +package sapapplicationserverinstances + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPApplicationServerInstance +} + +// Update ... +func (c SAPApplicationServerInstancesClient) Update(ctx context.Context, id ApplicationInstanceId, input UpdateSAPApplicationInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SAPApplicationServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go new file mode 100644 index 00000000000..b726103087c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_applicationservervmdetails.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerVMDetails struct { + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + Type *ApplicationServerVirtualMachineType `json:"type,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..0e481e26494 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapapplicationserverinstances + +// 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/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go new file mode 100644 index 00000000000..46aaa86d6cc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go new file mode 100644 index 00000000000..1c96d28f14e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapapplicationserverinstances + +// 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/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..3ff21a98118 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..ef30a3b1ed0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapapplicationserverinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go new file mode 100644 index 00000000000..a3837fdd73d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverinstance.go @@ -0,0 +1,18 @@ +package sapapplicationserverinstances + +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 SAPApplicationServerInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPApplicationServerProperties `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/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go new file mode 100644 index 00000000000..d479c8bf7a7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapapplicationserverproperties.go @@ -0,0 +1,23 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPApplicationServerProperties struct { + DispatcherStatus *string `json:"dispatcherStatus,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + GatewayPort *int64 `json:"gatewayPort,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IcmHTTPPort *int64 `json:"icmHttpPort,omitempty"` + IcmHTTPSPort *int64 `json:"icmHttpsPort,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]ApplicationServerVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..079f2c6a94d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go new file mode 100644 index 00000000000..4e9512a739f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go new file mode 100644 index 00000000000..603321b88ea --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go new file mode 100644 index 00000000000..c4b5853f8d7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go new file mode 100644 index 00000000000..47841304c98 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/model_updatesapapplicationinstancerequest.go @@ -0,0 +1,8 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPApplicationInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go new file mode 100644 index 00000000000..29caee9a23c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/predicates.go @@ -0,0 +1,32 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPApplicationServerInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPApplicationServerInstanceOperationPredicate) Matches(input SAPApplicationServerInstance) 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/workloads/2024-09-01/sapapplicationserverinstances/version.go b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go new file mode 100644 index 00000000000..45916d1a57c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapapplicationserverinstances/version.go @@ -0,0 +1,10 @@ +package sapapplicationserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapapplicationserverinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md new file mode 100644 index 00000000000..41d59c38318 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapcentralserverinstances` Documentation + +The `sapcentralserverinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +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/workloads/2024-09-01/sapcentralserverinstances" +``` + + +### Client Initialization + +```go +client := sapcentralserverinstances.NewSAPCentralServerInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.SAPCentralServerInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +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: `SAPCentralServerInstancesClient.List` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// 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: `SAPCentralServerInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPCentralServerInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapcentralserverinstances.NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + +payload := sapcentralserverinstances.UpdateSAPCentralInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go new file mode 100644 index 00000000000..3afe84dd512 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/client.go @@ -0,0 +1,26 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPCentralServerInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPCentralServerInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapcentralserverinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPCentralServerInstancesClient: %+v", err) + } + + return &SAPCentralServerInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go new file mode 100644 index 00000000000..5123e35af40 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/constants.go @@ -0,0 +1,263 @@ +package sapcentralserverinstances + +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 CentralServerVirtualMachineType string + +const ( + CentralServerVirtualMachineTypeASCS CentralServerVirtualMachineType = "ASCS" + CentralServerVirtualMachineTypeERS CentralServerVirtualMachineType = "ERS" + CentralServerVirtualMachineTypeERSInactive CentralServerVirtualMachineType = "ERSInactive" + CentralServerVirtualMachineTypePrimary CentralServerVirtualMachineType = "Primary" + CentralServerVirtualMachineTypeSecondary CentralServerVirtualMachineType = "Secondary" + CentralServerVirtualMachineTypeStandby CentralServerVirtualMachineType = "Standby" + CentralServerVirtualMachineTypeUnknown CentralServerVirtualMachineType = "Unknown" +) + +func PossibleValuesForCentralServerVirtualMachineType() []string { + return []string{ + string(CentralServerVirtualMachineTypeASCS), + string(CentralServerVirtualMachineTypeERS), + string(CentralServerVirtualMachineTypeERSInactive), + string(CentralServerVirtualMachineTypePrimary), + string(CentralServerVirtualMachineTypeSecondary), + string(CentralServerVirtualMachineTypeStandby), + string(CentralServerVirtualMachineTypeUnknown), + } +} + +func (s *CentralServerVirtualMachineType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCentralServerVirtualMachineType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCentralServerVirtualMachineType(input string) (*CentralServerVirtualMachineType, error) { + vals := map[string]CentralServerVirtualMachineType{ + "ascs": CentralServerVirtualMachineTypeASCS, + "ers": CentralServerVirtualMachineTypeERS, + "ersinactive": CentralServerVirtualMachineTypeERSInactive, + "primary": CentralServerVirtualMachineTypePrimary, + "secondary": CentralServerVirtualMachineTypeSecondary, + "standby": CentralServerVirtualMachineTypeStandby, + "unknown": CentralServerVirtualMachineTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CentralServerVirtualMachineType(input) + return &out, nil +} + +type EnqueueReplicationServerType string + +const ( + EnqueueReplicationServerTypeEnqueueReplicatorOne EnqueueReplicationServerType = "EnqueueReplicator1" + EnqueueReplicationServerTypeEnqueueReplicatorTwo EnqueueReplicationServerType = "EnqueueReplicator2" +) + +func PossibleValuesForEnqueueReplicationServerType() []string { + return []string{ + string(EnqueueReplicationServerTypeEnqueueReplicatorOne), + string(EnqueueReplicationServerTypeEnqueueReplicatorTwo), + } +} + +func (s *EnqueueReplicationServerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnqueueReplicationServerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnqueueReplicationServerType(input string) (*EnqueueReplicationServerType, error) { + vals := map[string]EnqueueReplicationServerType{ + "enqueuereplicator1": EnqueueReplicationServerTypeEnqueueReplicatorOne, + "enqueuereplicator2": EnqueueReplicationServerTypeEnqueueReplicatorTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnqueueReplicationServerType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go new file mode 100644 index 00000000000..f1dc113cecf --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance.go @@ -0,0 +1,139 @@ +package sapcentralserverinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&CentralInstanceId{}) +} + +var _ resourceids.ResourceId = &CentralInstanceId{} + +// CentralInstanceId is a struct representing the Resource ID for a Central Instance +type CentralInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + CentralInstanceName string +} + +// NewCentralInstanceID returns a new CentralInstanceId struct +func NewCentralInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, centralInstanceName string) CentralInstanceId { + return CentralInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + CentralInstanceName: centralInstanceName, + } +} + +// ParseCentralInstanceID parses 'input' into a CentralInstanceId +func ParseCentralInstanceID(input string) (*CentralInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CentralInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CentralInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCentralInstanceIDInsensitively parses 'input' case-insensitively into a CentralInstanceId +// note: this method should only be used for API response data and not user input +func ParseCentralInstanceIDInsensitively(input string) (*CentralInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CentralInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CentralInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CentralInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.CentralInstanceName, ok = input.Parsed["centralInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "centralInstanceName", input) + } + + return nil +} + +// ValidateCentralInstanceID checks that 'input' can be parsed as a Central Instance ID +func ValidateCentralInstanceID(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 := ParseCentralInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Central Instance ID +func (id CentralInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/centralInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.CentralInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Central Instance ID +func (id CentralInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticCentralInstances", "centralInstances", "centralInstances"), + resourceids.UserSpecifiedSegment("centralInstanceName", "centralInstanceName"), + } +} + +// String returns a human-readable description of this Central Instance ID +func (id CentralInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Central Instance Name: %q", id.CentralInstanceName), + } + return fmt.Sprintf("Central Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go new file mode 100644 index 00000000000..ef54149a599 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_centralinstance_test.go @@ -0,0 +1,327 @@ +package sapcentralserverinstances + +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 = &CentralInstanceId{} + +func TestNewCentralInstanceID(t *testing.T) { + id := NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.CentralInstanceName != "centralInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'CentralInstanceName'", id.CentralInstanceName, "centralInstanceName") + } +} + +func TestFormatCentralInstanceID(t *testing.T) { + actual := NewCentralInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "centralInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCentralInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CentralInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + CentralInstanceName: "centralInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCentralInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.CentralInstanceName != v.Expected.CentralInstanceName { + t.Fatalf("Expected %q but got %q for CentralInstanceName", v.Expected.CentralInstanceName, actual.CentralInstanceName) + } + + } +} + +func TestParseCentralInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CentralInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + CentralInstanceName: "centralInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/centralInstances/centralInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS/cEnTrAlInStAnCeNaMe", + Expected: &CentralInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + CentralInstanceName: "cEnTrAlInStAnCeNaMe", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/cEnTrAlInStAnCeS/cEnTrAlInStAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCentralInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.CentralInstanceName != v.Expected.CentralInstanceName { + t.Fatalf("Expected %q but got %q for CentralInstanceName", v.Expected.CentralInstanceName, actual.CentralInstanceName) + } + + } +} + +func TestSegmentsForCentralInstanceId(t *testing.T) { + segments := CentralInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CentralInstanceId 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/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..8f987ad996b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapcentralserverinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..030e8ee55dd --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapcentralserverinstances + +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 = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId 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/workloads/2024-09-01/sapcentralserverinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go new file mode 100644 index 00000000000..573c95e929e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_create.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPCentralServerInstance +} + +// Create ... +func (c SAPCentralServerInstancesClient) Create(ctx context.Context, id CentralInstanceId, input SAPCentralServerInstance) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPCentralServerInstancesClient) CreateThenPoll(ctx context.Context, id CentralInstanceId, input SAPCentralServerInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go new file mode 100644 index 00000000000..923f154846a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstancesClient) Delete(ctx context.Context, id CentralInstanceId) (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 SAPCentralServerInstancesClient) DeleteThenPoll(ctx context.Context, id CentralInstanceId) 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/workloads/2024-09-01/sapcentralserverinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go new file mode 100644 index 00000000000..3d60cfb8ddc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_get.go @@ -0,0 +1,53 @@ +package sapcentralserverinstances + +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 *SAPCentralServerInstance +} + +// Get ... +func (c SAPCentralServerInstancesClient) Get(ctx context.Context, id CentralInstanceId) (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 + } + + var model SAPCentralServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go new file mode 100644 index 00000000000..84fb920ff22 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_list.go @@ -0,0 +1,105 @@ +package sapcentralserverinstances + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPCentralServerInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPCentralServerInstance +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SAPCentralServerInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/centralInstances", 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 *[]SAPCentralServerInstance `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 SAPCentralServerInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPCentralServerInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPCentralServerInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPCentralServerInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPCentralServerInstance, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/workloads/2024-09-01/sapcentralserverinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go new file mode 100644 index 00000000000..f43ae42b616 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_start.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPCentralServerInstancesClient) Start(ctx context.Context, id CentralInstanceId, input StartRequest) (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/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPCentralServerInstancesClient) StartThenPoll(ctx context.Context, id CentralInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/workloads/2024-09-01/sapcentralserverinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go new file mode 100644 index 00000000000..3d90866c7af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapcentralserverinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPCentralServerInstancesClient) Stop(ctx context.Context, id CentralInstanceId, input StopRequest) (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/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPCentralServerInstancesClient) StopThenPoll(ctx context.Context, id CentralInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/workloads/2024-09-01/sapcentralserverinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go new file mode 100644 index 00000000000..0d38bae0695 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/method_update.go @@ -0,0 +1,57 @@ +package sapcentralserverinstances + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPCentralServerInstance +} + +// Update ... +func (c SAPCentralServerInstancesClient) Update(ctx context.Context, id CentralInstanceId, input UpdateSAPCentralInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SAPCentralServerInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go new file mode 100644 index 00000000000..51e66ae4628 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_centralservervmdetails.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerVMDetails struct { + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + Type *CentralServerVirtualMachineType `json:"type,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go new file mode 100644 index 00000000000..c8bdb57a883 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueuereplicationserverproperties.go @@ -0,0 +1,14 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnqueueReplicationServerProperties struct { + ErsVersion *EnqueueReplicationServerType `json:"ersVersion,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go new file mode 100644 index 00000000000..8f338c92243 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_enqueueserverproperties.go @@ -0,0 +1,11 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnqueueServerProperties struct { + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..da146f1761c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// 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/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go new file mode 100644 index 00000000000..1e2bc5a1a72 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go new file mode 100644 index 00000000000..2602ea3533b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapcentralserverinstances + +// 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/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go new file mode 100644 index 00000000000..603e6e7577d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_gatewayserverproperties.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayServerProperties struct { + Health *SAPHealthState `json:"health,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..3907ef35a43 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go new file mode 100644 index 00000000000..fe1c784bb49 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_messageserverproperties.go @@ -0,0 +1,14 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageServerProperties struct { + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + Hostname *string `json:"hostname,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InternalMsPort *int64 `json:"internalMsPort,omitempty"` + MsPort *int64 `json:"msPort,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..2aa75ea1f54 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapcentralserverinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go new file mode 100644 index 00000000000..95b8cbc088c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverinstance.go @@ -0,0 +1,18 @@ +package sapcentralserverinstances + +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 SAPCentralServerInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPCentralServerProperties `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/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go new file mode 100644 index 00000000000..7a0dd2ab42a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapcentralserverproperties.go @@ -0,0 +1,21 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPCentralServerProperties struct { + EnqueueReplicationServerProperties *EnqueueReplicationServerProperties `json:"enqueueReplicationServerProperties,omitempty"` + EnqueueServerProperties *EnqueueServerProperties `json:"enqueueServerProperties,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + GatewayServerProperties *GatewayServerProperties `json:"gatewayServerProperties,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + InstanceNo *string `json:"instanceNo,omitempty"` + KernelPatch *string `json:"kernelPatch,omitempty"` + KernelVersion *string `json:"kernelVersion,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + MessageServerProperties *MessageServerProperties `json:"messageServerProperties,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]CentralServerVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..dc2d54ce4ae --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go new file mode 100644 index 00000000000..ff3ed0c7bcb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go new file mode 100644 index 00000000000..bff0289b502 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go new file mode 100644 index 00000000000..fe88f2d14c1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go new file mode 100644 index 00000000000..f22c45eeaf7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/model_updatesapcentralinstancerequest.go @@ -0,0 +1,8 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPCentralInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go new file mode 100644 index 00000000000..425219f1f39 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/predicates.go @@ -0,0 +1,32 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPCentralServerInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPCentralServerInstanceOperationPredicate) Matches(input SAPCentralServerInstance) 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/workloads/2024-09-01/sapcentralserverinstances/version.go b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go new file mode 100644 index 00000000000..50ae7a3b83e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapcentralserverinstances/version.go @@ -0,0 +1,10 @@ +package sapcentralserverinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapcentralserverinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md new file mode 100644 index 00000000000..4178575ceaa --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapdatabaseinstances` Documentation + +The `sapdatabaseinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +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/workloads/2024-09-01/sapdatabaseinstances" +``` + + +### Client Initialization + +```go +client := sapdatabaseinstances.NewSAPDatabaseInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.SAPDatabaseInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +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: `SAPDatabaseInstancesClient.List` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +// 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: `SAPDatabaseInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPDatabaseInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapdatabaseinstances.NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + +payload := sapdatabaseinstances.UpdateSAPDatabaseInstanceRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go new file mode 100644 index 00000000000..7ef60c6a773 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/client.go @@ -0,0 +1,26 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPDatabaseInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPDatabaseInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapdatabaseinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPDatabaseInstancesClient: %+v", err) + } + + return &SAPDatabaseInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go new file mode 100644 index 00000000000..242c9049980 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/constants.go @@ -0,0 +1,119 @@ +package sapdatabaseinstances + +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 SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go new file mode 100644 index 00000000000..7b114164c04 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance.go @@ -0,0 +1,139 @@ +package sapdatabaseinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&DatabaseInstanceId{}) +} + +var _ resourceids.ResourceId = &DatabaseInstanceId{} + +// DatabaseInstanceId is a struct representing the Resource ID for a Database Instance +type DatabaseInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string + DatabaseInstanceName string +} + +// NewDatabaseInstanceID returns a new DatabaseInstanceId struct +func NewDatabaseInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string, databaseInstanceName string) DatabaseInstanceId { + return DatabaseInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + DatabaseInstanceName: databaseInstanceName, + } +} + +// ParseDatabaseInstanceID parses 'input' into a DatabaseInstanceId +func ParseDatabaseInstanceID(input string) (*DatabaseInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseInstanceIDInsensitively parses 'input' case-insensitively into a DatabaseInstanceId +// note: this method should only be used for API response data and not user input +func ParseDatabaseInstanceIDInsensitively(input string) (*DatabaseInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + if id.DatabaseInstanceName, ok = input.Parsed["databaseInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseInstanceName", input) + } + + return nil +} + +// ValidateDatabaseInstanceID checks that 'input' can be parsed as a Database Instance ID +func ValidateDatabaseInstanceID(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 := ParseDatabaseInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Instance ID +func (id DatabaseInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s/databaseInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName, id.DatabaseInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Instance ID +func (id DatabaseInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + resourceids.StaticSegment("staticDatabaseInstances", "databaseInstances", "databaseInstances"), + resourceids.UserSpecifiedSegment("databaseInstanceName", "databaseInstanceName"), + } +} + +// String returns a human-readable description of this Database Instance ID +func (id DatabaseInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + fmt.Sprintf("Database Instance Name: %q", id.DatabaseInstanceName), + } + return fmt.Sprintf("Database Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go new file mode 100644 index 00000000000..9ac9a5f54c9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_databaseinstance_test.go @@ -0,0 +1,327 @@ +package sapdatabaseinstances + +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 = &DatabaseInstanceId{} + +func TestNewDatabaseInstanceID(t *testing.T) { + id := NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } + + if id.DatabaseInstanceName != "databaseInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseInstanceName'", id.DatabaseInstanceName, "databaseInstanceName") + } +} + +func TestFormatDatabaseInstanceID(t *testing.T) { + actual := NewDatabaseInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName", "databaseInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + DatabaseInstanceName: "databaseInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.DatabaseInstanceName != v.Expected.DatabaseInstanceName { + t.Fatalf("Expected %q but got %q for DatabaseInstanceName", v.Expected.DatabaseInstanceName, actual.DatabaseInstanceName) + } + + } +} + +func TestParseDatabaseInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + DatabaseInstanceName: "databaseInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/databaseInstances/databaseInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs/dAtAbAsEiNsTaNcEnAmE", + Expected: &DatabaseInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + DatabaseInstanceName: "dAtAbAsEiNsTaNcEnAmE", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/dAtAbAsEiNsTaNcEs/dAtAbAsEiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + if actual.DatabaseInstanceName != v.Expected.DatabaseInstanceName { + t.Fatalf("Expected %q but got %q for DatabaseInstanceName", v.Expected.DatabaseInstanceName, actual.DatabaseInstanceName) + } + + } +} + +func TestSegmentsForDatabaseInstanceId(t *testing.T) { + segments := DatabaseInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseInstanceId 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/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..f4f8aa9d143 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapdatabaseinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..0a5881b6428 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapdatabaseinstances + +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 = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId 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/workloads/2024-09-01/sapdatabaseinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go new file mode 100644 index 00000000000..7317badba24 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_create.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPDatabaseInstance +} + +// Create ... +func (c SAPDatabaseInstancesClient) Create(ctx context.Context, id DatabaseInstanceId, input SAPDatabaseInstance) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPDatabaseInstancesClient) CreateThenPoll(ctx context.Context, id DatabaseInstanceId, input SAPDatabaseInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go new file mode 100644 index 00000000000..87d7e580a3a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstancesClient) Delete(ctx context.Context, id DatabaseInstanceId) (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 SAPDatabaseInstancesClient) DeleteThenPoll(ctx context.Context, id DatabaseInstanceId) 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/workloads/2024-09-01/sapdatabaseinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go new file mode 100644 index 00000000000..1c4add58a17 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_get.go @@ -0,0 +1,53 @@ +package sapdatabaseinstances + +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 *SAPDatabaseInstance +} + +// Get ... +func (c SAPDatabaseInstancesClient) Get(ctx context.Context, id DatabaseInstanceId) (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 + } + + var model SAPDatabaseInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go new file mode 100644 index 00000000000..ce164baa7f1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_list.go @@ -0,0 +1,105 @@ +package sapdatabaseinstances + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPDatabaseInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPDatabaseInstance +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SAPDatabaseInstancesClient) List(ctx context.Context, id SapVirtualInstanceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/databaseInstances", 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 *[]SAPDatabaseInstance `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 SAPDatabaseInstancesClient) ListComplete(ctx context.Context, id SapVirtualInstanceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SAPDatabaseInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPDatabaseInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id SapVirtualInstanceId, predicate SAPDatabaseInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SAPDatabaseInstance, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/workloads/2024-09-01/sapdatabaseinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go new file mode 100644 index 00000000000..0202a996a2c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_start.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPDatabaseInstancesClient) Start(ctx context.Context, id DatabaseInstanceId, input StartRequest) (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/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPDatabaseInstancesClient) StartThenPoll(ctx context.Context, id DatabaseInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/workloads/2024-09-01/sapdatabaseinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go new file mode 100644 index 00000000000..a4696981eee --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapdatabaseinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPDatabaseInstancesClient) Stop(ctx context.Context, id DatabaseInstanceId, input StopRequest) (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/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPDatabaseInstancesClient) StopThenPoll(ctx context.Context, id DatabaseInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/workloads/2024-09-01/sapdatabaseinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go new file mode 100644 index 00000000000..eafa8168fd9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/method_update.go @@ -0,0 +1,57 @@ +package sapdatabaseinstances + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPDatabaseInstance +} + +// Update ... +func (c SAPDatabaseInstancesClient) Update(ctx context.Context, id DatabaseInstanceId, input UpdateSAPDatabaseInstanceRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model SAPDatabaseInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go new file mode 100644 index 00000000000..61f23878c82 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_databasevmdetails.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseVMDetails struct { + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + StorageDetails *[]StorageInformation `json:"storageDetails,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..3f0ca0f13ad --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapdatabaseinstances + +// 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/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go new file mode 100644 index 00000000000..a0010440822 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go new file mode 100644 index 00000000000..109ec8b6f46 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapdatabaseinstances + +// 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/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go new file mode 100644 index 00000000000..c13208cd34a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_loadbalancerdetails.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerDetails struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..f6e093ddffd --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapdatabaseinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go new file mode 100644 index 00000000000..04f0b39f6d3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseinstance.go @@ -0,0 +1,18 @@ +package sapdatabaseinstances + +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 SAPDatabaseInstance struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPDatabaseProperties `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/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go new file mode 100644 index 00000000000..25dd497a869 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapdatabaseproperties.go @@ -0,0 +1,16 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDatabaseProperties struct { + DatabaseSid *string `json:"databaseSid,omitempty"` + DatabaseType *string `json:"databaseType,omitempty"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LoadBalancerDetails *LoadBalancerDetails `json:"loadBalancerDetails,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + Subnet *string `json:"subnet,omitempty"` + VMDetails *[]DatabaseVMDetails `json:"vmDetails,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..016147f0493 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go new file mode 100644 index 00000000000..59064628a09 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go new file mode 100644 index 00000000000..34a89b63370 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go new file mode 100644 index 00000000000..4f5182e83c0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_storageinformation.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageInformation struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go new file mode 100644 index 00000000000..31957d5bbca --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/model_updatesapdatabaseinstancerequest.go @@ -0,0 +1,8 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPDatabaseInstanceRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go new file mode 100644 index 00000000000..eba9c19b470 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/predicates.go @@ -0,0 +1,32 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDatabaseInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPDatabaseInstanceOperationPredicate) Matches(input SAPDatabaseInstance) 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/workloads/2024-09-01/sapdatabaseinstances/version.go b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go new file mode 100644 index 00000000000..7d4dd3d65f9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapdatabaseinstances/version.go @@ -0,0 +1,10 @@ +package sapdatabaseinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapdatabaseinstances/2024-09-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md b/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md new file mode 100644 index 00000000000..44ad2680008 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/README.md @@ -0,0 +1,235 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances` Documentation + +The `sapvirtualinstances` SDK allows for interaction with Azure Resource Manager `workloads` (API Version `2024-09-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2024-09-01/sapvirtualinstances" +``` + + +### Client Initialization + +```go +client := sapvirtualinstances.NewSAPVirtualInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SAPVirtualInstancesClient.Create` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.SAPVirtualInstance{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Delete` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Get` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +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: `SAPVirtualInstancesClient.InvokeAvailabilityZoneDetails` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPAvailabilityZoneDetailsRequest{ + // ... +} + + +read, err := client.InvokeAvailabilityZoneDetails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeDiskConfigurations` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPDiskConfigurationsRequest{ + // ... +} + + +read, err := client.InvokeDiskConfigurations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeSapSupportedSku` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPSupportedSkusRequest{ + // ... +} + + +read, err := client.InvokeSapSupportedSku(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.InvokeSizingRecommendations` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := sapvirtualinstances.SAPSizingRecommendationRequest{ + // ... +} + + +read, err := client.InvokeSizingRecommendations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Start` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.StartRequest{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Stop` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.StopRequest{ + // ... +} + + +if err := client.StopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SAPVirtualInstancesClient.Update` + +```go +ctx := context.TODO() +id := sapvirtualinstances.NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + +payload := sapvirtualinstances.UpdateSAPVirtualInstanceRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go new file mode 100644 index 00000000000..e7297735c3f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/client.go @@ -0,0 +1,26 @@ +package sapvirtualinstances + +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 SAPVirtualInstancesClient struct { + Client *resourcemanager.Client +} + +func NewSAPVirtualInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*SAPVirtualInstancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sapvirtualinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SAPVirtualInstancesClient: %+v", err) + } + + return &SAPVirtualInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go new file mode 100644 index 00000000000..b67571e0654 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/constants.go @@ -0,0 +1,794 @@ +package sapvirtualinstances + +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 DiskSkuName string + +const ( + DiskSkuNamePremiumLRS DiskSkuName = "Premium_LRS" + DiskSkuNamePremiumVTwoLRS DiskSkuName = "PremiumV2_LRS" + DiskSkuNamePremiumZRS DiskSkuName = "Premium_ZRS" + DiskSkuNameStandardLRS DiskSkuName = "Standard_LRS" + DiskSkuNameStandardSSDLRS DiskSkuName = "StandardSSD_LRS" + DiskSkuNameStandardSSDZRS DiskSkuName = "StandardSSD_ZRS" + DiskSkuNameUltraSSDLRS DiskSkuName = "UltraSSD_LRS" +) + +func PossibleValuesForDiskSkuName() []string { + return []string{ + string(DiskSkuNamePremiumLRS), + string(DiskSkuNamePremiumVTwoLRS), + string(DiskSkuNamePremiumZRS), + string(DiskSkuNameStandardLRS), + string(DiskSkuNameStandardSSDLRS), + string(DiskSkuNameStandardSSDZRS), + string(DiskSkuNameUltraSSDLRS), + } +} + +func (s *DiskSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskSkuName(input string) (*DiskSkuName, error) { + vals := map[string]DiskSkuName{ + "premium_lrs": DiskSkuNamePremiumLRS, + "premiumv2_lrs": DiskSkuNamePremiumVTwoLRS, + "premium_zrs": DiskSkuNamePremiumZRS, + "standard_lrs": DiskSkuNameStandardLRS, + "standardssd_lrs": DiskSkuNameStandardSSDLRS, + "standardssd_zrs": DiskSkuNameStandardSSDZRS, + "ultrassd_lrs": DiskSkuNameUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskSkuName(input) + return &out, nil +} + +type FileShareConfigurationType string + +const ( + FileShareConfigurationTypeCreateAndMount FileShareConfigurationType = "CreateAndMount" + FileShareConfigurationTypeMount FileShareConfigurationType = "Mount" + FileShareConfigurationTypeSkip FileShareConfigurationType = "Skip" +) + +func PossibleValuesForFileShareConfigurationType() []string { + return []string{ + string(FileShareConfigurationTypeCreateAndMount), + string(FileShareConfigurationTypeMount), + string(FileShareConfigurationTypeSkip), + } +} + +func (s *FileShareConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFileShareConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFileShareConfigurationType(input string) (*FileShareConfigurationType, error) { + vals := map[string]FileShareConfigurationType{ + "createandmount": FileShareConfigurationTypeCreateAndMount, + "mount": FileShareConfigurationTypeMount, + "skip": FileShareConfigurationTypeSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileShareConfigurationType(input) + return &out, nil +} + +type ManagedResourcesNetworkAccessType string + +const ( + ManagedResourcesNetworkAccessTypePrivate ManagedResourcesNetworkAccessType = "Private" + ManagedResourcesNetworkAccessTypePublic ManagedResourcesNetworkAccessType = "Public" +) + +func PossibleValuesForManagedResourcesNetworkAccessType() []string { + return []string{ + string(ManagedResourcesNetworkAccessTypePrivate), + string(ManagedResourcesNetworkAccessTypePublic), + } +} + +func (s *ManagedResourcesNetworkAccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourcesNetworkAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedResourcesNetworkAccessType(input string) (*ManagedResourcesNetworkAccessType, error) { + vals := map[string]ManagedResourcesNetworkAccessType{ + "private": ManagedResourcesNetworkAccessTypePrivate, + "public": ManagedResourcesNetworkAccessTypePublic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedResourcesNetworkAccessType(input) + return &out, nil +} + +type NamingPatternType string + +const ( + NamingPatternTypeFullResourceName NamingPatternType = "FullResourceName" +) + +func PossibleValuesForNamingPatternType() []string { + return []string{ + string(NamingPatternTypeFullResourceName), + } +} + +func (s *NamingPatternType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNamingPatternType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNamingPatternType(input string) (*NamingPatternType, error) { + vals := map[string]NamingPatternType{ + "fullresourcename": NamingPatternTypeFullResourceName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NamingPatternType(input) + return &out, nil +} + +type OSType string + +const ( + OSTypeLinux OSType = "Linux" + OSTypeWindows OSType = "Windows" +) + +func PossibleValuesForOSType() []string { + return []string{ + string(OSTypeLinux), + string(OSTypeWindows), + } +} + +func (s *OSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSType(input string) (*OSType, error) { + vals := map[string]OSType{ + "linux": OSTypeLinux, + "windows": OSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSType(input) + return &out, nil +} + +type SAPConfigurationType string + +const ( + SAPConfigurationTypeDeployment SAPConfigurationType = "Deployment" + SAPConfigurationTypeDeploymentWithOSConfig SAPConfigurationType = "DeploymentWithOSConfig" + SAPConfigurationTypeDiscovery SAPConfigurationType = "Discovery" +) + +func PossibleValuesForSAPConfigurationType() []string { + return []string{ + string(SAPConfigurationTypeDeployment), + string(SAPConfigurationTypeDeploymentWithOSConfig), + string(SAPConfigurationTypeDiscovery), + } +} + +func (s *SAPConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPConfigurationType(input string) (*SAPConfigurationType, error) { + vals := map[string]SAPConfigurationType{ + "deployment": SAPConfigurationTypeDeployment, + "deploymentwithosconfig": SAPConfigurationTypeDeploymentWithOSConfig, + "discovery": SAPConfigurationTypeDiscovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPConfigurationType(input) + return &out, nil +} + +type SAPDatabaseScaleMethod string + +const ( + SAPDatabaseScaleMethodScaleUp SAPDatabaseScaleMethod = "ScaleUp" +) + +func PossibleValuesForSAPDatabaseScaleMethod() []string { + return []string{ + string(SAPDatabaseScaleMethodScaleUp), + } +} + +func (s *SAPDatabaseScaleMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDatabaseScaleMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDatabaseScaleMethod(input string) (*SAPDatabaseScaleMethod, error) { + vals := map[string]SAPDatabaseScaleMethod{ + "scaleup": SAPDatabaseScaleMethodScaleUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDatabaseScaleMethod(input) + return &out, nil +} + +type SAPDatabaseType string + +const ( + SAPDatabaseTypeDBTwo SAPDatabaseType = "DB2" + SAPDatabaseTypeHANA SAPDatabaseType = "HANA" +) + +func PossibleValuesForSAPDatabaseType() []string { + return []string{ + string(SAPDatabaseTypeDBTwo), + string(SAPDatabaseTypeHANA), + } +} + +func (s *SAPDatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDatabaseType(input string) (*SAPDatabaseType, error) { + vals := map[string]SAPDatabaseType{ + "db2": SAPDatabaseTypeDBTwo, + "hana": SAPDatabaseTypeHANA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDatabaseType(input) + return &out, nil +} + +type SAPDeploymentType string + +const ( + SAPDeploymentTypeSingleServer SAPDeploymentType = "SingleServer" + SAPDeploymentTypeThreeTier SAPDeploymentType = "ThreeTier" +) + +func PossibleValuesForSAPDeploymentType() []string { + return []string{ + string(SAPDeploymentTypeSingleServer), + string(SAPDeploymentTypeThreeTier), + } +} + +func (s *SAPDeploymentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPDeploymentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPDeploymentType(input string) (*SAPDeploymentType, error) { + vals := map[string]SAPDeploymentType{ + "singleserver": SAPDeploymentTypeSingleServer, + "threetier": SAPDeploymentTypeThreeTier, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPDeploymentType(input) + return &out, nil +} + +type SAPEnvironmentType string + +const ( + SAPEnvironmentTypeNonProd SAPEnvironmentType = "NonProd" + SAPEnvironmentTypeProd SAPEnvironmentType = "Prod" +) + +func PossibleValuesForSAPEnvironmentType() []string { + return []string{ + string(SAPEnvironmentTypeNonProd), + string(SAPEnvironmentTypeProd), + } +} + +func (s *SAPEnvironmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPEnvironmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPEnvironmentType(input string) (*SAPEnvironmentType, error) { + vals := map[string]SAPEnvironmentType{ + "nonprod": SAPEnvironmentTypeNonProd, + "prod": SAPEnvironmentTypeProd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPEnvironmentType(input) + return &out, nil +} + +type SAPHealthState string + +const ( + SAPHealthStateDegraded SAPHealthState = "Degraded" + SAPHealthStateHealthy SAPHealthState = "Healthy" + SAPHealthStateUnhealthy SAPHealthState = "Unhealthy" + SAPHealthStateUnknown SAPHealthState = "Unknown" +) + +func PossibleValuesForSAPHealthState() []string { + return []string{ + string(SAPHealthStateDegraded), + string(SAPHealthStateHealthy), + string(SAPHealthStateUnhealthy), + string(SAPHealthStateUnknown), + } +} + +func (s *SAPHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHealthState(input string) (*SAPHealthState, error) { + vals := map[string]SAPHealthState{ + "degraded": SAPHealthStateDegraded, + "healthy": SAPHealthStateHealthy, + "unhealthy": SAPHealthStateUnhealthy, + "unknown": SAPHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHealthState(input) + return &out, nil +} + +type SAPHighAvailabilityType string + +const ( + SAPHighAvailabilityTypeAvailabilitySet SAPHighAvailabilityType = "AvailabilitySet" + SAPHighAvailabilityTypeAvailabilityZone SAPHighAvailabilityType = "AvailabilityZone" +) + +func PossibleValuesForSAPHighAvailabilityType() []string { + return []string{ + string(SAPHighAvailabilityTypeAvailabilitySet), + string(SAPHighAvailabilityTypeAvailabilityZone), + } +} + +func (s *SAPHighAvailabilityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPHighAvailabilityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPHighAvailabilityType(input string) (*SAPHighAvailabilityType, error) { + vals := map[string]SAPHighAvailabilityType{ + "availabilityset": SAPHighAvailabilityTypeAvailabilitySet, + "availabilityzone": SAPHighAvailabilityTypeAvailabilityZone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPHighAvailabilityType(input) + return &out, nil +} + +type SAPProductType string + +const ( + SAPProductTypeECC SAPProductType = "ECC" + SAPProductTypeOther SAPProductType = "Other" + SAPProductTypeSFourHANA SAPProductType = "S4HANA" +) + +func PossibleValuesForSAPProductType() []string { + return []string{ + string(SAPProductTypeECC), + string(SAPProductTypeOther), + string(SAPProductTypeSFourHANA), + } +} + +func (s *SAPProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPProductType(input string) (*SAPProductType, error) { + vals := map[string]SAPProductType{ + "ecc": SAPProductTypeECC, + "other": SAPProductTypeOther, + "s4hana": SAPProductTypeSFourHANA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPProductType(input) + return &out, nil +} + +type SAPSoftwareInstallationType string + +const ( + SAPSoftwareInstallationTypeExternal SAPSoftwareInstallationType = "External" + SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig SAPSoftwareInstallationType = "SAPInstallWithoutOSConfig" + SAPSoftwareInstallationTypeServiceInitiated SAPSoftwareInstallationType = "ServiceInitiated" +) + +func PossibleValuesForSAPSoftwareInstallationType() []string { + return []string{ + string(SAPSoftwareInstallationTypeExternal), + string(SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig), + string(SAPSoftwareInstallationTypeServiceInitiated), + } +} + +func (s *SAPSoftwareInstallationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPSoftwareInstallationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPSoftwareInstallationType(input string) (*SAPSoftwareInstallationType, error) { + vals := map[string]SAPSoftwareInstallationType{ + "external": SAPSoftwareInstallationTypeExternal, + "sapinstallwithoutosconfig": SAPSoftwareInstallationTypeSAPInstallWithoutOSConfig, + "serviceinitiated": SAPSoftwareInstallationTypeServiceInitiated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPSoftwareInstallationType(input) + return &out, nil +} + +type SAPVirtualInstanceState string + +const ( + SAPVirtualInstanceStateACSSInstallationBlocked SAPVirtualInstanceState = "ACSSInstallationBlocked" + SAPVirtualInstanceStateDiscoveryFailed SAPVirtualInstanceState = "DiscoveryFailed" + SAPVirtualInstanceStateDiscoveryInProgress SAPVirtualInstanceState = "DiscoveryInProgress" + SAPVirtualInstanceStateDiscoveryPending SAPVirtualInstanceState = "DiscoveryPending" + SAPVirtualInstanceStateInfrastructureDeploymentFailed SAPVirtualInstanceState = "InfrastructureDeploymentFailed" + SAPVirtualInstanceStateInfrastructureDeploymentInProgress SAPVirtualInstanceState = "InfrastructureDeploymentInProgress" + SAPVirtualInstanceStateInfrastructureDeploymentPending SAPVirtualInstanceState = "InfrastructureDeploymentPending" + SAPVirtualInstanceStateRegistrationComplete SAPVirtualInstanceState = "RegistrationComplete" + SAPVirtualInstanceStateSoftwareDetectionFailed SAPVirtualInstanceState = "SoftwareDetectionFailed" + SAPVirtualInstanceStateSoftwareDetectionInProgress SAPVirtualInstanceState = "SoftwareDetectionInProgress" + SAPVirtualInstanceStateSoftwareInstallationFailed SAPVirtualInstanceState = "SoftwareInstallationFailed" + SAPVirtualInstanceStateSoftwareInstallationInProgress SAPVirtualInstanceState = "SoftwareInstallationInProgress" + SAPVirtualInstanceStateSoftwareInstallationPending SAPVirtualInstanceState = "SoftwareInstallationPending" +) + +func PossibleValuesForSAPVirtualInstanceState() []string { + return []string{ + string(SAPVirtualInstanceStateACSSInstallationBlocked), + string(SAPVirtualInstanceStateDiscoveryFailed), + string(SAPVirtualInstanceStateDiscoveryInProgress), + string(SAPVirtualInstanceStateDiscoveryPending), + string(SAPVirtualInstanceStateInfrastructureDeploymentFailed), + string(SAPVirtualInstanceStateInfrastructureDeploymentInProgress), + string(SAPVirtualInstanceStateInfrastructureDeploymentPending), + string(SAPVirtualInstanceStateRegistrationComplete), + string(SAPVirtualInstanceStateSoftwareDetectionFailed), + string(SAPVirtualInstanceStateSoftwareDetectionInProgress), + string(SAPVirtualInstanceStateSoftwareInstallationFailed), + string(SAPVirtualInstanceStateSoftwareInstallationInProgress), + string(SAPVirtualInstanceStateSoftwareInstallationPending), + } +} + +func (s *SAPVirtualInstanceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceState(input string) (*SAPVirtualInstanceState, error) { + vals := map[string]SAPVirtualInstanceState{ + "acssinstallationblocked": SAPVirtualInstanceStateACSSInstallationBlocked, + "discoveryfailed": SAPVirtualInstanceStateDiscoveryFailed, + "discoveryinprogress": SAPVirtualInstanceStateDiscoveryInProgress, + "discoverypending": SAPVirtualInstanceStateDiscoveryPending, + "infrastructuredeploymentfailed": SAPVirtualInstanceStateInfrastructureDeploymentFailed, + "infrastructuredeploymentinprogress": SAPVirtualInstanceStateInfrastructureDeploymentInProgress, + "infrastructuredeploymentpending": SAPVirtualInstanceStateInfrastructureDeploymentPending, + "registrationcomplete": SAPVirtualInstanceStateRegistrationComplete, + "softwaredetectionfailed": SAPVirtualInstanceStateSoftwareDetectionFailed, + "softwaredetectioninprogress": SAPVirtualInstanceStateSoftwareDetectionInProgress, + "softwareinstallationfailed": SAPVirtualInstanceStateSoftwareInstallationFailed, + "softwareinstallationinprogress": SAPVirtualInstanceStateSoftwareInstallationInProgress, + "softwareinstallationpending": SAPVirtualInstanceStateSoftwareInstallationPending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceState(input) + return &out, nil +} + +type SAPVirtualInstanceStatus string + +const ( + SAPVirtualInstanceStatusOffline SAPVirtualInstanceStatus = "Offline" + SAPVirtualInstanceStatusPartiallyRunning SAPVirtualInstanceStatus = "PartiallyRunning" + SAPVirtualInstanceStatusRunning SAPVirtualInstanceStatus = "Running" + SAPVirtualInstanceStatusSoftShutdown SAPVirtualInstanceStatus = "SoftShutdown" + SAPVirtualInstanceStatusStarting SAPVirtualInstanceStatus = "Starting" + SAPVirtualInstanceStatusStopping SAPVirtualInstanceStatus = "Stopping" + SAPVirtualInstanceStatusUnavailable SAPVirtualInstanceStatus = "Unavailable" +) + +func PossibleValuesForSAPVirtualInstanceStatus() []string { + return []string{ + string(SAPVirtualInstanceStatusOffline), + string(SAPVirtualInstanceStatusPartiallyRunning), + string(SAPVirtualInstanceStatusRunning), + string(SAPVirtualInstanceStatusSoftShutdown), + string(SAPVirtualInstanceStatusStarting), + string(SAPVirtualInstanceStatusStopping), + string(SAPVirtualInstanceStatusUnavailable), + } +} + +func (s *SAPVirtualInstanceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSAPVirtualInstanceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSAPVirtualInstanceStatus(input string) (*SAPVirtualInstanceStatus, error) { + vals := map[string]SAPVirtualInstanceStatus{ + "offline": SAPVirtualInstanceStatusOffline, + "partiallyrunning": SAPVirtualInstanceStatusPartiallyRunning, + "running": SAPVirtualInstanceStatusRunning, + "softshutdown": SAPVirtualInstanceStatusSoftShutdown, + "starting": SAPVirtualInstanceStatusStarting, + "stopping": SAPVirtualInstanceStatusStopping, + "unavailable": SAPVirtualInstanceStatusUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SAPVirtualInstanceStatus(input) + return &out, nil +} + +type SapVirtualInstanceProvisioningState string + +const ( + SapVirtualInstanceProvisioningStateCanceled SapVirtualInstanceProvisioningState = "Canceled" + SapVirtualInstanceProvisioningStateCreating SapVirtualInstanceProvisioningState = "Creating" + SapVirtualInstanceProvisioningStateDeleting SapVirtualInstanceProvisioningState = "Deleting" + SapVirtualInstanceProvisioningStateFailed SapVirtualInstanceProvisioningState = "Failed" + SapVirtualInstanceProvisioningStateSucceeded SapVirtualInstanceProvisioningState = "Succeeded" + SapVirtualInstanceProvisioningStateUpdating SapVirtualInstanceProvisioningState = "Updating" +) + +func PossibleValuesForSapVirtualInstanceProvisioningState() []string { + return []string{ + string(SapVirtualInstanceProvisioningStateCanceled), + string(SapVirtualInstanceProvisioningStateCreating), + string(SapVirtualInstanceProvisioningStateDeleting), + string(SapVirtualInstanceProvisioningStateFailed), + string(SapVirtualInstanceProvisioningStateSucceeded), + string(SapVirtualInstanceProvisioningStateUpdating), + } +} + +func (s *SapVirtualInstanceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSapVirtualInstanceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSapVirtualInstanceProvisioningState(input string) (*SapVirtualInstanceProvisioningState, error) { + vals := map[string]SapVirtualInstanceProvisioningState{ + "canceled": SapVirtualInstanceProvisioningStateCanceled, + "creating": SapVirtualInstanceProvisioningStateCreating, + "deleting": SapVirtualInstanceProvisioningStateDeleting, + "failed": SapVirtualInstanceProvisioningStateFailed, + "succeeded": SapVirtualInstanceProvisioningStateSucceeded, + "updating": SapVirtualInstanceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SapVirtualInstanceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go new file mode 100644 index 00000000000..bff26be9c89 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location.go @@ -0,0 +1,121 @@ +package sapvirtualinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Workloads/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go new file mode 100644 index 00000000000..a693a81b998 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_location_test.go @@ -0,0 +1,237 @@ +package sapvirtualinstances + +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 = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + 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.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // 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/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Workloads/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId 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/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go new file mode 100644 index 00000000000..64a6c56e20c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance.go @@ -0,0 +1,130 @@ +package sapvirtualinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "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. + +func init() { + recaser.RegisterResourceId(&SapVirtualInstanceId{}) +} + +var _ resourceids.ResourceId = &SapVirtualInstanceId{} + +// SapVirtualInstanceId is a struct representing the Resource ID for a Sap Virtual Instance +type SapVirtualInstanceId struct { + SubscriptionId string + ResourceGroupName string + SapVirtualInstanceName string +} + +// NewSapVirtualInstanceID returns a new SapVirtualInstanceId struct +func NewSapVirtualInstanceID(subscriptionId string, resourceGroupName string, sapVirtualInstanceName string) SapVirtualInstanceId { + return SapVirtualInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SapVirtualInstanceName: sapVirtualInstanceName, + } +} + +// ParseSapVirtualInstanceID parses 'input' into a SapVirtualInstanceId +func ParseSapVirtualInstanceID(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSapVirtualInstanceIDInsensitively parses 'input' case-insensitively into a SapVirtualInstanceId +// note: this method should only be used for API response data and not user input +func ParseSapVirtualInstanceIDInsensitively(input string) (*SapVirtualInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SapVirtualInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SapVirtualInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SapVirtualInstanceId) 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.SapVirtualInstanceName, ok = input.Parsed["sapVirtualInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sapVirtualInstanceName", input) + } + + return nil +} + +// ValidateSapVirtualInstanceID checks that 'input' can be parsed as a Sap Virtual Instance ID +func ValidateSapVirtualInstanceID(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 := ParseSapVirtualInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sap Virtual Instance ID +func (id SapVirtualInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Workloads/sapVirtualInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SapVirtualInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sap Virtual Instance ID +func (id SapVirtualInstanceId) 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("staticMicrosoftWorkloads", "Microsoft.Workloads", "Microsoft.Workloads"), + resourceids.StaticSegment("staticSapVirtualInstances", "sapVirtualInstances", "sapVirtualInstances"), + resourceids.UserSpecifiedSegment("sapVirtualInstanceName", "sapVirtualInstanceName"), + } +} + +// String returns a human-readable description of this Sap Virtual Instance ID +func (id SapVirtualInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sap Virtual Instance Name: %q", id.SapVirtualInstanceName), + } + return fmt.Sprintf("Sap Virtual Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go new file mode 100644 index 00000000000..6348f9430ac --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/id_sapvirtualinstance_test.go @@ -0,0 +1,282 @@ +package sapvirtualinstances + +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 = &SapVirtualInstanceId{} + +func TestNewSapVirtualInstanceID(t *testing.T) { + id := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName") + + 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.SapVirtualInstanceName != "sapVirtualInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'SapVirtualInstanceName'", id.SapVirtualInstanceName, "sapVirtualInstanceName") + } +} + +func TestFormatSapVirtualInstanceID(t *testing.T) { + actual := NewSapVirtualInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sapVirtualInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSapVirtualInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceID(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestParseSapVirtualInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SapVirtualInstanceId + }{ + { + // 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.Workloads", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SapVirtualInstanceName: "sapVirtualInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Workloads/sapVirtualInstances/sapVirtualInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE", + Expected: &SapVirtualInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SapVirtualInstanceName: "sApViRtUaLiNsTaNcEnAmE", + }, + }, + { + // 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.wOrKlOaDs/sApViRtUaLiNsTaNcEs/sApViRtUaLiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSapVirtualInstanceIDInsensitively(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.SapVirtualInstanceName != v.Expected.SapVirtualInstanceName { + t.Fatalf("Expected %q but got %q for SapVirtualInstanceName", v.Expected.SapVirtualInstanceName, actual.SapVirtualInstanceName) + } + + } +} + +func TestSegmentsForSapVirtualInstanceId(t *testing.T) { + segments := SapVirtualInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SapVirtualInstanceId 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/workloads/2024-09-01/sapvirtualinstances/method_create.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go new file mode 100644 index 00000000000..cf665a1c878 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_create.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SAPVirtualInstance +} + +// Create ... +func (c SAPVirtualInstancesClient) Create(ctx context.Context, id SapVirtualInstanceId, input SAPVirtualInstance) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c SAPVirtualInstancesClient) CreateThenPoll(ctx context.Context, id SapVirtualInstanceId, input SAPVirtualInstance) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go new file mode 100644 index 00000000000..b945144f8af --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_delete.go @@ -0,0 +1,70 @@ +package sapvirtualinstances + +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 SAPVirtualInstancesClient) Delete(ctx context.Context, id SapVirtualInstanceId) (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 SAPVirtualInstancesClient) DeleteThenPoll(ctx context.Context, id SapVirtualInstanceId) 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/workloads/2024-09-01/sapvirtualinstances/method_get.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go new file mode 100644 index 00000000000..a475bb7cdfb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_get.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +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 *SAPVirtualInstance +} + +// Get ... +func (c SAPVirtualInstancesClient) Get(ctx context.Context, id SapVirtualInstanceId) (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 + } + + var model SAPVirtualInstance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go new file mode 100644 index 00000000000..a392cd30743 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokeavailabilityzonedetails.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +import ( + "context" + "fmt" + "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 InvokeAvailabilityZoneDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPAvailabilityZoneDetailsResult +} + +// InvokeAvailabilityZoneDetails ... +func (c SAPVirtualInstancesClient) InvokeAvailabilityZoneDetails(ctx context.Context, id LocationId, input SAPAvailabilityZoneDetailsRequest) (result InvokeAvailabilityZoneDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getAvailabilityZoneDetails", 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 + } + + var model SAPAvailabilityZoneDetailsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go new file mode 100644 index 00000000000..b76d7789f1b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokediskconfigurations.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +import ( + "context" + "fmt" + "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 InvokeDiskConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPDiskConfigurationsResult +} + +// InvokeDiskConfigurations ... +func (c SAPVirtualInstancesClient) InvokeDiskConfigurations(ctx context.Context, id LocationId, input SAPDiskConfigurationsRequest) (result InvokeDiskConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getDiskConfigurations", 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 + } + + var model SAPDiskConfigurationsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go new file mode 100644 index 00000000000..94a2f51a83f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesapsupportedsku.go @@ -0,0 +1,58 @@ +package sapvirtualinstances + +import ( + "context" + "fmt" + "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 InvokeSapSupportedSkuOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SAPSupportedResourceSkusResult +} + +// InvokeSapSupportedSku ... +func (c SAPVirtualInstancesClient) InvokeSapSupportedSku(ctx context.Context, id LocationId, input SAPSupportedSkusRequest) (result InvokeSapSupportedSkuOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getSapSupportedSku", 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 + } + + var model SAPSupportedResourceSkusResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go new file mode 100644 index 00000000000..df9142c7a11 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_invokesizingrecommendations.go @@ -0,0 +1,63 @@ +package sapvirtualinstances + +import ( + "context" + "encoding/json" + "fmt" + "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 InvokeSizingRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model SAPSizingRecommendationResult +} + +// InvokeSizingRecommendations ... +func (c SAPVirtualInstancesClient) InvokeSizingRecommendations(ctx context.Context, id LocationId, input SAPSizingRecommendationRequest) (result InvokeSizingRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sapVirtualInstanceMetadata/default/getSizingRecommendations", 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 + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalSAPSizingRecommendationResultImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go new file mode 100644 index 00000000000..82e423c66ab --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package sapvirtualinstances + +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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPVirtualInstance +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPVirtualInstance +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c SAPVirtualInstancesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Workloads/sapVirtualInstances", 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 *[]SAPVirtualInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SAPVirtualInstancesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SAPVirtualInstanceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPVirtualInstancesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SAPVirtualInstanceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SAPVirtualInstance, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go new file mode 100644 index 00000000000..69718c73bd8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_listbysubscription.go @@ -0,0 +1,106 @@ +package sapvirtualinstances + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SAPVirtualInstance +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SAPVirtualInstance +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c SAPVirtualInstancesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Workloads/sapVirtualInstances", 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 *[]SAPVirtualInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SAPVirtualInstancesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SAPVirtualInstanceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SAPVirtualInstancesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SAPVirtualInstanceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SAPVirtualInstance, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go new file mode 100644 index 00000000000..b2814bb9cd5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_start.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Start ... +func (c SAPVirtualInstancesClient) Start(ctx context.Context, id SapVirtualInstanceId, input StartRequest) (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/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c SAPVirtualInstancesClient) StartThenPoll(ctx context.Context, id SapVirtualInstanceId, input StartRequest) error { + result, err := c.Start(ctx, id, input) + 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/workloads/2024-09-01/sapvirtualinstances/method_stop.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go new file mode 100644 index 00000000000..aac10878a2b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_stop.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationStatusResult +} + +// Stop ... +func (c SAPVirtualInstancesClient) Stop(ctx context.Context, id SapVirtualInstanceId, input StopRequest) (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/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c SAPVirtualInstancesClient) StopThenPoll(ctx context.Context, id SapVirtualInstanceId, input StopRequest) error { + result, err := c.Stop(ctx, id, input) + 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/workloads/2024-09-01/sapvirtualinstances/method_update.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go new file mode 100644 index 00000000000..b3f22f61acb --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/method_update.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 + Model *SAPVirtualInstance +} + +// Update ... +func (c SAPVirtualInstancesClient) Update(ctx context.Context, id SapVirtualInstanceId, input UpdateSAPVirtualInstanceRequest) (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 SAPVirtualInstancesClient) UpdateThenPoll(ctx context.Context, id SapVirtualInstanceId, input UpdateSAPVirtualInstanceRequest) 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/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go new file mode 100644 index 00000000000..16e4d301f4c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerConfiguration struct { + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go new file mode 100644 index 00000000000..2b99b68a423 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_applicationserverfullresourcenames.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go new file mode 100644 index 00000000000..691fffbf2c7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerConfiguration struct { + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go new file mode 100644 index 00000000000..c3a013c0f52 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_centralserverfullresourcenames.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CentralServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + LoadBalancer *LoadBalancerResourceNames `json:"loadBalancer,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go new file mode 100644 index 00000000000..a3a5b08974c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_createandmountfileshareconfiguration.go @@ -0,0 +1,51 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = CreateAndMountFileShareConfiguration{} + +type CreateAndMountFileShareConfiguration struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s CreateAndMountFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = CreateAndMountFileShareConfiguration{} + +func (s CreateAndMountFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper CreateAndMountFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "CreateAndMount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CreateAndMountFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go new file mode 100644 index 00000000000..3777d01e9b8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseconfiguration.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConfiguration struct { + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DiskConfiguration *DiskConfiguration `json:"diskConfiguration,omitempty"` + InstanceCount int64 `json:"instanceCount"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go new file mode 100644 index 00000000000..ee192d2c046 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_databaseserverfullresourcenames.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseServerFullResourceNames struct { + AvailabilitySetName *string `json:"availabilitySetName,omitempty"` + LoadBalancer *LoadBalancerResourceNames `json:"loadBalancer,omitempty"` + VirtualMachines *[]VirtualMachineResourceNames `json:"virtualMachines,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go new file mode 100644 index 00000000000..bfcd632981c --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deployervmpackages.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeployerVMPackages struct { + StorageAccountId *string `json:"storageAccountId,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go new file mode 100644 index 00000000000..f1c10fae8c3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentconfiguration.go @@ -0,0 +1,90 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DeploymentConfiguration{} + +type DeploymentConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + InfrastructureConfiguration InfrastructureConfiguration `json:"infrastructureConfiguration"` + SoftwareConfiguration SoftwareConfiguration `json:"softwareConfiguration"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DeploymentConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DeploymentConfiguration{} + +func (s DeploymentConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DeploymentConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeploymentConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeploymentConfiguration: %+v", err) + } + + decoded["configurationType"] = "Deployment" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeploymentConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DeploymentConfiguration{} + +func (s *DeploymentConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppLocation *string `json:"appLocation,omitempty"` + ConfigurationType SAPConfigurationType `json:"configurationType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppLocation = decoded.AppLocation + s.ConfigurationType = decoded.ConfigurationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeploymentConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["infrastructureConfiguration"]; ok { + impl, err := UnmarshalInfrastructureConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'InfrastructureConfiguration' for 'DeploymentConfiguration': %+v", err) + } + s.InfrastructureConfiguration = impl + } + + if v, ok := temp["softwareConfiguration"]; ok { + impl, err := UnmarshalSoftwareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SoftwareConfiguration' for 'DeploymentConfiguration': %+v", err) + } + s.SoftwareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go new file mode 100644 index 00000000000..9feff2a8ee7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_deploymentwithosconfiguration.go @@ -0,0 +1,93 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DeploymentWithOSConfiguration{} + +type DeploymentWithOSConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + InfrastructureConfiguration InfrastructureConfiguration `json:"infrastructureConfiguration"` + OsSapConfiguration *OsSapConfiguration `json:"osSapConfiguration,omitempty"` + SoftwareConfiguration SoftwareConfiguration `json:"softwareConfiguration"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DeploymentWithOSConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DeploymentWithOSConfiguration{} + +func (s DeploymentWithOSConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DeploymentWithOSConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DeploymentWithOSConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DeploymentWithOSConfiguration: %+v", err) + } + + decoded["configurationType"] = "DeploymentWithOSConfig" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DeploymentWithOSConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DeploymentWithOSConfiguration{} + +func (s *DeploymentWithOSConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppLocation *string `json:"appLocation,omitempty"` + OsSapConfiguration *OsSapConfiguration `json:"osSapConfiguration,omitempty"` + ConfigurationType SAPConfigurationType `json:"configurationType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppLocation = decoded.AppLocation + s.OsSapConfiguration = decoded.OsSapConfiguration + s.ConfigurationType = decoded.ConfigurationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeploymentWithOSConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["infrastructureConfiguration"]; ok { + impl, err := UnmarshalInfrastructureConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'InfrastructureConfiguration' for 'DeploymentWithOSConfiguration': %+v", err) + } + s.InfrastructureConfiguration = impl + } + + if v, ok := temp["softwareConfiguration"]; ok { + impl, err := UnmarshalSoftwareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SoftwareConfiguration' for 'DeploymentWithOSConfiguration': %+v", err) + } + s.SoftwareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go new file mode 100644 index 00000000000..05e6556d368 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_discoveryconfiguration.go @@ -0,0 +1,52 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPConfiguration = DiscoveryConfiguration{} + +type DiscoveryConfiguration struct { + AppLocation *string `json:"appLocation,omitempty"` + CentralServerVMId *string `json:"centralServerVmId,omitempty"` + ManagedRgStorageAccountName *string `json:"managedRgStorageAccountName,omitempty"` + + // Fields inherited from SAPConfiguration + + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s DiscoveryConfiguration) SAPConfiguration() BaseSAPConfigurationImpl { + return BaseSAPConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = DiscoveryConfiguration{} + +func (s DiscoveryConfiguration) MarshalJSON() ([]byte, error) { + type wrapper DiscoveryConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DiscoveryConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DiscoveryConfiguration: %+v", err) + } + + decoded["configurationType"] = "Discovery" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DiscoveryConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go new file mode 100644 index 00000000000..b9fada01e2e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskConfiguration struct { + DiskVolumeConfigurations *map[string]DiskVolumeConfiguration `json:"diskVolumeConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go new file mode 100644 index 00000000000..19e1caae1c2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskdetails.go @@ -0,0 +1,14 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + DiskTier *string `json:"diskTier,omitempty"` + IopsReadWrite *int64 `json:"iopsReadWrite,omitempty"` + MaximumSupportedDiskCount *int64 `json:"maximumSupportedDiskCount,omitempty"` + MbpsReadWrite *int64 `json:"mbpsReadWrite,omitempty"` + MinimumSupportedDiskCount *int64 `json:"minimumSupportedDiskCount,omitempty"` + SizeGB *int64 `json:"sizeGB,omitempty"` + Sku *DiskSku `json:"sku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go new file mode 100644 index 00000000000..4ad14b3416e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_disksku.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskSku struct { + Name *DiskSkuName `json:"name,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go new file mode 100644 index 00000000000..ddc92a369c7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_diskvolumeconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskVolumeConfiguration struct { + Count *int64 `json:"count,omitempty"` + SizeGB *int64 `json:"sizeGB,omitempty"` + Sku *DiskSku `json:"sku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..18c075c9e04 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// 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/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go new file mode 100644 index 00000000000..becaed0cda3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordefinition.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDefinition struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorDefinition `json:"details,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go new file mode 100644 index 00000000000..23a41b56090 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// 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/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go new file mode 100644 index 00000000000..5e0b4faacb7 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_externalinstallationsoftwareconfiguration.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = ExternalInstallationSoftwareConfiguration{} + +type ExternalInstallationSoftwareConfiguration struct { + CentralServerVMId *string `json:"centralServerVmId,omitempty"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s ExternalInstallationSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = ExternalInstallationSoftwareConfiguration{} + +func (s ExternalInstallationSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ExternalInstallationSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "External" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExternalInstallationSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go new file mode 100644 index 00000000000..efbdf413150 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_fileshareconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 FileShareConfiguration interface { + FileShareConfiguration() BaseFileShareConfigurationImpl +} + +var _ FileShareConfiguration = BaseFileShareConfigurationImpl{} + +type BaseFileShareConfigurationImpl struct { + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s BaseFileShareConfigurationImpl) FileShareConfiguration() BaseFileShareConfigurationImpl { + return s +} + +var _ FileShareConfiguration = RawFileShareConfigurationImpl{} + +// RawFileShareConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFileShareConfigurationImpl struct { + fileShareConfiguration BaseFileShareConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawFileShareConfigurationImpl) FileShareConfiguration() BaseFileShareConfigurationImpl { + return s.fileShareConfiguration +} + +func UnmarshalFileShareConfigurationImplementation(input []byte) (FileShareConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling FileShareConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["configurationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CreateAndMount") { + var out CreateAndMountFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CreateAndMountFileShareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Mount") { + var out MountFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MountFileShareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Skip") { + var out SkipFileShareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SkipFileShareConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseFileShareConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFileShareConfigurationImpl: %+v", err) + } + + return RawFileShareConfigurationImpl{ + fileShareConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go new file mode 100644 index 00000000000..d9ce01fc8b1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilityconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailabilityConfiguration struct { + HighAvailabilityType SAPHighAvailabilityType `json:"highAvailabilityType"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go new file mode 100644 index 00000000000..8d8583b37b3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_highavailabilitysoftwareconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HighAvailabilitySoftwareConfiguration struct { + FencingClientId string `json:"fencingClientId"` + FencingClientPassword string `json:"fencingClientPassword"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go new file mode 100644 index 00000000000..4f1ac0a149b --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_imagereference.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageReference struct { + Id *string `json:"id,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go new file mode 100644 index 00000000000..138f40f4a24 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_infrastructureconfiguration.go @@ -0,0 +1,84 @@ +package sapvirtualinstances + +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 InfrastructureConfiguration interface { + InfrastructureConfiguration() BaseInfrastructureConfigurationImpl +} + +var _ InfrastructureConfiguration = BaseInfrastructureConfigurationImpl{} + +type BaseInfrastructureConfigurationImpl struct { + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s BaseInfrastructureConfigurationImpl) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return s +} + +var _ InfrastructureConfiguration = RawInfrastructureConfigurationImpl{} + +// RawInfrastructureConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawInfrastructureConfigurationImpl struct { + infrastructureConfiguration BaseInfrastructureConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawInfrastructureConfigurationImpl) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return s.infrastructureConfiguration +} + +func UnmarshalInfrastructureConfigurationImplementation(input []byte) (InfrastructureConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling InfrastructureConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["deploymentType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SingleServer") { + var out SingleServerConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ThreeTier") { + var out ThreeTierConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseInfrastructureConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseInfrastructureConfigurationImpl: %+v", err) + } + + return RawInfrastructureConfigurationImpl{ + infrastructureConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go new file mode 100644 index 00000000000..3e39988ded8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_linuxconfiguration.go @@ -0,0 +1,52 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OSConfiguration = LinuxConfiguration{} + +type LinuxConfiguration struct { + DisablePasswordAuthentication *bool `json:"disablePasswordAuthentication,omitempty"` + Ssh *SshConfiguration `json:"ssh,omitempty"` + SshKeyPair *SshKeyPair `json:"sshKeyPair,omitempty"` + + // Fields inherited from OSConfiguration + + OsType OSType `json:"osType"` +} + +func (s LinuxConfiguration) OSConfiguration() BaseOSConfigurationImpl { + return BaseOSConfigurationImpl{ + OsType: s.OsType, + } +} + +var _ json.Marshaler = LinuxConfiguration{} + +func (s LinuxConfiguration) MarshalJSON() ([]byte, error) { + type wrapper LinuxConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LinuxConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LinuxConfiguration: %+v", err) + } + + decoded["osType"] = "Linux" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LinuxConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go new file mode 100644 index 00000000000..7789f0e8351 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_loadbalancerresourcenames.go @@ -0,0 +1,11 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerResourceNames struct { + BackendPoolNames *[]string `json:"backendPoolNames,omitempty"` + FrontendIPConfigurationNames *[]string `json:"frontendIpConfigurationNames,omitempty"` + HealthProbeNames *[]string `json:"healthProbeNames,omitempty"` + LoadBalancerName *string `json:"loadBalancerName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go new file mode 100644 index 00000000000..8d7002377ff --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_managedrgconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRGConfiguration struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go new file mode 100644 index 00000000000..12b9d933808 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_mountfileshareconfiguration.go @@ -0,0 +1,51 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = MountFileShareConfiguration{} + +type MountFileShareConfiguration struct { + Id string `json:"id"` + PrivateEndpointId string `json:"privateEndpointId"` + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s MountFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = MountFileShareConfiguration{} + +func (s MountFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper MountFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MountFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MountFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "Mount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MountFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go new file mode 100644 index 00000000000..3805e428087 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfiguration struct { + IsSecondaryIPEnabled *bool `json:"isSecondaryIpEnabled,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go new file mode 100644 index 00000000000..0116cdb0dc2 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_networkinterfaceresourcenames.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceResourceNames struct { + NetworkInterfaceName *string `json:"networkInterfaceName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go new file mode 100644 index 00000000000..723b60a69e6 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_operationstatusresult.go @@ -0,0 +1,46 @@ +package sapvirtualinstances + +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 OperationStatusResult struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Operations *[]OperationStatusResult `json:"operations,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *OperationStatusResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *OperationStatusResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OperationStatusResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go new file mode 100644 index 00000000000..53ac3199476 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osconfiguration.go @@ -0,0 +1,83 @@ +package sapvirtualinstances + +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 OSConfiguration interface { + OSConfiguration() BaseOSConfigurationImpl +} + +var _ OSConfiguration = BaseOSConfigurationImpl{} + +type BaseOSConfigurationImpl struct { + OsType OSType `json:"osType"` +} + +func (s BaseOSConfigurationImpl) OSConfiguration() BaseOSConfigurationImpl { + return s +} + +var _ OSConfiguration = RawOSConfigurationImpl{} + +// RawOSConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawOSConfigurationImpl struct { + oSConfiguration BaseOSConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawOSConfigurationImpl) OSConfiguration() BaseOSConfigurationImpl { + return s.oSConfiguration +} + +func UnmarshalOSConfigurationImplementation(input []byte) (OSConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling OSConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["osType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Linux") { + var out LinuxConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LinuxConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out WindowsConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into WindowsConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseOSConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOSConfigurationImpl: %+v", err) + } + + return RawOSConfigurationImpl{ + oSConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go new file mode 100644 index 00000000000..5b4cba4ab6f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_osprofile.go @@ -0,0 +1,45 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + OsConfiguration OSConfiguration `json:"osConfiguration"` +} + +var _ json.Unmarshaler = &OSProfile{} + +func (s *OSProfile) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AdminPassword = decoded.AdminPassword + s.AdminUsername = decoded.AdminUsername + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling OSProfile into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["osConfiguration"]; ok { + impl, err := UnmarshalOSConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'OsConfiguration' for 'OSProfile': %+v", err) + } + s.OsConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go new file mode 100644 index 00000000000..d5a1d18b285 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_ossapconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsSapConfiguration struct { + DeployerVMPackages *DeployerVMPackages `json:"deployerVmPackages,omitempty"` + SapFqdn *string `json:"sapFqdn,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go new file mode 100644 index 00000000000..3002b1dcd82 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsrequest.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZoneDetailsRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go new file mode 100644 index 00000000000..88a3556f5c5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonedetailsresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZoneDetailsResult struct { + AvailabilityZonePairs *[]SAPAvailabilityZonePair `json:"availabilityZonePairs,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go new file mode 100644 index 00000000000..3c18d72d02d --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapavailabilityzonepair.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPAvailabilityZonePair struct { + ZoneA *int64 `json:"zoneA,omitempty"` + ZoneB *int64 `json:"zoneB,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go new file mode 100644 index 00000000000..776e6a14fc5 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 SAPConfiguration interface { + SAPConfiguration() BaseSAPConfigurationImpl +} + +var _ SAPConfiguration = BaseSAPConfigurationImpl{} + +type BaseSAPConfigurationImpl struct { + ConfigurationType SAPConfigurationType `json:"configurationType"` +} + +func (s BaseSAPConfigurationImpl) SAPConfiguration() BaseSAPConfigurationImpl { + return s +} + +var _ SAPConfiguration = RawSAPConfigurationImpl{} + +// RawSAPConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSAPConfigurationImpl struct { + sAPConfiguration BaseSAPConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawSAPConfigurationImpl) SAPConfiguration() BaseSAPConfigurationImpl { + return s.sAPConfiguration +} + +func UnmarshalSAPConfigurationImplementation(input []byte) (SAPConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SAPConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["configurationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Deployment") { + var out DeploymentConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeploymentConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DeploymentWithOSConfig") { + var out DeploymentWithOSConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DeploymentWithOSConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Discovery") { + var out DiscoveryConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DiscoveryConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseSAPConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSAPConfigurationImpl: %+v", err) + } + + return RawSAPConfigurationImpl{ + sAPConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go new file mode 100644 index 00000000000..e1ee5988200 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfiguration.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfiguration struct { + RecommendedConfiguration *DiskVolumeConfiguration `json:"recommendedConfiguration,omitempty"` + SupportedConfigurations *[]DiskDetails `json:"supportedConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go new file mode 100644 index 00000000000..743d843fa54 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsrequest.go @@ -0,0 +1,13 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfigurationsRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DbVMSku string `json:"dbVmSku"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go new file mode 100644 index 00000000000..f40e340ae21 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapdiskconfigurationsresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPDiskConfigurationsResult struct { + VolumeConfigurations *map[string]SAPDiskConfiguration `json:"volumeConfigurations,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go new file mode 100644 index 00000000000..14cfc6b9ba8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapinstallwithoutosconfigsoftwareconfiguration.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = SAPInstallWithoutOSConfigSoftwareConfiguration{} + +type SAPInstallWithoutOSConfigSoftwareConfiguration struct { + BomURL string `json:"bomUrl"` + HighAvailabilitySoftwareConfiguration *HighAvailabilitySoftwareConfiguration `json:"highAvailabilitySoftwareConfiguration,omitempty"` + SapBitsStorageAccountId string `json:"sapBitsStorageAccountId"` + SoftwareVersion string `json:"softwareVersion"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s SAPInstallWithoutOSConfigSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = SAPInstallWithoutOSConfigSoftwareConfiguration{} + +func (s SAPInstallWithoutOSConfigSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SAPInstallWithoutOSConfigSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "SAPInstallWithoutOSConfig" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go new file mode 100644 index 00000000000..3ddb3c14444 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationrequest.go @@ -0,0 +1,16 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSizingRecommendationRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DbMemory int64 `json:"dbMemory"` + DbScaleMethod *SAPDatabaseScaleMethod `json:"dbScaleMethod,omitempty"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + HighAvailabilityType *SAPHighAvailabilityType `json:"highAvailabilityType,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + Saps int64 `json:"saps"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go new file mode 100644 index 00000000000..187e7a164ee --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsizingrecommendationresult.go @@ -0,0 +1,83 @@ +package sapvirtualinstances + +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 SAPSizingRecommendationResult interface { + SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl +} + +var _ SAPSizingRecommendationResult = BaseSAPSizingRecommendationResultImpl{} + +type BaseSAPSizingRecommendationResultImpl struct { + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s BaseSAPSizingRecommendationResultImpl) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return s +} + +var _ SAPSizingRecommendationResult = RawSAPSizingRecommendationResultImpl{} + +// RawSAPSizingRecommendationResultImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSAPSizingRecommendationResultImpl struct { + sAPSizingRecommendationResult BaseSAPSizingRecommendationResultImpl + Type string + Values map[string]interface{} +} + +func (s RawSAPSizingRecommendationResultImpl) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return s.sAPSizingRecommendationResult +} + +func UnmarshalSAPSizingRecommendationResultImplementation(input []byte) (SAPSizingRecommendationResult, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SAPSizingRecommendationResult into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["deploymentType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SingleServer") { + var out SingleServerRecommendationResult + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerRecommendationResult: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ThreeTier") { + var out ThreeTierRecommendationResult + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierRecommendationResult: %+v", err) + } + return out, nil + } + + var parent BaseSAPSizingRecommendationResultImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSAPSizingRecommendationResultImpl: %+v", err) + } + + return RawSAPSizingRecommendationResultImpl{ + sAPSizingRecommendationResult: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go new file mode 100644 index 00000000000..0fdd3d4be10 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedresourceskusresult.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedResourceSkusResult struct { + SupportedSkus *[]SAPSupportedSku `json:"supportedSkus,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go new file mode 100644 index 00000000000..d04c2328462 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedsku.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedSku struct { + IsAppServerCertified *bool `json:"isAppServerCertified,omitempty"` + IsDatabaseCertified *bool `json:"isDatabaseCertified,omitempty"` + VMSku *string `json:"vmSku,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go new file mode 100644 index 00000000000..3e24c4c3d59 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapsupportedskusrequest.go @@ -0,0 +1,13 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPSupportedSkusRequest struct { + AppLocation string `json:"appLocation"` + DatabaseType SAPDatabaseType `json:"databaseType"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + Environment SAPEnvironmentType `json:"environment"` + HighAvailabilityType *SAPHighAvailabilityType `json:"highAvailabilityType,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go new file mode 100644 index 00000000000..6ca7eaa18d8 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go @@ -0,0 +1,20 @@ +package sapvirtualinstances + +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 SAPVirtualInstance struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPVirtualInstanceProperties `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/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go new file mode 100644 index 00000000000..b473f684fcc --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceerror.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceError struct { + Properties *ErrorDefinition `json:"properties,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go new file mode 100644 index 00000000000..a60c5700024 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstanceproperties.go @@ -0,0 +1,66 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceProperties struct { + Configuration SAPConfiguration `json:"configuration"` + Environment SAPEnvironmentType `json:"environment"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + ManagedResourceGroupConfiguration *ManagedRGConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + State *SAPVirtualInstanceState `json:"state,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` +} + +var _ json.Unmarshaler = &SAPVirtualInstanceProperties{} + +func (s *SAPVirtualInstanceProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Environment SAPEnvironmentType `json:"environment"` + Errors *SAPVirtualInstanceError `json:"errors,omitempty"` + Health *SAPHealthState `json:"health,omitempty"` + ManagedResourceGroupConfiguration *ManagedRGConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` + ProvisioningState *SapVirtualInstanceProvisioningState `json:"provisioningState,omitempty"` + SapProduct SAPProductType `json:"sapProduct"` + State *SAPVirtualInstanceState `json:"state,omitempty"` + Status *SAPVirtualInstanceStatus `json:"status,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Environment = decoded.Environment + s.Errors = decoded.Errors + s.Health = decoded.Health + s.ManagedResourceGroupConfiguration = decoded.ManagedResourceGroupConfiguration + s.ManagedResourcesNetworkAccessType = decoded.ManagedResourcesNetworkAccessType + s.ProvisioningState = decoded.ProvisioningState + s.SapProduct = decoded.SapProduct + s.State = decoded.State + s.Status = decoded.Status + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SAPVirtualInstanceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["configuration"]; ok { + impl, err := UnmarshalSAPConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Configuration' for 'SAPVirtualInstanceProperties': %+v", err) + } + s.Configuration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go new file mode 100644 index 00000000000..0f1ff942c7f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_serviceinitiatedsoftwareconfiguration.go @@ -0,0 +1,55 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SoftwareConfiguration = ServiceInitiatedSoftwareConfiguration{} + +type ServiceInitiatedSoftwareConfiguration struct { + BomURL string `json:"bomUrl"` + HighAvailabilitySoftwareConfiguration *HighAvailabilitySoftwareConfiguration `json:"highAvailabilitySoftwareConfiguration,omitempty"` + SapBitsStorageAccountId string `json:"sapBitsStorageAccountId"` + SapFqdn string `json:"sapFqdn"` + SoftwareVersion string `json:"softwareVersion"` + SshPrivateKey string `json:"sshPrivateKey"` + + // Fields inherited from SoftwareConfiguration + + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s ServiceInitiatedSoftwareConfiguration) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return BaseSoftwareConfigurationImpl{ + SoftwareInstallationType: s.SoftwareInstallationType, + } +} + +var _ json.Marshaler = ServiceInitiatedSoftwareConfiguration{} + +func (s ServiceInitiatedSoftwareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ServiceInitiatedSoftwareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + decoded["softwareInstallationType"] = "ServiceInitiated" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServiceInitiatedSoftwareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go new file mode 100644 index 00000000000..0a5c9dd1dda --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sharedstorageresourcenames.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedStorageResourceNames struct { + SharedStorageAccountName *string `json:"sharedStorageAccountName,omitempty"` + SharedStorageAccountPrivateEndPointName *string `json:"sharedStorageAccountPrivateEndPointName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go new file mode 100644 index 00000000000..0b4d0c8b665 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverconfiguration.go @@ -0,0 +1,97 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ InfrastructureConfiguration = SingleServerConfiguration{} + +type SingleServerConfiguration struct { + CustomResourceNames SingleServerCustomResourceNames `json:"customResourceNames"` + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DbDiskConfiguration *DiskConfiguration `json:"dbDiskConfiguration,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` + + // Fields inherited from InfrastructureConfiguration + + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s SingleServerConfiguration) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return BaseInfrastructureConfigurationImpl{ + AppResourceGroup: s.AppResourceGroup, + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = SingleServerConfiguration{} + +func (s SingleServerConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SingleServerConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerConfiguration: %+v", err) + } + + decoded["deploymentType"] = "SingleServer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SingleServerConfiguration{} + +func (s *SingleServerConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DatabaseType *SAPDatabaseType `json:"databaseType,omitempty"` + DbDiskConfiguration *DiskConfiguration `json:"dbDiskConfiguration,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + SubnetId string `json:"subnetId"` + VirtualMachineConfiguration VirtualMachineConfiguration `json:"virtualMachineConfiguration"` + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DatabaseType = decoded.DatabaseType + s.DbDiskConfiguration = decoded.DbDiskConfiguration + s.NetworkConfiguration = decoded.NetworkConfiguration + s.SubnetId = decoded.SubnetId + s.VirtualMachineConfiguration = decoded.VirtualMachineConfiguration + s.AppResourceGroup = decoded.AppResourceGroup + s.DeploymentType = decoded.DeploymentType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SingleServerConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customResourceNames"]; ok { + impl, err := UnmarshalSingleServerCustomResourceNamesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomResourceNames' for 'SingleServerConfiguration': %+v", err) + } + s.CustomResourceNames = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go new file mode 100644 index 00000000000..0004c02b979 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleservercustomresourcenames.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 SingleServerCustomResourceNames interface { + SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl +} + +var _ SingleServerCustomResourceNames = BaseSingleServerCustomResourceNamesImpl{} + +type BaseSingleServerCustomResourceNamesImpl struct { + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s BaseSingleServerCustomResourceNamesImpl) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return s +} + +var _ SingleServerCustomResourceNames = RawSingleServerCustomResourceNamesImpl{} + +// RawSingleServerCustomResourceNamesImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSingleServerCustomResourceNamesImpl struct { + singleServerCustomResourceNames BaseSingleServerCustomResourceNamesImpl + Type string + Values map[string]interface{} +} + +func (s RawSingleServerCustomResourceNamesImpl) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return s.singleServerCustomResourceNames +} + +func UnmarshalSingleServerCustomResourceNamesImplementation(input []byte) (SingleServerCustomResourceNames, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerCustomResourceNames into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["namingPatternType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FullResourceName") { + var out SingleServerFullResourceNames + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingleServerFullResourceNames: %+v", err) + } + return out, nil + } + + var parent BaseSingleServerCustomResourceNamesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSingleServerCustomResourceNamesImpl: %+v", err) + } + + return RawSingleServerCustomResourceNamesImpl{ + singleServerCustomResourceNames: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go new file mode 100644 index 00000000000..b33a1da3d75 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverfullresourcenames.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SingleServerCustomResourceNames = SingleServerFullResourceNames{} + +type SingleServerFullResourceNames struct { + VirtualMachine *VirtualMachineResourceNames `json:"virtualMachine,omitempty"` + + // Fields inherited from SingleServerCustomResourceNames + + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s SingleServerFullResourceNames) SingleServerCustomResourceNames() BaseSingleServerCustomResourceNamesImpl { + return BaseSingleServerCustomResourceNamesImpl{ + NamingPatternType: s.NamingPatternType, + } +} + +var _ json.Marshaler = SingleServerFullResourceNames{} + +func (s SingleServerFullResourceNames) MarshalJSON() ([]byte, error) { + type wrapper SingleServerFullResourceNames + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerFullResourceNames: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerFullResourceNames: %+v", err) + } + + decoded["namingPatternType"] = "FullResourceName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerFullResourceNames: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go new file mode 100644 index 00000000000..4a39f4fee2a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_singleserverrecommendationresult.go @@ -0,0 +1,50 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPSizingRecommendationResult = SingleServerRecommendationResult{} + +type SingleServerRecommendationResult struct { + VMSku *string `json:"vmSku,omitempty"` + + // Fields inherited from SAPSizingRecommendationResult + + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s SingleServerRecommendationResult) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return BaseSAPSizingRecommendationResultImpl{ + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = SingleServerRecommendationResult{} + +func (s SingleServerRecommendationResult) MarshalJSON() ([]byte, error) { + type wrapper SingleServerRecommendationResult + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingleServerRecommendationResult: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingleServerRecommendationResult: %+v", err) + } + + decoded["deploymentType"] = "SingleServer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingleServerRecommendationResult: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go new file mode 100644 index 00000000000..dc6b71ff635 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_skipfileshareconfiguration.go @@ -0,0 +1,49 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FileShareConfiguration = SkipFileShareConfiguration{} + +type SkipFileShareConfiguration struct { + + // Fields inherited from FileShareConfiguration + + ConfigurationType FileShareConfigurationType `json:"configurationType"` +} + +func (s SkipFileShareConfiguration) FileShareConfiguration() BaseFileShareConfigurationImpl { + return BaseFileShareConfigurationImpl{ + ConfigurationType: s.ConfigurationType, + } +} + +var _ json.Marshaler = SkipFileShareConfiguration{} + +func (s SkipFileShareConfiguration) MarshalJSON() ([]byte, error) { + type wrapper SkipFileShareConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SkipFileShareConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SkipFileShareConfiguration: %+v", err) + } + + decoded["configurationType"] = "Skip" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SkipFileShareConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go new file mode 100644 index 00000000000..79d4059c6d0 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_softwareconfiguration.go @@ -0,0 +1,91 @@ +package sapvirtualinstances + +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 SoftwareConfiguration interface { + SoftwareConfiguration() BaseSoftwareConfigurationImpl +} + +var _ SoftwareConfiguration = BaseSoftwareConfigurationImpl{} + +type BaseSoftwareConfigurationImpl struct { + SoftwareInstallationType SAPSoftwareInstallationType `json:"softwareInstallationType"` +} + +func (s BaseSoftwareConfigurationImpl) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return s +} + +var _ SoftwareConfiguration = RawSoftwareConfigurationImpl{} + +// RawSoftwareConfigurationImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSoftwareConfigurationImpl struct { + softwareConfiguration BaseSoftwareConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawSoftwareConfigurationImpl) SoftwareConfiguration() BaseSoftwareConfigurationImpl { + return s.softwareConfiguration +} + +func UnmarshalSoftwareConfigurationImplementation(input []byte) (SoftwareConfiguration, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SoftwareConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["softwareInstallationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "External") { + var out ExternalInstallationSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExternalInstallationSoftwareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPInstallWithoutOSConfig") { + var out SAPInstallWithoutOSConfigSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SAPInstallWithoutOSConfigSoftwareConfiguration: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServiceInitiated") { + var out ServiceInitiatedSoftwareConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServiceInitiatedSoftwareConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseSoftwareConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSoftwareConfigurationImpl: %+v", err) + } + + return RawSoftwareConfigurationImpl{ + softwareConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go new file mode 100644 index 00000000000..8aa35391df6 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshconfiguration.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// 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/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go new file mode 100644 index 00000000000..c8c9f86c535 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshkeypair.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshKeyPair struct { + PrivateKey *string `json:"privateKey,omitempty"` + PublicKey *string `json:"publicKey,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go new file mode 100644 index 00000000000..4bd50069431 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sshpublickey.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// 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"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go new file mode 100644 index 00000000000..9c7466742e9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_startrequest.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartRequest struct { + StartVM *bool `json:"startVm,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go new file mode 100644 index 00000000000..08a49608fc9 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_stoprequest.go @@ -0,0 +1,9 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopRequest struct { + DeallocateVM *bool `json:"deallocateVm,omitempty"` + SoftStopTimeoutSeconds *int64 `json:"softStopTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go new file mode 100644 index 00000000000..ec178033530 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_storageconfiguration.go @@ -0,0 +1,33 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageConfiguration struct { + TransportFileShareConfiguration FileShareConfiguration `json:"transportFileShareConfiguration"` +} + +var _ json.Unmarshaler = &StorageConfiguration{} + +func (s *StorageConfiguration) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StorageConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["transportFileShareConfiguration"]; ok { + impl, err := UnmarshalFileShareConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TransportFileShareConfiguration' for 'StorageConfiguration': %+v", err) + } + s.TransportFileShareConfiguration = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go new file mode 100644 index 00000000000..19f94f63f0a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierconfiguration.go @@ -0,0 +1,100 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ InfrastructureConfiguration = ThreeTierConfiguration{} + +type ThreeTierConfiguration struct { + ApplicationServer ApplicationServerConfiguration `json:"applicationServer"` + CentralServer CentralServerConfiguration `json:"centralServer"` + CustomResourceNames ThreeTierCustomResourceNames `json:"customResourceNames"` + DatabaseServer DatabaseConfiguration `json:"databaseServer"` + HighAvailabilityConfig *HighAvailabilityConfiguration `json:"highAvailabilityConfig,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + StorageConfiguration *StorageConfiguration `json:"storageConfiguration,omitempty"` + + // Fields inherited from InfrastructureConfiguration + + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s ThreeTierConfiguration) InfrastructureConfiguration() BaseInfrastructureConfigurationImpl { + return BaseInfrastructureConfigurationImpl{ + AppResourceGroup: s.AppResourceGroup, + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = ThreeTierConfiguration{} + +func (s ThreeTierConfiguration) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierConfiguration: %+v", err) + } + + decoded["deploymentType"] = "ThreeTier" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierConfiguration: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ThreeTierConfiguration{} + +func (s *ThreeTierConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ApplicationServer ApplicationServerConfiguration `json:"applicationServer"` + CentralServer CentralServerConfiguration `json:"centralServer"` + DatabaseServer DatabaseConfiguration `json:"databaseServer"` + HighAvailabilityConfig *HighAvailabilityConfiguration `json:"highAvailabilityConfig,omitempty"` + NetworkConfiguration *NetworkConfiguration `json:"networkConfiguration,omitempty"` + StorageConfiguration *StorageConfiguration `json:"storageConfiguration,omitempty"` + AppResourceGroup string `json:"appResourceGroup"` + DeploymentType SAPDeploymentType `json:"deploymentType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ApplicationServer = decoded.ApplicationServer + s.CentralServer = decoded.CentralServer + s.DatabaseServer = decoded.DatabaseServer + s.HighAvailabilityConfig = decoded.HighAvailabilityConfig + s.NetworkConfiguration = decoded.NetworkConfiguration + s.StorageConfiguration = decoded.StorageConfiguration + s.AppResourceGroup = decoded.AppResourceGroup + s.DeploymentType = decoded.DeploymentType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ThreeTierConfiguration into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customResourceNames"]; ok { + impl, err := UnmarshalThreeTierCustomResourceNamesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomResourceNames' for 'ThreeTierConfiguration': %+v", err) + } + s.CustomResourceNames = impl + } + + return nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go new file mode 100644 index 00000000000..da72d08566f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetiercustomresourcenames.go @@ -0,0 +1,75 @@ +package sapvirtualinstances + +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 ThreeTierCustomResourceNames interface { + ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl +} + +var _ ThreeTierCustomResourceNames = BaseThreeTierCustomResourceNamesImpl{} + +type BaseThreeTierCustomResourceNamesImpl struct { + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s BaseThreeTierCustomResourceNamesImpl) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return s +} + +var _ ThreeTierCustomResourceNames = RawThreeTierCustomResourceNamesImpl{} + +// RawThreeTierCustomResourceNamesImpl is returned when the Discriminated Value doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawThreeTierCustomResourceNamesImpl struct { + threeTierCustomResourceNames BaseThreeTierCustomResourceNamesImpl + Type string + Values map[string]interface{} +} + +func (s RawThreeTierCustomResourceNamesImpl) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return s.threeTierCustomResourceNames +} + +func UnmarshalThreeTierCustomResourceNamesImplementation(input []byte) (ThreeTierCustomResourceNames, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierCustomResourceNames into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["namingPatternType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FullResourceName") { + var out ThreeTierFullResourceNames + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ThreeTierFullResourceNames: %+v", err) + } + return out, nil + } + + var parent BaseThreeTierCustomResourceNamesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseThreeTierCustomResourceNamesImpl: %+v", err) + } + + return RawThreeTierCustomResourceNamesImpl{ + threeTierCustomResourceNames: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go new file mode 100644 index 00000000000..01be320e9ba --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierfullresourcenames.go @@ -0,0 +1,53 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ThreeTierCustomResourceNames = ThreeTierFullResourceNames{} + +type ThreeTierFullResourceNames struct { + ApplicationServer *ApplicationServerFullResourceNames `json:"applicationServer,omitempty"` + CentralServer *CentralServerFullResourceNames `json:"centralServer,omitempty"` + DatabaseServer *DatabaseServerFullResourceNames `json:"databaseServer,omitempty"` + SharedStorage *SharedStorageResourceNames `json:"sharedStorage,omitempty"` + + // Fields inherited from ThreeTierCustomResourceNames + + NamingPatternType NamingPatternType `json:"namingPatternType"` +} + +func (s ThreeTierFullResourceNames) ThreeTierCustomResourceNames() BaseThreeTierCustomResourceNamesImpl { + return BaseThreeTierCustomResourceNamesImpl{ + NamingPatternType: s.NamingPatternType, + } +} + +var _ json.Marshaler = ThreeTierFullResourceNames{} + +func (s ThreeTierFullResourceNames) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierFullResourceNames + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierFullResourceNames: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierFullResourceNames: %+v", err) + } + + decoded["namingPatternType"] = "FullResourceName" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierFullResourceNames: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go new file mode 100644 index 00000000000..6a4a5108da1 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_threetierrecommendationresult.go @@ -0,0 +1,55 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SAPSizingRecommendationResult = ThreeTierRecommendationResult{} + +type ThreeTierRecommendationResult struct { + ApplicationServerInstanceCount *int64 `json:"applicationServerInstanceCount,omitempty"` + ApplicationServerVMSku *string `json:"applicationServerVmSku,omitempty"` + CentralServerInstanceCount *int64 `json:"centralServerInstanceCount,omitempty"` + CentralServerVMSku *string `json:"centralServerVmSku,omitempty"` + DatabaseInstanceCount *int64 `json:"databaseInstanceCount,omitempty"` + DbVMSku *string `json:"dbVmSku,omitempty"` + + // Fields inherited from SAPSizingRecommendationResult + + DeploymentType SAPDeploymentType `json:"deploymentType"` +} + +func (s ThreeTierRecommendationResult) SAPSizingRecommendationResult() BaseSAPSizingRecommendationResultImpl { + return BaseSAPSizingRecommendationResultImpl{ + DeploymentType: s.DeploymentType, + } +} + +var _ json.Marshaler = ThreeTierRecommendationResult{} + +func (s ThreeTierRecommendationResult) MarshalJSON() ([]byte, error) { + type wrapper ThreeTierRecommendationResult + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ThreeTierRecommendationResult: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ThreeTierRecommendationResult: %+v", err) + } + + decoded["deploymentType"] = "ThreeTier" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ThreeTierRecommendationResult: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go new file mode 100644 index 00000000000..d956979e1b3 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstanceproperties.go @@ -0,0 +1,8 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSAPVirtualInstanceProperties struct { + ManagedResourcesNetworkAccessType *ManagedResourcesNetworkAccessType `json:"managedResourcesNetworkAccessType,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go new file mode 100644 index 00000000000..95da3bf4f6e --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go @@ -0,0 +1,14 @@ +package sapvirtualinstances + +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 UpdateSAPVirtualInstanceRequest struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *UpdateSAPVirtualInstanceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go new file mode 100644 index 00000000000..ec4bdf513ab --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineconfiguration.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineConfiguration struct { + ImageReference ImageReference `json:"imageReference"` + OsProfile OSProfile `json:"osProfile"` + VMSize string `json:"vmSize"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go new file mode 100644 index 00000000000..a9767d0a758 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_virtualmachineresourcenames.go @@ -0,0 +1,12 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineResourceNames struct { + DataDiskNames *map[string][]string `json:"dataDiskNames,omitempty"` + HostName *string `json:"hostName,omitempty"` + NetworkInterfaces *[]NetworkInterfaceResourceNames `json:"networkInterfaces,omitempty"` + OsDiskName *string `json:"osDiskName,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go new file mode 100644 index 00000000000..81f41dff686 --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_windowsconfiguration.go @@ -0,0 +1,49 @@ +package sapvirtualinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OSConfiguration = WindowsConfiguration{} + +type WindowsConfiguration struct { + + // Fields inherited from OSConfiguration + + OsType OSType `json:"osType"` +} + +func (s WindowsConfiguration) OSConfiguration() BaseOSConfigurationImpl { + return BaseOSConfigurationImpl{ + OsType: s.OsType, + } +} + +var _ json.Marshaler = WindowsConfiguration{} + +func (s WindowsConfiguration) MarshalJSON() ([]byte, error) { + type wrapper WindowsConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling WindowsConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling WindowsConfiguration: %+v", err) + } + + decoded["osType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling WindowsConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go new file mode 100644 index 00000000000..7b18cd9294a --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/predicates.go @@ -0,0 +1,32 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SAPVirtualInstanceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SAPVirtualInstanceOperationPredicate) Matches(input SAPVirtualInstance) 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/workloads/2024-09-01/sapvirtualinstances/version.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go new file mode 100644 index 00000000000..6793a56243f --- /dev/null +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/version.go @@ -0,0 +1,10 @@ +package sapvirtualinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sapvirtualinstances/2024-09-01" +}